Hi everyone:

While I am learning more about the GD.pm module, I thought up an idea to draw an abstract salute to NodeReaper's cherry pies, by drawing a picture (somewhat,) using the GD.pm module. I wasn't sure what section to put this under, since there really aren't any "code art" sections or anything, so I decided to just put it in here, as to not add excess to other sections that this wouldn't fit under. So, here's the code, and also there is an output of the program at: HERE if you would rather see it in action, and not run it using the code.

#!/usr/bin/perl -w use strict; use GD; my ($width, $height) = (300,300); # Create a new image my $im = new GD::Image($width,$height); # Allocate some colors my $white = $im->colorAllocate(255,255,255); my $black = $im->colorAllocate(0,0,0); my $red = $im->colorAllocate(255,0,0); my $blue = $im->colorAllocate(0,0,255); my $brown = $im->colorAllocate(150,127,36); my $grey = $im->colorAllocate(100,100,100); # make the background transparent and interlaced $im->transparent($white); $im->interlaced('true'); for (my $x=0;$x<=300;$x+=15) { for (my $y=0;$y<=300;$y+=15) { #$im->rectangle($x,$y,$x+13,$y+13,$black); $im->arc($x-15,$height/2,$x,$y,0,360,$grey); $im->fill(50,50,$black); } } for (my $x=0;$x<=300;$x+=10) { for (my $y=0;$y<=300;$y+=10) { $im->arc($x+15,$height/2,$y,$x,0,100,$white); $im->fill(30,30,$grey); } } for (my $x=200;$x<=300;$x+=10) { for (my $y=200;$y<=300;$y+=10) { $im->arc($x+10,$height/2,$x,$y,0,150,$white); $im->fill(250,250,$red); } } $im->setStyle($black,$white,gdTransparent,gdTransparent); for (my $x=0;$x<=10;$x+=15) { for (my $y=0;$y<=300;$y+=10) { $im->rectangle($x,$y,$x+13,$y+5,gdStyled); $im->filledRectangle($x,$y,$x+13,$y+5,gdStyled); } } $im->stringUp(gdGiantFont,225,110,"Abstract Art",$white); $im->string(gdGiantFont,240,50,"of",$white); $im->stringUp(gdGiantFont,255,110,"Node Reaper",$white); $im->stringUp(gdGiantFont,270,110,"Cutting a",$white); $im->stringUp(gdGiantFont,285,110,"Cherry Pie!",$white); $im->rectangle(0,0,$width-1,$height-1,$black); binmode STDOUT; print "Content-type: image/png\n\n"; print $im->png;


Andy Summers

Moved to from Meditations to CUFP by planetscape

( keep:1 edit:12 reap:0 )