diff echo.pl @ 40:1ac1409ea68c laserkard

[svn r41] implemented dynamic text.
author rlm
date Mon, 25 Jan 2010 03:42:08 -0500
parents 07c19a58ba5a
children 95fa4bcc5d67
line wrap: on
line diff
     1.1 --- a/echo.pl	Sun Jan 24 15:06:22 2010 -0500
     1.2 +++ b/echo.pl	Mon Jan 25 03:42:08 2010 -0500
     1.3 @@ -13,7 +13,7 @@
     1.4  use Data::Dumper;
     1.5  $Data::Dumper::Indent = 1;
     1.6  use Storable;
     1.7 -
     1.8 +use SVG;
     1.9  
    1.10  my $q = new CGI;
    1.11  
    1.12 @@ -68,11 +68,12 @@
    1.13  my $svg = $_[0];
    1.14  
    1.15  my $destination = 'rlm@mit.edu';	
    1.16 -#~ $svg =~ s/</\&lt\;/g;
    1.17 -#~ return $svg;
    1.18  
    1.19  
    1.20 -$svg = &repair_file($svg);
    1.21 +
    1.22 +
    1.23 +$svg = &impose($svg);
    1.24 +
    1.25  
    1.26  
    1.27  
    1.28 @@ -87,6 +88,141 @@
    1.29  }
    1.30  
    1.31  
    1.32 +
    1.33 +sub impose
    1.34 +{
    1.35 +
    1.36 +#here $svg is a string which contains the properly formatted svg data for one card
    1.37 +#out purpose here is to take that one card, size it correctly, and make appropiate copies 
    1.38 +#so that our supplier can simply import the file and print.
    1.39 +
    1.40 +$sss =  $_[0];
    1.41 +$sss =~ s/^/\n\n\n/;
    1.42 +$sss =~ s/$/\n\n\n/;
    1.43 +# you fucking bitch!
    1.44 +$sss =~ s/Created wit........//;
    1.45 +
    1.46 +
    1.47 +# read XML file
    1.48 +my $xml = new XML::Simple;
    1.49 +my $data = $xml->XMLin($sss, ForceArray => 1);
    1.50 +
    1.51 +
    1.52 +my %data = %$data;
    1.53 +
    1.54 +my %juzz  = 
    1.55 +(
    1.56 +
    1.57 +path	=> $data{'path'},
    1.58 +rect 	=> $data{'rect'},
    1.59 +width	=>"16in" ,
    1.60 +height	=>"12in" ,
    1.61 +version	=>"1.1",
    1.62 +xmlns	=>"http://www.w3.org/2000/svg"
    1.63 +
    1.64 +);
    1.65 +
    1.66 +
    1.67 +
    1.68 +
    1.69 +#print Dumper(%juzz);
    1.70 +
    1.71 +
    1.72 +my $svg= SVG->new(width=>"18in",height=>"12in");
    1.73 +
    1.74 +#print Dumper($juzz{'path'}[2]);
    1.75 +#print "\n***************************\n";
    1.76 +#print Dumper($pathData);
    1.77 +
    1.78 +
    1.79 +
    1.80 +
    1.81 +my $base = "scale(0.6057),matrix(1 0 0 -1 0 317), rotate(180),translate(-514,-317)";
    1.82 +
    1.83 +
    1.84 +my @cardCollection;
    1.85 +
    1.86 +for $name(0..21)  #22 letters for 22 cards
    1.87 +{
    1.88 +	
    1.89 +	#calcuate the thing's place in the grid:
    1.90 +	
    1.91 +	$cardsToARow = 5;
    1.92 +	$cardsToAColumn =  5;
    1.93 +	
    1.94 +	my $row = int($name/$cardsToARow);  #  cards to a row 
    1.95 +	my $column = int($name %  $cardsToAColumn);
    1.96 +	
    1.97 +	$margin = 25;
    1.98 +	$cardWidth   =  514*0.6057;
    1.99 +	$cardHeight  = 	317*0.6057;
   1.100 +	
   1.101 +	
   1.102 +	$transX = 40 + ($margin + $cardWidth ) * $column;
   1.103 +	$transY = 40 + ($margin + $cardHeight) * $row;
   1.104 +	
   1.105 +	
   1.106 +	
   1.107 +	${"group_".$name} = 
   1.108 +	$svg->group(
   1.109 +    id    => "group_".$name,    
   1.110 +	transform => "translate($transX,$transY),"."$base"
   1.111 +	);
   1.112 +	
   1.113 +	push @cardCollection, ${"group_".$name};
   1.114 +}
   1.115 +
   1.116 +
   1.117 +
   1.118 +      
   1.119 +  
   1.120 +        
   1.121 +        
   1.122 +        
   1.123 +for ($i = 0; $i <= $#cardCollection; $i++)
   1.124 +{
   1.125 +
   1.126 +for $pathData(@{$juzz{'path'}})
   1.127 +{
   1.128 +$cardCollection[$i]->tag('path', %{$pathData});
   1.129 +}
   1.130 +
   1.131 +for $pathData(@{$juzz{'rect'}})
   1.132 +{
   1.133 +$cardCollection[$i]->tag('rect', %{$pathData});
   1.134 +}
   1.135 +
   1.136 +
   1.137 +}
   1.138 +
   1.139 +
   1.140 +
   1.141 +#my $tag = $svg->tag('path', $juzz{'path'});
   1.142 +
   1.143 +
   1.144 +#$tag = $svg->group(%attributes);
   1.145 +
   1.146 +
   1.147 +$output =  $svg->xmlify;
   1.148 +
   1.149 +
   1.150 +$killCopyrigt = <<HERE;
   1.151 +<!-- 
   1.152 +	Generated using the Perl SVG Module V2.49
   1.153 +	by Ronan Oger
   1.154 +	Info: http://www.roitsystems.com/
   1.155 + -->
   1.156 +HERE
   1.157 +
   1.158 +$output =~ s/$killCopyrigt/\n/;
   1.159 +
   1.160 +return $output;
   1.161 +
   1.162 +	
   1.163 +	
   1.164 +}
   1.165 +
   1.166 +
   1.167  sub repair_file
   1.168  {
   1.169