-
Notifications
You must be signed in to change notification settings - Fork 0
/
fi.pl
42 lines (32 loc) · 593 Bytes
/
fi.pl
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
36
37
38
39
40
41
42
#!/usr/bin/perl
# Daniel "Trizen" Șuteu
# License: GPLv3
# Date: 18 May 2014
# https://github.com/trizen
use 5.010;
use strict;
use warnings;
use GD::Simple;
my $img = 'GD::Simple'->new(1500, 1000);
$img->moveTo(250, 530);
sub t($) {
$img->turn(shift);
}
sub l($) {
$img->line(shift);
}
sub c($) {
$img->fgcolor(shift);
}
sub fib {
my ($n) = @_;
my $res = $n < 2 ? $n : fib($n - 2) + fib($n - 1);
l($res * 4);
t(90);
$res;
}
fib(14);
my $image_name = 'fibonacci_turtle.png';
open my $fh, '>', $image_name or die $!;
print {$fh} $img->png;
close $fh;