SHARE
TWEET

svg-grid.pl

a guest Mar 26th, 2018 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/perl -Tw
  2. use strict;
  3. use SVG;
  4.  
  5. my $margin=10;
  6. my $size=42;
  7.  
  8. my $imgsize = 2*$margin + 9*$size;
  9.  
  10. my $img=SVG->new(width=>$imgsize, height=>$imgsize);
  11.  
  12. my $squares=$img->group(
  13.     id    => 'squares',
  14.     style => { stroke=>'black', fill=>'none', "stroke-width"=>1 }
  15.     );
  16. my $blocks=$img->group(
  17.     id    => 'blocks',
  18.     style => { stroke=>'black', fill=>'none', "stroke-width"=>3 }
  19.     );
  20.  
  21.  
  22. foreach my $x (0..8)
  23. {
  24.     foreach my $y (0..8)
  25.     {
  26.         $squares->rectangle(
  27.             x => $margin + $size * $x,
  28.             y => $margin + $size * $y,
  29.             width => $size,
  30.             height => $size,
  31.             id => "square_$x,$y",
  32.             );
  33.  
  34.         if($x % 3 == 0)
  35.         {
  36.             $blocks->rectangle(
  37.             x => $margin + $size * $x,
  38.             y => $margin + $size * $y,
  39.             width => $size * 3,
  40.             height => $size,
  41.             id => "block_$x,$y",
  42.             );
  43.         }
  44.     }
  45. }
  46.  
  47. print $img->xmlify();
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top