Colour pinstripe/Display: Difference between revisions

Improve Uxntal version with suggestions from #uxn IRC channel
(Added Quackery.)
(Improve Uxntal version with suggestions from #uxn IRC channel)
 
(10 intermediate revisions by 8 users not shown)
Line 454:
ExitApp</syntaxhighlight>
 
=={{header|BASIC256BASIC}}==
==={{header|BASIC256}}===
{{trans|Yabasic}}
<syntaxhighlight lang="basic256">w = 640 : h = 480
Line 473 ⟶ 474:
next i</syntaxhighlight>
 
==={{header|BBC BASIC}}===
{{works with|BBC BASIC for Windows}}
<syntaxhighlight lang="bbcbasic"> SW_MAXIMIZE = 3
Line 710 ⟶ 711:
(make-position xpos top)
(make-position xpos bottom)))))))</syntaxhighlight>
 
=={{header|Delphi}}==
{{works with|Delphi|6.0}}
{{libheader|SysUtils,StdCtrls}}
[[File:DelphiColorStripes.png|frame|none]]
 
<syntaxhighlight lang="Delphi">
procedure DrawColorStripes(Image: TImage; Colors: array of TColor; PenWidth,Top,Bottom: integer);
{Draw vertical stripes across full width of image}
{Top/Bottom Control the position of the band of stripes}
{PenWidth controls width of the line drawn}
var X,X2,Y: integer;
begin
Image.Canvas.Pen.Width:=PenWidth;
for X:=0 to (Image.Width div PenWidth)-1 do
begin
Image.Canvas.Pen.Color:=Colors[X mod Length(Colors)];
X2:=X * PenWidth;
Image.Canvas.MoveTo(X2,Top);
Image.Canvas.LineTo(X2,Bottom);
end;
end;
 
 
var Colors: array [0..7] of TColor = (clBlack, clRed, clGreen, clBlue, clFuchsia, clAqua, clYellow, clWhite);
 
procedure ShowColorStripes(Image: TImage);
{Draw all four bands of stripes}
var SHeight: integer;
var I: integer;
begin
SHeight:=Image.Height div 4;
for I:=0 to 4-1 do
begin
DrawColorStripes(Image,Colors,I+1,SHeight*I,SHeight*(I+1));
end;
end;
 
 
</syntaxhighlight>
{{out}}
<pre>
Elapsed Time: 20.167 ms.
 
</pre>
 
=={{header|EasyLang}}==
[https://easylang.dev/show/#cod=PU3LCoMwELznK+bYB5VNsdA99EtCThpBtKTYIPr3ncXQwzKPndmdQsQLASIC5YhyRMmVnEitxOiGvGBk1qNktA5Al2fTRncjrN8YueD+MM8KG33Bt6QPF+zVjK2PA8xMgRir9c5rYmuvckldYfM4+H95MrjCnxnvPZ62bFzjfg== Run it]
<syntaxhighlight>
k[] = [ 000 900 090 009 909 099 990 999 ]
for i = 1 to 4
col = 1
y = 100 - i * 25
for x = 0 step i to 100 - i
color k[col]
move x y
rect i 25
col = (col + 1) mod1 8
.
.
</syntaxhighlight>
 
=={{header|Factor}}==
Line 1,476 ⟶ 1,538:
 
=={{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 = GD::Image->new( $width , $height );
my @paintcolors ;
 
foreach my $color ( keys %colors ) {
my @paintcolors;
my $paintcolor = $image->colorAllocate( @{$colors{ $color }} ) ;
my $barheight = $height / 4;
push @paintcolors, $paintcolor ;
my($startx, $starty, $run, $colorindex) = (0) x 4;
 
for my $color ( sort keys %colors ) {
push @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 ] );
$startx += $barwidth;
}
$colorindex++;
$starty += $barheight ;
$startx = 0 ;}
$colorindexstarty = 0 += $barheight;
$run++startx = 0;
$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}}==
Line 1,819 ⟶ 1,884:
 
[ turtle
50 frames
width n->v 2 1 v/ fly
-1 4 turn
height n->v 2 1 v/ fly
-1 4 turn
4 times
[ i^ 1+ colours
width times stripe
Line 1,831 ⟶ 1,897:
height n->v
4 n->v v/ fly
1 4 turn ] ] is pinstripes ( --> )</syntaxhighlight>
1 frames ] is pinstripes ( --> )
</syntaxhighlight>
 
{{out}}
Line 2,111 ⟶ 2,179:
NEXT i
END</syntaxhighlight>
 
=={{header|Uxntal}}==
<syntaxhighlight lang="uxntal">( uxnasm color-pinstripe.tal color-pinstripe.rom && uxnemu color-pinstripe.rom )
 
|00 @System &vector $2 &expansion $2 &wst $1 &rst $1 &metadata $2 &r $2 &g $2 &b $2 &debug $1 &state $1
|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1
 
|0100
( set theme )
#0f00 .System/r DEO2
#00f0 .System/g DEO2
#000f .System/b DEO2
 
( store screen width )
.Screen/width DEI2 ,draw-layer/width STR2
( store a quarter of the screen height )
.Screen/height DEI2 #02 SFT2 ,&quarter-height STR2
 
( draw the four stripe layers )
#00
&loop ( -- )
( update y coordinate )
#00 OVR [ LIT2 &quarter-height $2 ] MUL2 .Screen/y DEO2
( draw a layer )
INCk draw-layer
( do it four times )
INC DUP #04 LTH ?&loop
POP BRK
 
@draw-layer ( step -: )
( extend step to short, create counter )
#00 SWP #0000
&loop ( -- )
( update x coordinate )
MUL2k .Screen/x DEO2
( fill a region )
DUP #03 AND #80 ORA .Screen/pixel DEO
( loop until the end of the screen )
INC2 MUL2k [ LIT2 &width $2 ] LTH2 ?&loop
POP2 POP2 JMP2r</syntaxhighlight>
[[File:Colour pinstripe-Display in Uxntal.png|thumb|none|alt=Uxntal implementation of Colour pinstripe/display in an emulator.|Running in an emulator.]]
 
=={{header|Visual Basic .NET}}==
Line 2,136 ⟶ 2,245:
{{trans|Go}}
{{libheader|DOME}}
<syntaxhighlight lang="ecmascriptwren">import "graphics" for Canvas, Color
import "dome" for Window
 
57

edits