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 )


In reply to Salute to cherry pies by bladx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.