Colour pinstripe/Display: Difference between revisions

Content deleted Content added
m →‎{{header|Quackery}}: fast graphics
SqrtNegInf (talk | contribs)
m →‎{{header|Perl}}: future-proof for 5.36, tidy code
Line 1,476:
 
=={{header|Perl}}==
<syntaxhighlight lang="perl">#!/usr/bin/perluse -wstrict;
use strict warnings;
use GD ;
 
my %colors = (
my $image = new GD::Image( 320 , 240 ) ;
my"white" %colors => ([255,255,255], "whitered" => [ 255 , 255 0, 255 0] , "redgreen" => [255 , 0,255, 0], "blue" => [ 0, ] 0,255],
"magenta" => [255, 0,255], "greenyellow" => [255,255, 0 0], 255"cyan" , 0=> ][ 0,255,255], "blueblack" => [ 0 0, 0 0, 255 0] , );
 
"magenta" => [ 255 , 0 , 255 ] , "yellow" => [ 255 , 255 , 0 ] ,
my($height, $width) = (240, 320);
"cyan" => [ 0 , 255 , 255 ] , "black" => [ 0 , 0 , 0 ] ) ;
my $image = new GD::Image->new( 320$width , 240$height ) ;
my @paintcolors ;
 
foreach my $color ( keys %colors ) {
my @paintcolors ;
my $paintcolor = $image->colorAllocate( @{$colors{ $color }} ) ;
my $barheight = 240$height / 4 ;
push @paintcolors, $paintcolor ;
my($startx, $starty, $run, $colorindex) = (0) x 4;
 
foreachfor my $color ( sort keys %colors ) {
my $paintcolorpush =@paintcolors, $image->colorAllocate( @{$colors{ $color }} ) ;
}
 
my $startx = 0 ;
my $starty = 0 ;
my $run = 0 ;
my $barheight = 240 / 4 ;
my $colorindex = 0 ;
while ( $run < 4 ) {
my $barwidth = $run + 1 ;
while ( $startx + $barwidth < 320$width ) {
$image->filledRectangle( $startx , $starty , $startx + $barwidth ,
$startx + $barwidth,
$starty + $barheight - 1 , $paintcolors[ $colorindex % 8 ] ) ;
$startxstarty += $barwidthbarheight - ;1,
$paintcolors[ $colorindex++ % 8 ] );
my $startx += 0 $barwidth;
}
$colorindex++;
$starty += $barheight ;
$startx = 0 ;}
$colorindexstarty = 0 += $barheight;
$run++startx = 0;
my $colorindex = 0 ;
}
$run++;
open ( DISPLAY , ">" , "pinstripes.png" ) || die ;
}
binmode DISPLAY ;
 
print DISPLAY $image->png ;
open ( DISPLAY , "'>"' , "'pinstripes.png"' ) ||or die ;
close DISPLAY ;</syntaxhighlight>
binmode DISPLAY ;
print DISPLAY $image->png ;
close DISPLAY ;</syntaxhighlight>
 
=={{header|Phix}}==