]> granicus.if.org Git - imagemagick/blob - PerlMagick/demo/tree.pl
(no commit message)
[imagemagick] / PerlMagick / demo / tree.pl
1 #!/usr/bin/perl
2 #
3 # Example of using a lsys fractal,
4 # which in turm used Turtle Graphics
5 #
6 require "lsys.pl";
7
8 %rule = (
9           'A' => 'S[---LMA][++++B]',
10           'B' => 'S[++LBg][--Cg]',
11           'C' => 'S[-----LB]GS[+MC]',
12           'g' => '',
13           'L' => '[{S+S+S+S+S+S}]'
14         );
15
16 %stemchanges = (
17   distance => 18.5,
18   dtheta => 0.1,
19   motionsub => sub{
20                     $im->Draw ( primitive=>'line', points=>join(' ',@_),
21                                 stroke=>'dark green', strokewidth=>1 );
22                   }
23 );
24
25 %polychanges = (
26   distance => 3,
27   dtheta => 0.4,
28   motionsub => sub{ push( @poly, @_[0..1] ); }
29 );
30
31 $changes = \%stemchanges;
32 lsys_init(400);
33 lsys_execute('A', 10, "tree.gif", %rule);