Colour bars/Display: Difference between revisions
Content added Content deleted
SqrtNegInf (talk | contribs) m (→{{header|Perl}}: future-proof for 5.36, tidy code) |
|||
Line 1,486: | Line 1,486: | ||
=={{header|Perl}}== |
=={{header|Perl}}== |
||
<syntaxhighlight lang="perl"> |
<syntaxhighlight lang="perl">use strict; |
||
use |
use warnings; |
||
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]); |
|||
cyan => [ 0 , 255 , 255 ] , black => [ 0 , 0 , 0 ] ) ; |
|||
my $ |
my $start = 0; |
||
my $ |
my $barwidth = 160 / 8; |
||
my $ |
my $image = GD::Image->new( 160 , 100 ); |
||
for my $rgb ( values %colors ) { |
|||
my $paintcolor = $image->colorAllocate( @$rgb ) ; |
|||
$image->filledRectangle( $start * $barwidth , 0 , $start * $barwidth + |
$image->filledRectangle( $start * $barwidth , 0 , $start * $barwidth + |
||
$barwidth - 1 , 99 , $ |
$barwidth - 1 , 99 , $image->colorAllocate( @$rgb ) ); |
||
$start++ ; |
$start++ ; |
||
} |
} |
||
open ( DISPLAY , ">" , " |
open ( DISPLAY , ">" , "bars.png" ) or die; |
||
binmode DISPLAY |
binmode DISPLAY; |
||
print DISPLAY $image->png |
print DISPLAY $image->png; |
||
close DISPLAY |
close DISPLAY;</syntaxhighlight> |
||
=={{header|Phix}}== |
=={{header|Phix}}== |