1#!/usr/bin/perl
2#
3# Example of using a lsys fractal,
4# which in turm used Turtle Graphics
5#
6require "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;
32lsys_init(400);
33lsys_execute('A', 10, "tree.gif", %rule);
34