File: tree.pl

package info (click to toggle)
imagemagick 8%3A7.1.1.47%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 90,424 kB
  • sloc: ansic: 372,037; cpp: 22,844; xml: 11,549; perl: 6,285; sh: 6,203; makefile: 3,484; tcl: 459
file content (35 lines) | stat: -rw-r--r-- 744 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/perl
#
# Example of using a lsys fractal,
# which in turm used Turtle Graphics
#
use Cwd;
use lib cwd;
require "lsys.pl";

%rule = (
	  'A' => 'S[---LMA][++++B]',
          'B' => 'S[++LBg][--Cg]',
          'C' => 'S[-----LB]GS[+MC]',
          'g' => '',
          'L' => '[{S+S+S+S+S+S}]'
        );

%stemchanges = (
  distance => 18.5,
  dtheta => 0.1,
  motionsub => sub{
                    $im->Draw ( primitive=>'line', points=>join(' ',@_),
                                stroke=>'dark green', strokewidth=>1 );
                  }
);

%polychanges = (
  distance => 3,
  dtheta => 0.4,
  motionsub => sub{ push( @poly, @_[0..1] ); }
);

$changes = \%stemchanges;
lsys_init(400);
lsys_execute('A', 10, "tree.pam", %rule);