# HG changeset patch # User Trammell Hudson # Date 1356553147 18000 # Node ID 24316cb2c16f951d59629f5ef448f562b6ff6bb7 # Parent 75b4686600d53c976602a4c72c1292c98061732b scale around average x/y diff --git a/lace-maker b/lace-maker --- a/lace-maker +++ b/lace-maker @@ -5,7 +5,8 @@ use Math::Geometry::Voronoi; my \$size = 300; -my \$num = 10; +my \$num = 200; +my \$scale = 0.8; my @points = map { [ rand \$size, rand \$size ] } 0..\$num; @@ -27,25 +28,22 @@ # Find the center point of the polygon. # Throw away any polygons that are outside of the box. - for (my \$i = 0 ; \$i < \$count-1 ; \$i++) + for (my \$i = 0 ; \$i < \$count ; \$i++) { my (\$x0,\$y0) = @{ \$poly->[\$i+0] }; - my (\$x1,\$y1) = @{ \$poly->[\$i+1] }; - my \$a0 = \$x0*\$y1 - \$x1*\$y0; + \$cx += \$x0; + \$cy += \$y0; - \$cx += (\$x0 + \$x1) * \$a0; - \$cy += (\$y0 + \$y1) * \$a0; - \$a += \$a0 / 2; } - \$cx /= 6 * \$a; - \$cy /= 6 * \$a; - printf STDERR "%.5f, %.5f\n", \$cx, \$cy; + \$cx /= \$count; + \$cy /= \$count; + #printf STDERR "%.5f, %.5f\n", \$cx, \$cy; print <<"";