Colour bars/Display: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 128: | Line 128: | ||
use GD ; |
use GD ; |
||
my %colors = ( |
my %colors = ( white => [ 255 , 255 , 255 ] , red => [255 , 0 , 0 ] , |
||
green => [ 0 , 255 , 0 ] , blue => [ 0 , 0 , 255 ] , |
|||
magenta => [ 255 , 0 , 255 ] , yellow => [ 255 , 255 , 0 ] , |
|||
cyan => [ 0 , 255 , 255 ] , black => [ 0 , 0 , 0 ] ) ; |
|||
my $barwidth = 160 / 8 ; |
my $barwidth = 160 / 8 ; |
||
my $image = new GD::Image( 160 , 100 ) ; |
my $image = new GD::Image( 160 , 100 ) ; |
||
my $start = 0 ; |
my $start = 0 ; |
||
foreach my $ |
foreach my $rgb ( values %colors ) { |
||
my $paintcolor = $image->colorAllocate( @ |
my $paintcolor = $image->colorAllocate( @$rgb ) ; |
||
$image->filledRectangle( $start * $barwidth , 0 , $start * $barwidth + |
$image->filledRectangle( $start * $barwidth , 0 , $start * $barwidth + |
||
$barwidth - 1 , 99 , $paintcolor ) ; |
$barwidth - 1 , 99 , $paintcolor ) ; |