Source

boxer / boxer

Diff from to
 
 my $units = "mm"; # mm = 1, inches = 1000 / 25.4
 my $thickness = 3;
-my $sides = 9;
+my $sides = 4;
 my $edge = 30;
 my $height = 20;
+my $tab_width = 5;
 
 my $deg2rad = 
 
 # Compute the height of the interior triangle
 my $interior_angle = 360.0 / $sides;
-my $hx = $edge / 2;
-my $hy = $hx / tan(deg2rad($interior_angle/2));
+my $interior_len = $edge - $thickness/2;
+my $interior_radius = ($interior_len/2) / tan(deg2rad($interior_angle/2));
 
 
 print <<"";
 for my $side (0..$sides-1)
 {
 	my $angle = (360 / $sides) * $side;
+	my $hx = $interior_len / 2;
+
+	# Put one tab in the middle
+	my $tab_x1 = $hx - $tab_width/2;
+	my $tab_x2 = $hx + $tab_width/2;
 
 	print <<"";
 	<g
-		transform="rotate(-$angle) translate(-$hx $hy)"
+		transform="rotate(-$angle) translate(-$hx $interior_radius)"
 	><path
 		stroke="#ff0000"
+		fill="NONE"
 		d="M
 
 	print <<"";
 		0 0
-		$edge 0
+		$tab_x1 0
+		$tab_x1 $thickness
+		$tab_x2 $thickness
+		$tab_x2 0
+		$interior_len 0
 
 	print <<"";
 	"/><text>$side</text></g>
 print <<"";
 </g>
 
+#
+# Draw the edge pieces
+#
+print <<"";
+<g transform="translate(200 200)">
+
+for my $side (0..$sides-1)
+{
+	my $origin_x = $side * ($edge + $thickness + 2);
+
+	# Put one tab in the middle of the top and bottom edges
+	my $tab_x1 = $edge/2 - $tab_width/2;
+	my $tab_x2 = $edge/2 + $tab_width/2;
+
+	# Put one tab in the middle of the left and right edges
+	my $side_tab_x1 = $height/2 - $tab_width/2;
+	my $side_tab_x2 = $height/2 + $tab_width/2;
+
+	print <<"";
+	<g transform="translate($origin_x 0)">
+
+	print <<"";
+	<!-- bottom edge -->
+	<path
+		transform="translate(0 0) rotate(0 0 0)"
+		stroke="#ff0000"
+		fill="NONE"
+		d="M
+			$thickness 0
+			$tab_x1 0
+			$tab_x1 -$thickness
+			$tab_x2 -$thickness
+			$tab_x2 0
+			$edge 0
+		"
+	/>
+
+	print <<"";
+	<!-- right side edge; tab goes out-->
+	<path
+		transform="translate($edge 0) rotate(-90 0 0)"
+		stroke="#ff0000"
+		fill="NONE"
+		d="M
+			0 0
+			$side_tab_x1 0
+			$side_tab_x1 $thickness
+			$side_tab_x2 $thickness
+			$side_tab_x2 0
+			$height 0
+		"
+	/>
+
+	print <<"";
+	<!-- top edge -->
+	<path
+		transform="translate($edge -$height) rotate(-180 0 0)"
+		stroke="#ff0000"
+		fill="NONE"
+		d="M
+			0 0
+			$tab_x1 0
+			$tab_x1 -$thickness
+			$tab_x2 -$thickness
+			$tab_x2 0
+			@{[$edge - $thickness]} 0
+		"
+	/>
+
+	print <<"";
+	<!-- left side edge; tab goes out-->
+	<path
+		transform="translate($thickness -$height) rotate(-270 0 0)"
+		stroke="#ff0000"
+		fill="NONE"
+		d="M
+			0 0
+			$side_tab_x1 0
+			$side_tab_x1 -$thickness
+			$side_tab_x2 -$thickness
+			$side_tab_x2 0
+			$height 0
+		"
+	/>
+
+	print <<"";
+	</g>
+
+}
+
+print <<"";
+</g>
 
 
 print <<"";