All pastes #1420790 Raw Edit

Untitled

public text v1 · immutable
#1420790 ·published 2009-05-12 19:12 UTC
rendered paste body
#!/usr/bin/perl -w
use GD;

# create a new image

my $im = GD::Image->newTrueColor(128,128);

# allocate some colors
$white = $im->colorAllocateAlpha(255,255,255,127);
$black = $im->colorAllocateAlpha(0,0,0,127);       
$red = $im->colorAllocateAlpha(255,0,0,127);      
$blue = $im->colorAllocateAlpha(0,0,255,127);

# make the background transparent and interlaced
$im->transparent($white);
$im->interlaced(undef);

# Put a black frame around the picture
$im->rectangle(0,0,99,99,$black);

# Draw a blue oval
$im->arc(50,50,95,75,0,360,$blue);

# And fill it with red
$im->fill(50,50,$red);

# make sure we are writing to a binary stream
binmode STDOUT;

# Convert the image to PNG and print it on standard output
print $im->png;