Source

boxer / lace-maker

Diff from to

lace-maker

 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;
 
 
 	# 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 <<"";
 		<g transform	= "translate($cx,$cy)" >
 		<path
-			transform	= "scale(0.5)"
+			transform	= "scale($scale)"
 			stroke		= "#ff0000"
 			fill		= "none"
 			stroke-width	= "0.1px"
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.