#!/usr/bin/perl -w
# $URL: svn+ssh://mrwhat@ssh.boim.com/home/mrwhat/svn/Walker/trunk/spacersP1.pl $
# $Id: spacersP1.pl 278 2013-10-11 14:14:48Z mrwhat $
#
# script to draw generic spacers and shims.  On a sheet.
# mostly to get 2mm spacers and shims, which are only available at Ponoko

$preview = $#ARGV < 0;  # set to 0 for actual size code generation... will generate REAL code if given any argument

# ponoko laser cutting sheets come in 181x181mm, 384x384mm, 384 wide x 790mm long
$wPx = 181;  # width of drawing, pixels?!?? -- most programs seem to ignore units, use mm
$hPx = 181;  # height of drawing, pixels?!??

$cutWidth=$preview?.2:.01;  # suggested .01 for real laser cut, but we can't see that in pixel display

require 'JansenDefs.pl';
require 'laserCutPartsPrimitives.pl';

&printHeader($wPx,$hPx);
printf("<g style=\"fill:none; stroke-width:%.2f; stroke-linejoin:miter; stroke-linecap:butt;\">\n",
       $preview?4:0.01);
&drawCornerFiducials($wPx,$hPx,$preview);

# put whole drawing in a group which scales mm to pixels
printf("<g transform=\"scale(%d)\" style=\"stroke-width:$cutWidth;\" stroke='$cutColor'>",
       $preview?10:1);  # 10 pixels/mm, rest of drawing in mm

### need 16 thin spacers for cranklinks (+ some spares?)
local $rs = 6.2;   # outer radius of crank spacers
local $x0 = 135+1.75;
local $y0 = 6.4+2;
for (local $j=0;$j<16;$j++) { for (local $i=0; $i<(($j % 2)?4:3);$i++) {
        &roundSpacer($x0+$i*12.58+((($j%2)==0)?6.3:0),
                     $y0+$j*10.9,$radQ,$rs);
}}

#print "<g transform=\"translate(2,5.4)\">";
#for (local $i=0; $i<18;$i++) { &spacerRow(6,10*$i,$i?1:0); }
print "<g transform=\"translate(125.4,0) rotate(90)\">";
for (local $i=0; $i<13;$i++) { &spacerRow(9,10*$i,$i?1:0); }
print "</g>\n";

print "</g>\n";  # end of mm scale 
print "</g>\n";  # end of cut-line drawing group
print "</svg>\n"; # end of drawing
