use strict; use GD; ## Load public GD library require "../utils.pl"; ## code to create sets of points, draw lines, etc. my $im = new GD::Image(340,340); ## Create an image my $white = $im->colorAllocate(255,255,255); ## Define some colours my @col = ($im->colorAllocate(0,0,255), $im->colorAllocate(255,0,0), $im->colorAllocate(0,170,0) ); my $grey = $im->colorAllocate(170,170,170); $im->interlaced('true'); my $f = rose( [185,160], 107, 3, 1/20 ); ## 'rose' creates an array of points equally spaced around a circle my ( @x, @y ); for ( my $j=0 ; $j<3 ; $j++ ) { $x[$j] = rose( $$f[$j], 80, 6, 1/12 ); $y[$j] = rose( $$f[$j], 16, 2, -2/9 ); } for ( my $j=0 ; $j<3 ; $j++ ) { for ( my $i=0 ; $i<6 ; $i++ ) { arcp( $im, $x[$j][$i], $x[($j+1)%3][$i], $grey, -1 ); # 'arcp' draws a line between the points specified arcp( $im, $y[$j][0], $y[($j+1)%3][0], $grey, -1 ); arcp( $im, $y[$j][1], $y[($j+1)%3][1], $grey, -1 ); arcp( $im, $x[$j][$i], $x[$j][($i+1)%6], $col[($i+$j+1)%3], -1 ); arcp( $im, $x[$j][$i], $x[$j][($i+2)%6], $col[($i+$j)%3], -1 ); arcp( $im, $y[$j][1], $x[$j][$i], $col[($i+$j+2)%3], $i&1?1:-1 ); arcp( $im, $y[$j][0], $x[$j][$i], $col[($i+$j+2)%3], $i&1?-1:1 ); } } open( FN, ">q8sc3.png" ); binmode FN; print FN $im->png; close ( FN );