style-light-choice
style-dark-choice 
Avatar
Gary
Vollink.com
9 November 2005

GD Lightning Talk

Here, I'll expand the example by adding a rectangle, and filling it with a color.

use GD;

MAIN: {
	my $banner;
	my $white;

	# Create a new image, 400px wide by 66px tall, using truecolor
	$banner = GD::Image->new(400, 66, 1);

	# Allocate colors to use in the image
	$white = $banner->colorAllocate(255,255,255);
    $black = $banner->colorAllocate(0,0,0);
    $blue = $banner->colorAllocate(0,0,255);


	# White Background
	$banner->fill(1,1,$white);

    # Box1
    $banner->rectangle(10,10,50,50, $black);


	# Create result 2...
	open($fh, '>', "bn_2.png");
	print $fh $banner->png();
	close($fh);

    # Fill Box1 with blue
    $banner->fill(11,11, $blue);


	# Create result 3...
	open($fh, '>', "bn_3.png");
	print $fh $banner->png();
	close($fh);
}

Result 2:
banner size rectangle, black bordered square is on the left.

Result 3:
banner size rectangle, black bordered square with blue fill is on the left.

Valid CSS!