# HG changeset patch # User rlm # Date 1264363582 18000 # Node ID 8b3b5753ad41cafb4491d7093e4abbeb65542864 # Parent 07c19a58ba5ae3bc640e0e66d256d7cb3577166a [svn r40] created succesuful interface to corel Draw :) diff -r 07c19a58ba5a -r 8b3b5753ad41 sex_again.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sex_again.pl Sun Jan 24 15:06:22 2010 -0500 @@ -0,0 +1,291 @@ +#!/usr/bin/perl + + + + + +use List::Util qw(first max maxstr min minstr reduce shuffle sum); +use Storable; +use CGI::Ajax; +use CGI qw(:standard); +use URI::Escape; +use MIME::QuotedPrint; +use MIME::Base64; +use Mail::Sendmail 0.75; # doesn't work with v. 0.74! +use XML::Simple; +use Data::Dumper; +$Data::Dumper::Indent = 1; +use Storable; +use SVG; + + +$ref = retrieve('file'); + +#print Dumper $$ref; +&echo($$ref); +#&impose($$ref); + + + + +sub impose +{ + +#here $svg is a string which contains the properly formatted svg data for one card +#out purpose here is to take that one card, size it correctly, and make appropiate copies +#so that our supplier can simply import the file and print. + +$sss = $_[0]; +$sss =~ s/^/\n\n\n/; +$sss =~ s/$/\n\n\n/; +# you fucking bitch! +$sss =~ s/Created wit........//; + + +# read XML file +my $xml = new XML::Simple; +my $data = $xml->XMLin($sss, ForceArray => 1); + + +my %data = %$data; + +my %juzz = +( + +path => $data{'path'}, +rect => $data{'rect'}, +width =>"16in" , +height =>"12in" , +version =>"1.1", +xmlns =>"http://www.w3.org/2000/svg" + +); + + + + +#print Dumper(%juzz); + + +my $svg= SVG->new(width=>"18in",height=>"12in"); + +#print Dumper($juzz{'path'}[2]); +print "\n***************************\n"; +#print Dumper($pathData); + + + + +my $base = "scale(0.6057),matrix(1 0 0 -1 0 317), rotate(180),translate(-514,-317)"; + + +my @cardCollection; + +for $name(0..21) #22 letters for 22 cards +{ + + #calcuate the thing's place in the grid: + + $cardsToARow = 5; + $cardsToAColumn = 5; + + my $row = int($name/$cardsToARow); # cards to a row + my $column = int($name % $cardsToAColumn); + + $margin = 25; + $cardWidth = 514*0.6057; + $cardHeight = 317*0.6057; + + + $transX = 40 + ($margin + $cardWidth ) * $column; + $transY = 40 + ($margin + $cardHeight) * $row; + + + + ${"group_".$name} = + $svg->group( + id => "group_".$name, + transform => "translate($transX,$transY),"."$base" + ); + + push @cardCollection, ${"group_".$name}; +} + + + + +#my $y=$svg->group( +# id => 'group_y' ); +# +#my $f=$svg->group( +# id => 'group_f' , +# transform => "$base" +# +# ); +# +# + + + + + + +for ($i = 0; $i <= $#cardCollection; $i++) +{ + +for $pathData(@{$juzz{'path'}}) +{ +$cardCollection[$i]->tag('path', %{$pathData}); +} + +for $pathData(@{$juzz{'rect'}}) +{ +$cardCollection[$i]->tag('rect', %{$pathData}); +} + + +} + + + +#my $tag = $svg->tag('path', $juzz{'path'}); + + +#$tag = $svg->group(%attributes); + + +$output = $svg->xmlify; + + +$killCopyrigt = < +HERE + +$output =~ s/$killCopyrigt/\n/; + +return $output; + + + +} + + + + + + + + + + + + +sub echo +{ + + +my $svg = $_[0]; + +my $destination = 'rlm@mit.edu'; +#~ $svg =~ s/C:/Documents and Settings/Robert McIntyre/Desktop/perlOut.svg'; +select OUT; +print $svg; +close OUT; + +#&mail($svg, $destination); + +return "done."; + +} + + + + + + +sub repair_file +{ + + +$sss = $_[0]; + + + +$sss =~ s/^/\n\n\n/; +$sss =~ s/$/\n\n\n/; +# you fucking bitch. +$sss =~ s/Created wit........//; + + +store \$sss, 'file'; + +# read XML file +my $xml = new XML::Simple; +my $data = $xml->XMLin($sss, ForceArray => 1); + + +my %data = %$data; + +my %juzz = +( + +path => $data{'path'}, +rect => $data{'rect'}, +width =>"16in" , +height =>"12in" , +version =>"1.1", +xmlns =>"http://www.w3.org/2000/svg" + +); + + +$out = $xml->XMLout(\%juzz , RootName=>'svg'); + + +my $fixed = < + +HERE + + + +$fixed .= $out; + +#print $fixed; +return $fixed; + +} + + + + + + + + + + + + + + + + + + + diff -r 07c19a58ba5a -r 8b3b5753ad41 svgExample.pl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/svgExample.pl Sun Jan 24 15:06:22 2010 -0500 @@ -0,0 +1,59 @@ + #!/usr/bin/perl -w + use strict; + use SVG; + + # create an SVG object + my $svg= SVG->new(width=>200,height=>200); + #or + my $svg= SVG->new(width=>200,height=>200); + + # use explicit element constructor to generate a group element + my $y=$svg->group( + id => 'group_y', + style => { stroke=>'red', fill=>'green' } + ); + + # add a circle to the group + $y->circle(cx=>100, cy=>100, r=>50, id=>'circle_in_group_y'); + + # or, use the generic 'tag' method to generate a group element by name + my $z=$svg->tag('g', + id => 'group_z', + style => { + stroke => 'rgb(100,200,50)', + fill => 'rgb(10,100,150)' + } + ); + + # create and add a circle using the generic 'tag' method + $z->tag('circle', cx=>50, cy=>50, r=>100, id=>'circle_in_group_z'); + + # create an anchor on a rectangle within a group within the group z + my $k = $z->anchor( + id => 'anchor_k', + -href => 'http://test.hackmare.com/', + target => 'new_window_0' + )->rectangle( + x => 20, y => 50, + width => 20, height => 30, + rx => 10, ry => 5, + id => 'rect_k_in_anchor_k_in_group_z' + ); + + # now render the SVG object, implicitly use svg namespace + print $svg->xmlify; + + # or render a child node of the SVG object without rendering the entire object + print $k->xmlify; #renders the anchor $k above containing a rectangle, but does not + #render any of the ancestor nodes of $k + + + # or, explicitly use svg namespace and generate a document with its own DTD + print $svg->xmlify(-namespace=>'svg'); + + # or, explicitly use svg namespace and generate an in-line docunent + print $svg->xmlify( + -namespace => "svg", + -pubid => "-//W3C//DTD SVG 1.0//EN", + -inline => 1 + ); \ No newline at end of file