Colour bars/Display: Difference between revisions

m
→‎{{header|Perl}}: future-proof for 5.36, tidy code
m (→‎{{header|Perl}}: future-proof for 5.36, tidy code)
Line 1,486:
 
=={{header|Perl}}==
<syntaxhighlight lang="perl">#!/usr/bin/perluse -wstrict;
use strict warnings;
use GD ;
 
my %colors = ( white => [ 255 , 255 , 255 ] , red => [255 , 0 , 0 ] ,
white => [255,255,255], red green => [255, 0 0, 255 0], green => [ 0,255, ] 0], blue => [ 0 0, 0 , 255 ] ,
magenta => [255, 0,255], magentayellow => [ 255 ,255, 0 0], 255cyan ] => [ 0,255,255], yellowblack => [ 255 0, 255 0, 0 ] ,);
 
cyan => [ 0 , 255 , 255 ] , black => [ 0 , 0 , 0 ] ) ;
my $barwidthstart = 160 / 8= 0;
my $imagebarwidth = new GD::Image( 160 , 100 )/ 8;
my $startimage = 0GD::Image->new( 160 , 100 );
 
foreachfor my $rgb ( values %colors ) {
my $paintcolor = $image->colorAllocate( @$rgb ) ;
$image->filledRectangle( $start * $barwidth , 0 , $start * $barwidth +
$barwidth - 1 , 99 , $paintcolorimage->colorAllocate( @$rgb ) );
$start++ ;
}
open ( DISPLAY , ">" , "testprogrambars.png" ) ||or die ;
binmode DISPLAY ;
print DISPLAY $image->png ;
close DISPLAY ;#to be watched with <image viewer> testprogram.png</syntaxhighlight>
 
=={{header|Phix}}==
2,392

edits