Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
30
Task/Fractal-tree/Perl/fractal-tree.pl
Normal file
30
Task/Fractal-tree/Perl/fractal-tree.pl
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
use GD::Simple;
|
||||
|
||||
my ($width, $height) = (1000,1000); # image dimension
|
||||
my $scale = 6/10; # branch scale relative to trunk
|
||||
my $length = 400; # trunk size
|
||||
|
||||
my $img = GD::Simple->new($width,$height);
|
||||
$img->fgcolor('black');
|
||||
$img->penSize(1,1);
|
||||
|
||||
tree($width/2, $height, $length, 270);
|
||||
|
||||
print $img->png;
|
||||
|
||||
|
||||
sub tree
|
||||
{
|
||||
my ($x, $y, $len, $angle) = @_;
|
||||
|
||||
return if $len < 1;
|
||||
|
||||
$img->moveTo($x,$y);
|
||||
$img->angle($angle);
|
||||
$img->line($len);
|
||||
|
||||
($x, $y) = $img->curPos();
|
||||
|
||||
tree($x, $y, $len*$scale, $angle+35);
|
||||
tree($x, $y, $len*$scale, $angle-35);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue