Colour pinstripe/Display: Difference between revisions

Improve Uxntal version with suggestions from #uxn IRC channel
(Improve Uxntal version with suggestions from #uxn IRC channel)
 
(45 intermediate revisions by 22 users not shown)
Line 1:
{{task|Test card}}
 
The task is to create 1 pixel wide coloured vertical pinstripes with a sufficient number of pinstripes to span the entire width of the graphics display. The pinstripes should either follow the system palette sequence or a sequence that includes Black, Red, Green, Blue, Magenta, Cyan, Yellow, White.
 
After filling the top quarter of the display, we switch to a wider 2 pixel wide vertical pinstripe pattern. Halfway down the display we switch to 3 pixel wide vertical pinstripe and then finally to a 4 pixels wide vertical pinstripe for the last quarter of the display.
 
The pinstripes should either follow the system palette sequence,   or a sequence that includes:
c.f. [[Pinstripe/Display]]
<br>black, &nbsp; red, &nbsp; green, &nbsp; blue, &nbsp; magenta, &nbsp; cyan, &nbsp; yellow, &nbsp; and &nbsp; white:
::* &nbsp; after filling the top quarter, switch to a wider 2 pixel wide vertical pinstripe pattern,
::* &nbsp; halfway down the display, switch to 3 pixel wide vertical pinstripe,
::* &nbsp; finally to a 4 pixels wide vertical pinstripe for the last quarter of the display.
 
 
;See also:
* &nbsp; [[Pinstripe/Display|display black and white ]]
* &nbsp; [[Colour pinstripe/Printer|print colour]]
<br><br>
=={{header|6502 Assembly}}==
{{works with|https://skilldrick.github.io/easy6502/ Easy6502}}
Output can be seen by copying and pasting this code into the code editor, then clicking "Assemble," then "Run."
<syntaxhighlight lang="6502asm">define color $00
define looptemp $01
 
loop_1wide:
lda color
sta $0200,x
inc color
inx
bne loop_1wide
 
loop_2wide:
lda color
sta $0300,x
inx
sta $0300,x
inc color
inx
bne loop_2wide
 
lda #0
tax
tay
sta color
sta looptemp ;reset ram
 
loop_3wide:
lda color
sta $0400,x
inc looptemp
inx
 
sta $0400,x
inc looptemp
inx
 
sta $0400,x
inc looptemp
inc color
inx
 
lda looptemp
cmp #$1e
bne loop_3wide
 
lda color ;loop overhead
sta $0400,x ;can't fit all of this stripe.
;two columns will have to do.
inx
lda color
sta $0400,x
inx
 
lda #0
sta color
sta looptemp ;reset color and looptemp
iny
cpy #$08 ;check secondary loop counter
bne loop_3wide
 
lda #0
tax
tay
sta color
sta looptemp ;reset ram
 
loop_4wide:
lda color
sta $0500,x
inx
inc looptemp
 
sta $0500,x
inx
inc looptemp
 
sta $0500,x
inx
inc looptemp
 
sta $0500,x
inc color
inc looptemp
inx
 
lda looptemp
cmp #$20
bne loop_4wide
lda #0
sta looptemp
sta color
 
iny
cpy #$8
bcc loop_4wide
 
brk ;program end</syntaxhighlight>
 
=={{header|Action!}}==
<syntaxhighlight lang="action!">PROC Main()
BYTE
i,
CH=$02FC, ;Internal hardware value for last key pressed
PALNTSC=$D014, ;To check if PAL or NTSC system is used
PCOLR0=$02C0,PCOLR1=$02C1,
PCOLR2=$02C2,PCOLR3=$02C3,
COLOR0=$02C4,COLOR1=$02C5,
COLOR2=$02C6,COLOR3=$02C7,
COLOR4=$02C8
Graphics(10)
PCOLR0=$04 ;gray
PCOLR1=$00 ;black
IF PALNTSC=15 THEN
PCOLR2=$42 ;red for NTSC
PCOLR3=$C6 ;green for NTSC
COLOR0=$84 ;blue for NTSC
COLOR1=$66 ;magenta for NTSC
COLOR2=$A6 ;cyan for NTSC
COLOR3=$FC ;yellow for NTSC
ELSE
PCOLR2=$22 ;red for PAL
PCOLR3=$B6 ;green for PAL
COLOR0=$74 ;blue for PAL
COLOR1=$48 ;magenta for PAL
COLOR2=$96 ;cyan for PAL
COLOR3=$EC ;yellow for PAL
FI
COLOR4=$0F ;white
 
FOR i=0 TO 79
DO
Color=i MOD 8+1
Plot(i,0) DrawTo(i,47)
 
Color=i/2 MOD 8+1
Plot(i,48) DrawTo(i,95)
 
Color=i/3 MOD 8+1
Plot(i,96) DrawTo(i,143)
 
Color=i/4 MOD 8+1
Plot(i,144) DrawTo(i,191)
OD
 
DO UNTIL CH#$FF OD
CH=$FF
RETURN</syntaxhighlight>
{{out}}
[https://gitlab.com/amarok8bit/action-rosetta-code/-/raw/master/images/Colour_pinstripe_display.png Screenshot from Atari 8-bit computer]
 
=={{header|ActionScript}}==
<syntaxhighlight lang="actionscript3">
<lang ActionScript3>
package {
Line 64 ⟶ 225:
 
}
</syntaxhighlight>
</lang>
 
=={{header|Ada}}==
{{libheader|SDLAda}}
<syntaxhighlight lang="ada">with SDL.Video.Windows.Makers;
with SDL.Video.Renderers.Makers;
with SDL.Video.Palettes;
with SDL.Events.Events;
 
procedure Colour_Pinstripe_Display is
 
Width : constant := 1_200;
Height : constant := 800;
 
Window : SDL.Video.Windows.Window;
Renderer : SDL.Video.Renderers.Renderer;
Event : SDL.Events.Events.Events;
 
procedure Draw_Pinstripe (Line_Width : in Integer;
Line_Height : in Integer;
Screen_Width : in Integer;
Y : in Integer)
is
type Colour_Range is (Black, Red, Green, Blue, Magenta, Cyan, Yellow, White);
Colours : constant array (Colour_Range) of SDL.Video.Palettes.Colour
:= (Black => (0, 0, 0, 255), Red => (255, 0, 0, 255),
Green => (0, 255, 0, 255), Blue => (0, 0, 255, 255),
Magenta => (255, 0, 255, 255), Cyan => (0, 255, 255, 255),
Yellow => (255, 255, 0, 255), White => (255, 255, 255, 255));
Col : Colour_Range := Colour_Range'First;
Count : constant Integer := Screen_Width / Line_Width;
begin
for A in 0 .. Count loop
Renderer.Set_Draw_Colour (Colour => Colours (Col));
Renderer.Fill (Rectangle => (X => SDL.C.int (A * Line_Width), Y => SDL.C.int (Y),
Width => SDL.C.int (Line_Width),
Height => SDL.C.int (Line_Height)));
Col := (if Col = Colour_Range'Last
then Colour_Range'First
else Colour_Range'Succ (Col));
end loop;
end Draw_Pinstripe;
 
procedure Wait is
use type SDL.Events.Event_Types;
begin
loop
while SDL.Events.Events.Poll (Event) loop
if Event.Common.Event_Type = SDL.Events.Quit then
return;
end if;
end loop;
delay 0.100;
end loop;
end Wait;
 
begin
if not SDL.Initialise (Flags => SDL.Enable_Screen) then
return;
end if;
 
SDL.Video.Windows.Makers.Create (Win => Window,
Title => "Pinstripe",
Position => SDL.Natural_Coordinates'(X => 10, Y => 10),
Size => SDL.Positive_Sizes'(Width, Height),
Flags => 0);
SDL.Video.Renderers.Makers.Create (Renderer, Window.Get_Surface);
 
Draw_Pinstripe (1, Height / 4, Width, 0);
Draw_Pinstripe (2, Height / 4, Width, 200);
Draw_Pinstripe (3, Height / 4, Width, 400);
Draw_Pinstripe (4, Height / 4, Width, 600);
Window.Update_Surface;
 
Wait;
Window.Finalize;
SDL.Finalise;
end Colour_Pinstripe_Display;</syntaxhighlight>
 
=={{header|ARM Assembly}}==
{{works with|https://akkit.org/info/gbatek.htm Game Boy Advance}}
 
Assembled using VASM (which explains why the syntax is different from how you might expect if you're used to the GNU Assembler)
This uses the Game Boy Advance's bitmap screen modes; no pre-defined tilemaps are needed.
 
<syntaxhighlight lang="arm assembly"> .org 0x08000000 ;cartridge ROM begins here
 
b ProgramStart ;branch around the cartridge header
 
;;;; cartridge header goes here
 
.equ SCREEN_WIDTH,240 ;some labels for convenience
.equ SCREEN_HEIGHT,160
 
ProgramStart:
mov sp,#0x03000000 ;set up stack pointer (we won't be using it but it's a good practice to do so anyway
mov r4,#0x04000000 ;DISPCNT (LCD Control Register)
mov r2,#0x403 ;4= Layer 2 on / 3= ScreenMode 3 (Bitmap Graphics, vram at 0x06000000)
str r2,[r4] ;now the screen is visible.
mov r0,#0x06000000 ;VRAM BASE (2 BYTES PER PIXEL)
mov r1,#0 ;COLOR TO STORE (INIT TO ZERO, WILL GET FILLED IN LATER)
 
adr r4,palArray ;get address of palette
mov r5,#0 ;index into palArray
mov r6,#19200 ;this is one quarter of the screen
add r7,r0,r6 ;MOV R7, #0x06004B00
add r8,r7,r6 ;MOV R8, #0x06009600
add r9,r8,r6 ;MOV R9, #0x0600E100
add r10,r9,r6 ;MOV R10,#0x06012C00
loop_pinstripe_firstQuarter:
ldrH r1,[r4,r5]
strH r1,[r0],#2 ;store into video memory and post-inc by 2.
add r5,r5,#2 ;next color in palette
and r5,r5,#0x0F ;prevents indexing out of bounds
cmp r0,r7 ;have we reached the end of this quarter of the screen?
blt loop_pinstripe_firstQuarter ;if not, keep drawing
loop_pinstripe_secondQuarter:
ldrH r1,[r4,r5]
strH r1,[r0],#2 ;post-inc by 2 after the store
strH r1,[r0],#2 ;post-inc by 2 after the store
add r5,r5,#2
and r5,r5,#0x0F
cmp r0,r8
blt loop_pinstripe_secondQuarter
loop_pinstripe_thirdQuarter:
ldrH r1,[r4,r5]
strH r1,[r0],#2 ;post-inc by 2 after the store
strH r1,[r0],#2
strH r1,[r0],#2
add r5,r5,#2
and r5,r5,#0x0F
cmp r0,r9
blt loop_pinstripe_thirdQuarter
; the last quarter works differently. We'll need to use a different
; loop counter to get the last pinstripe
mov r2,#SCREEN_WIDTH/4 ;inner loop counter
mov r3,#48 ;outer loop counter
loop_pinstripe_lastQuarter:
ldrH r1,[r4,r5]
strH r1,[r0],#2
strH r1,[r0],#2
strH r1,[r0],#2
strH r1,[r0],#2
add r5,r5,#2
and r5,r5,#0x0F
subs r2,r2,#1
bne loop_pinstripe_lastQuarter
mov r5,#0 ;reset the palette pointer
mov r2,#SCREEN_WIDTH/4 ;reset the inner loop counter
subs r3,r3,#1 ;decrement the outer loop counter
bne loop_pinstripe_lastQuarter ;if we're not done, keep going
 
forever:
b forever ;end of program
palArray: ;GAME BOY ADVANCE USES 15-BIT COLOR. WE WON'T USE THE TOP BIT.
 
.word 0x0000 ;black
.word 0b0000000000011111 ;red
.word 0b0000001111100000 ;green
.word 0b0111110000000000 ;blue
.word 0b0111110000011111 ;magenta
.word 0b0111111111100000 ;cyan
.word 0b0000001111111111 ;yellow
.word 0x7FFF ;white</syntaxhighlight>
 
{{out}}
[https://ibb.co/cNCXgMq Picture of output (I can't get Rosetta Code's file uploading to work)]
 
 
=={{header|AutoHotkey}}==
Line 71 ⟶ 410:
Requires the GDI+ standard library: http://www.autohotkey.com/forum/viewtopic.php?t=32238<br/>
It is worth noting that this fills the whole screen; press Esc to exit.
<langsyntaxhighlight AHKlang="ahk">h := A_ScreenHeight
w := A_ScreenWidth
pToken := gdip_Startup()
Line 113 ⟶ 452:
Exit:
Gdip_Shutdown(pToken)
ExitApp</langsyntaxhighlight>
 
=={{header|BASIC}}==
==={{header|BASIC256}}===
{{trans|Yabasic}}
<syntaxhighlight lang="basic256">w = 640 : h = 480
graphsize w, h
 
dim k = {black, red, green, blue, purple, cyan, yellow, white}
h /= 4
 
for i = 1 to 4
col = 0
y = (i-1) * h
for x = 1 to w step i
if col mod 8 = 0 then col = 0
colour k[col]
rect (x, y, x + i, y + h)
col += 1
next x
next i</syntaxhighlight>
 
==={{header|BBC BASIC}}===
{{works with|BBC BASIC for Windows}}
<langsyntaxhighlight lang="bbcbasic"> SW_MAXIMIZE = 3
SYS "ShowWindow", @hwnd%, SW_MAXIMIZE
VDU 26
Line 141 ⟶ 500:
NEXT
NEXT P%
</syntaxhighlight>
</lang>
 
=={{header|Befunge}}==
Line 149 ⟶ 508:
The dimensions of the image are specified by the first two values on the stack: 1366 (<tt>"%":*3-</tt>) by 768 (<tt>"`"8*</tt>).
 
<langsyntaxhighlight lang="befunge">"%":*3-"`"8*>4/::8%00p8/10p4*\55+"3P",,,:.\.5v
5+:,1vv\%2:%8/-g025:\-1_$$55+,\:v1+*8g01g00_@>
024,.<>2/:2%\2/...1+\:>^<:\0:\-1_$20g1-:20p^1p</langsyntaxhighlight>
 
=={{header|C}}==
Line 157 ⟶ 516:
The following code uses the BGI graphics library of Borland's Turbo C.
 
<syntaxhighlight lang="c">
<lang C>
#include<graphics.h>
#include<conio.h>
Line 186 ⟶ 545:
return 0;
}
</syntaxhighlight>
</lang>
 
=={{header|C++}}==
[[File:clr_pinstripe_cpp.png|300px]]
<langsyntaxhighlight lang="cpp">
#include <windows.h>
 
Line 311 ⟶ 670:
}
//--------------------------------------------------------------------------------------------------
</syntaxhighlight>
</lang>
 
=={{header|Common Lisp}}==
Line 317 ⟶ 676:
which causes the line caps to make the edges between regions to be a bit ragged. I mention
a couple of alternatives there which I'm too lazy to implement right now.
<langsyntaxhighlight lang="lisp">(in-package :cg-user)
 
;;; We only need a bitmap pane - nothing fancy
Line 351 ⟶ 710:
(draw-line win
(make-position xpos top)
(make-position xpos bottom)))))))</langsyntaxhighlight>
 
=={{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}}==
<syntaxhighlight lang="factor">USING: accessors arrays colors.constants kernel locals math
math.ranges opengl sequences ui ui.gadgets ui.render ;
 
CONSTANT: palette
{
COLOR: black
COLOR: red
COLOR: green
COLOR: blue
COLOR: magenta
COLOR: cyan
COLOR: yellow
COLOR: white
}
 
CONSTANT: bands 4
 
TUPLE: pinstripe < gadget ;
 
: <pinstripe> ( -- pinstripe ) pinstripe new ;
 
M: pinstripe pref-dim* drop { 400 400 } ;
 
: set-color ( n -- ) palette length mod palette nth gl-color ;
 
:: draw-pinstripe ( pinstripe n -- )
pinstripe dim>> first2 :> ( w h )
h 4 /i :> quarter
quarter n * :> y2
y2 quarter - :> y1
0 w n <range> [| x |
x n / set-color x y1 2array x n + y2 2array gl-fill-rect
] each ;
 
M: pinstripe draw-gadget*
bands [1,b] [ draw-pinstripe ] with each ;
 
<pinstripe> "Color pinstripe" open-window</syntaxhighlight>
 
=={{header|FreeBASIC}}==
<langsyntaxhighlight lang="freebasic">' version 14-03-2017
' compile with: fbc -s console
' or compile with: fbc -s gui
Line 378 ⟶ 839:
'Print : Print "hit any key to end program"
Sleep
End</langsyntaxhighlight>
 
=={{header|FutureBasic}}==
<syntaxhighlight lang="futurebasic">
 
void local fn DoIt
long c = 0, x, y, w = 1
CFArrayRef colors = @[fn ColorBlack,fn ColorRed,
fn ColorGreen,fn ColorBlue,fn ColorMagenta,
fn ColorCyan,fn ColorYellow,fn ColorWhite]
window 1,, (0,0,384,240), NSWindowStyleMaskBorderless
pen -1
for y = 0 to 180 step 60
for x = 0 to 384 - w step w
rect fill (x,y,w,60), colors[c]
c++
if ( c >= len(colors) ) then c = 0
next
w++
next
end fn
 
fn DoIt
 
HandleEvents
</syntaxhighlight>
 
[[File:ColorPinstripeDisplayFB.png]]
 
=={{header|Gambas}}==
<langsyntaxhighlight lang="gambas">'WARNING this takes a time to display
 
Public Sub Form_Open()
Line 407 ⟶ 899:
 
End
</syntaxhighlight>
</lang>
'''[http://www.cogier.com/gambas/colour_pinstripe.png Click to see output image]'''
 
Line 413 ⟶ 905:
{{libheader|Go Graphics}}
{{trans|Java}}
<langsyntaxhighlight lang="go">package main
 
import "github.com/fogleman/gg"
Line 445 ⟶ 937:
pinstripe(dc)
dc.SavePNG("color_pinstripe.png")
}</langsyntaxhighlight>
 
{{out}}
Line 455 ⟶ 947:
This is a modified version of the [[Pinstripe/Display]] solution. A shrunken screenshot is included.
 
<langsyntaxhighlight Iconlang="icon">link graphics,numbers,printf
procedure main() # pinstripe
Line 484 ⟶ 976:
}
WDone()
end</langsyntaxhighlight>
 
[[File:Pinstripe_Colour_unicon.jpeg]]
Line 494 ⟶ 986:
 
=={{header|J}}==
<langsyntaxhighlight lang="j"> load 'viewmat'
size=. 2{.".wd'qm' NB. J6
size=. getscreenwh_jgtk_ '' NB. J7
'rgb'viewmat (4<.@%~{:size)# ({.size) $&> 1 2 3 4#&.> <256#.255*#:i.8</langsyntaxhighlight>
 
 
=={{header|Java}}==
{{works with|Java|8}}
<langsyntaxhighlight lang="java">import java.awt.*;
import static java.awt.Color.*;
import javax.swing.*;
Line 539 ⟶ 1,030:
});
}
}</langsyntaxhighlight>
 
=={{header|Julia}}==
<langsyntaxhighlight lang="julia">using Gtk, Graphics, Colors
 
function drawline(ctx, p1, p2, color, width)
Line 583 ⟶ 1,074:
signal_connect(endit, win, :destroy)
wait(cond)
</syntaxhighlight>
</lang>
 
=={{header|Kotlin}}==
{{trans|Java}}
<langsyntaxhighlight lang="scala">// version 1.1.0
 
import java.awt.*
Line 628 ⟶ 1,119:
f.isVisible = true
}
}</langsyntaxhighlight>
 
=={{header|Lua}}==
{{libheader|nw}}
{{libheader|cairo}}
<syntaxhighlight lang="lua">local nw = require("nw")
local app = nw:app()
local cw, ch = 320, 240
local win = app:window(cw, ch, "Color Pinstripe", false)
local colors = {{0,0,0}, {1,0,0}, {0,1,0}, {0,0,1}, {1,0,1}, {0,1,1}, {1,1,0}, {1,1,1}}
local unpack = unpack or table.unpack -- polyfill 5.2 vs 5.3
function win:repaint()
local cr = win:bitmap():cairo()
local ystride = ch/4
for y = 0, ch-1, ystride do
local i, xstride = 1, y/ystride+1
for x = 0, cw-1, xstride do
cr:rectangle(x, y, xstride, ystride)
cr:rgb(unpack(colors[i]))
cr:fill()
i = (i % #colors) + 1
end
end
end
win:show()
app:run()</syntaxhighlight>
 
=={{header|M2000 Interpreter}}==
Module names and variables with same name may exist
Line 635 ⟶ 1,152:
Sprite layers have a priority number, so 32 is the top one. We can change priorities sending back any sprite.
 
Version 2
We change console width and height and put in the center of screen
We use a thread to move the layer above console (and inside console form), when we push any mouse button (only in console window). Program ends when we close the modal opened window.
 
<syntaxhighlight lang="m2000 interpreter">
<lang M2000 Interpreter>
Module PinstripeCheckit {
SmoothWindow off16, ' use of GDI3214000,12000;
DimModule colors(0Pinstripe to 7){
Smooth off ' use of GDI32
Colors(0)=#000000,#FF0000, #00FF00, #0000FF, #FF00FF, #00FFFF, #FFFF00, #FFFFFF
Dim colors(0 to 7)
pixelsX=scale.x/twipsX
Colors(0)=#000000,#FF0000, #00FF00, #0000FF, #FF00FF, #00FFFF, #FFFF00, #FFFFFF
pixelsY=scale.y/twipsY
zoneheight pixelsX=scale.yx/4twipsX
n pixelsY=0scale.y/twipsY
zoneheight=scale.y/4
Refresh 5000
For i=1 to 4 { n=0
moveRefresh 0, (i-1)*zoneheight5000
pinw=For i*twipsx=1 to 4 {
For j=1 to pixelsX/i { move 0, (i-1)*zoneheight
Fill pinw, zoneheight, color(n)=i*twipsx
StepFor j=1 0,to -zoneheightpixelsX/i {
n++:if n=8 then Fill pinw, zoneheight, color(n=0)
Step 0, -zoneheight
n++:if n=8 then n=0
}
}
\\ now we make the refersh
Refresh 100
}
\\ nowdraw weto makeconsole the refershwindow
\\ now we make a window and draw there
Refresh 100
}
\\ draw to console window
\\ now we make a window and draw there
Pinstripe
Layer 32 {
Window 12, 10000,10000
Pinstripe
MotionLayer 2000,200032 {
Window 12, 10000,10000
Show
Pinstripe
Show
}
Declare Pinstripe Form
Layer Pinstripe {
Window 12, 10000,10000
Pinstripe
motion 2000, 2000
}
refresh 20
Thread {
if control$="MAIN" then if mouse then player 32, mousea.x, mousea.y
} as anyvar interval 100
Method Pinstripe, "Show", 1
Threads Erase
Layer 32 {Hide}
Cls
}
Checkit
Declare Pinstripe Form
 
Layer Pinstripe {
</syntaxhighlight>
Window 12, 10000,10000
Pinstripe
}
Method Pinstripe, "Show", 1
Layer 32 {Hide}
</lang>
 
=={{header|Maple}}==
<syntaxhighlight lang="maple">
<lang Maple>
colors := [yellow, black, red, green, magenta, cyan, white]:
plots:-display( [
Line 683 ⟶ 1,215:
seq( plot([1+i/10,y,y=4..5], color=colors[i mod 7 + 1],thickness=2), i = 1..500),seq( plot([1+i/10,y,y=3..4], color=colors[i mod 7 + 1],thickness=3), i = 1..500),seq( plot([1+i/10,y,y=2..3], color=colors[i mod 7 + 1],thickness=4,size=[interface(screenwidth)*20,interface(screenheight)*32]), i = 1..500)],
axes=none);
</syntaxhighlight>
</lang>
 
=={{header|Mathematica}} / {{header|Wolfram Language}}==
<langsyntaxhighlight Mathematicalang="mathematica">color[y_] := {Black, Red, Green, Blue, Magenta, Cyan, Yellow,
White}[[Mod[y, 8] + 1]];
Graphics[Join[{Thickness[1/408]},
Line 696 ⟶ 1,228:
Range[136]], {Thickness[1/102]},
Flatten[{color[#], Line[{{4 # - 2, 102}, {4 # - 2, 1}}]} & /@
Range[102]]], ImageSize -> {408, 408}]</langsyntaxhighlight>
{{out}}
See [https://www.dropbox.com/s/tg4zk4jkddkok8w/Mathematica_Pinstripes_Colored.png?dl=0 here].
 
=={{header|OCamlMIPS Assembly}}==
This isn't perfect, as the edges are cut off due to overscan. But this is as close as I could get:
<syntaxhighlight lang="mips">.include "\SrcAll\Header.asm"
.include "\SrcAll\BasicMacros.asm"
.include "\SrcALL\AdvancedMacros.asm"
.include "\SrcALL\MemoryMap.asm"
 
.definelabel VRAMBASE,0xA0100008 ;the extra 8 accounts for overscan
<lang ocaml>open Graphics
.definelabel VRAMSIZE,0x12C00 ;320x240(decimal)
 
;;;;;;;;;;;;;;;;;;;;;;;;;
let () =
open_graph "";
let width = size_x ()
and height = size_y () in
let colors = [| black; red; green; blue; magenta; cyan; yellow; white |] in
let num_colors = Array.length colors in
let h = height / 4 in
for i = 1 to 4 do
let j = 4 - i in
for x = 0 to pred width do
set_color colors.((x / i) mod num_colors);
moveto x (j * h); lineto x (j * h + h);
done
done;
ignore(read_key())</lang>
 
main:
run with:
la $a0,VRAMBASE
<pre>$ ocaml graphics.cma pinstripe.ml</pre>
la $a1,colors
li $t1,0x4B00/8
 
LOOP1:
=={{header|Perl}}==
lh $t0,($a1)
<lang Perl>#!/usr/bin/perl -w
sh $t0,($a0)
use strict ;
use GD ;
 
lh $t0,2($a1)
my $image = new GD::Image( 320 , 240 ) ;
sh $t0,2($a0)
my %colors = ( "white" => [ 255 , 255 , 255 ] , "red" => [255 , 0 , 0 ] ,
"green" => [ 0 , 255 , 0 ] , "blue" => [ 0 , 0 , 255 ] ,
lh $t0,4($a1)
"magenta" => [ 255 , 0 , 255 ] , "yellow" => [ 255 , 255 , 0 ] ,
sh $t0,4($a0)
"cyan" => [ 0 , 255 , 255 ] , "black" => [ 0 , 0 , 0 ] ) ;
my @paintcolors ;
lh $t0,6($a1)
foreach my $color ( keys %colors ) {
sh $t0,6($a0)
my $paintcolor = $image->colorAllocate( @{$colors{ $color }} ) ;
push @paintcolors, $paintcolor ;
lh $t0,8($a1)
}
sh $t0,8($a0)
my $startx = 0 ;
my $starty = 0 ;
lh $t0,10($a1)
my $run = 0 ;
sh $t0,10($a0)
my $barheight = 240 / 4 ;
my $colorindex = 0 ;
lh $t0,12($a1)
while ( $run < 4 ) {
sh $t0,12($a0)
my $barwidth = $run + 1 ;
while ( $startx + $barwidth < 320 ) {
lh $t0,14($a1)
$image->filledRectangle( $startx , $starty , $startx + $barwidth ,
sh $t0,14($a0)
$starty + $barheight - 1 , $paintcolors[ $colorindex % 8 ] ) ;
$startx += $barwidth ;
addiu $a0,16
$colorindex++ ;
subiu $t1,1
}
bnez $t1,LOOP1
$starty += $barheight ;
nop
$startx = 0 ;
$colorindex = 0 ;
li $t1,0x4B00/16
$run++ ;
}
LOOP2:
open ( DISPLAY , ">" , "pinstripes.png" ) || die ;
lh $t0,($a1)
binmode DISPLAY ;
sh $t0,($a0)
print DISPLAY $image->png ;
sh $t0,2($a0)
close DISPLAY ;</lang>
=={{header|Perl 6}}==
lh $t0,2($a1)
{{works with|Rakudo|2016-01}}
sh $t0,4($a0)
<lang perl6>my $HOR = 1280;
sh $t0,6($a0)
my $VERT = 720;
lh $t0,4($a1)
sh $t0,8($a0)
sh $t0,10($a0)
lh $t0,6($a1)
sh $t0,12($a0)
sh $t0,14($a0)
 
lh $t0,8($a1)
my @colors = map -> $r, $g, $b { [$r, $g, $b] },
sh $t0,16($a0)
0, 0, 0,
sh $t0,18($a0)
255, 0, 0,
0,255, 0,
lh $t0,10($a1)
0, 0,255,
sh $t0,20($a0)
255, 0,255,
sh $t0,22($a0)
0,255,255,
255,255, 0,
lh $t0,12($a1)
255,255,255;
sh $t0,24($a0)
sh $t0,26($a0)
lh $t0,14($a1)
sh $t0,28($a0)
sh $t0,30($a0)
addiu $a0,32
subiu $t1,1
bnez $t1,LOOP2
nop
li $t1,0x4B00/32
LOOP3:
lh $t0,0($a1)
sh $t0,0($a0)
sh $t0,2($a0)
sh $t0,4($a0)
lh $t0,2($a1)
sh $t0,6($a0)
sh $t0,8($a0)
sh $t0,10($a0)
lh $t0,4($a1)
sh $t0,12($a0)
sh $t0,14($a0)
sh $t0,16($a0)
lh $t0,8($a1)
sh $t0,18($a0)
sh $t0,20($a0)
sh $t0,22($a0)
lh $t0,10($a1)
sh $t0,24($a0)
sh $t0,26($a0)
sh $t0,28($a0)
lh $t0,12($a1)
sh $t0,30($a0)
sh $t0,32($a0)
sh $t0,34($a0)
lh $t0,14($a1)
sh $t0,36($a0)
sh $t0,38($a0)
sh $t0,40($a0)
lh $t0,0($a1)
sh $t0,42($a0)
sh $t0,44($a0)
sh $t0,46($a0)
lh $t0,2($a1)
sh $t0,48($a0)
sh $t0,50($a0)
sh $t0,52($a0)
lh $t0,4($a1)
sh $t0,54($a0)
sh $t0,56($a0)
sh $t0,58($a0)
lh $t0,6($a1)
sh $t0,60($a0)
sh $t0,62($a0)
addiu $a0,64
subiu $t1,1
bnez $t1,LOOP3
nop
li $t1,0x4B00/32
LOOP4:
lh $t0,0($a1)
sh $t0,0($a0)
sh $t0,2($a0)
sh $t0,4($a0)
sh $t0,6($a0)
lh $t0,2($a1)
sh $t0,8($a0)
sh $t0,10($a0)
sh $t0,12($a0)
sh $t0,14($a0)
lh $t0,4($a1)
sh $t0,16($a0)
sh $t0,18($a0)
sh $t0,20($a0)
sh $t0,22($a0)
lh $t0,6($a1)
sh $t0,24($a0)
sh $t0,26($a0)
sh $t0,28($a0)
sh $t0,30($a0)
 
lh $t0,8($a1)
my $PPM = open "pinstripes.ppm", :w or die "Can't create pinstripes.ppm: $!";
sh $t0,32($a0)
sh $t0,34($a0)
sh $t0,36($a0)
sh $t0,38($a0)
lh $t0,10($a1)
sh $t0,40($a0)
sh $t0,42($a0)
sh $t0,44($a0)
sh $t0,46($a0)
lh $t0,12($a1)
sh $t0,48($a0)
sh $t0,50($a0)
sh $t0,52($a0)
sh $t0,54($a0)
lh $t0,14($a1)
sh $t0,56($a0)
sh $t0,58($a0)
sh $t0,60($a0)
sh $t0,62($a0)
 
addiu $a0,64
$PPM.print: qq:to/EOH/;
subiu $t1,1
P3
bnez $t1,LOOP4
# pinstripes.ppm
nop
$HOR $VERT
255
shutdown:
EOH
nop ;project 64 will throw an error and end the program if I don't have a NOP here. Real hardware doesn't care.
b shutdown
nop
colors:
;colors are approximate because I'm not sure how the bit patterns work.
.halfword 0x0000,0xf000,0x0f00,0x00f0,0xf0f0,0x7fff,0xff00,0xffff
.include "\SrcN64\Footer.asm"</syntaxhighlight>
 
{{out}}
my $vzones = $VERT div 4;
[[https://ibb.co/y4gg97Z Output of Nintendo 64 emulator]]
for 1..4 -> $w {
my $hzones = ceiling $HOR / $w / +@colors;
my $line = [((@colors Xxx $w) xx $hzones).flatmap: *.values].splice(0,$HOR);
$PPM.put: $line for ^$vzones;
}
 
=={{header|Nim}}==
$PPM.close;</lang>
{{libheader|gintro}}
<syntaxhighlight lang="nim">import gintro/[glib, gobject, gtk, gio, cairo]
 
const
=={{header|Phix}}==
Width = 420
{{libheader|pGUI}}
Height = 420
<lang Phix>--
-- demo\rosetta\Colour_pinstripe.exw
-- =================================
--
include pGUI.e
 
const Colors = [[0.0, 0.0, 0.0], [255.0, 0.0, 0.0],
constant colours = {CD_BLACK, CD_RED, CD_GREEN, CD_MAGENTA, CD_CYAN, CD_YELLOW, CD_WHITE}
[0.0, 255.0, 0.0], [0.0, 0.0, 255.0],
[255.0, 0.0, 255.0], [0.0, 255.0, 255.0],
[255.0, 255.0, 0.0], [255.0, 255.0, 255.0]]
 
#---------------------------------------------------------------------------------------------------
procedure draw_to(cdCanvas cdcanvas)
cdCanvasActivate(cdcanvas)
integer {width, height} = cdCanvasGetSize(cdcanvas)
for y=1 to 4 do
integer x = 0, c = 1, h = floor(height/(5-y))
while x<width do
cdCanvasSetForeground(cdcanvas, colours[c])
cdCanvasBox(cdcanvas, x, x+y, height-h, height)
x += y
c = iff(c=length(colours)?1:c+1)
end while
height -= h
end for
cdCanvasFlush(cdcanvas)
end procedure
 
proc draw(area: DrawingArea; context: Context) =
Ihandle dlg, canvas
## Draw the color bars.
cdCanvas cddbuffer, cdcanvas
 
const lineHeight = Height div 4
function redraw_cb(Ihandle /*ih*/, integer /*posx*/, integer /*posy*/)
draw_to(cddbuffer)
return IUP_DEFAULT
end function
 
var y = 0.0
function map_cb(Ihandle ih)
for lineWidth in [1.0, 2.0, 3.0, 4.0]:
cdcanvas = cdCreateCanvas(CD_IUP, ih)
context.setLineWidth(lineWidth)
cddbuffer = cdCreateCanvas(CD_DBUFFER, cdcanvas)
returnvar IUP_DEFAULTx = 0.0
var colorIndex = 0
end function
while x < Width:
context.setSource(Colors[colorIndex])
context.moveTo(x, y)
context.lineTo(x, y + lineHeight)
context.stroke()
colorIndex = (colorIndex + 1) mod Colors.len
x += lineWidth
y += lineHeight
 
#---------------------------------------------------------------------------------------------------
function unmap_cb(Ihandle /*ih*/)
cdKillCanvas(cddbuffer)
cdKillCanvas(cdcanvas)
return IUP_DEFAULT
end function
 
proc onDraw(area: DrawingArea; context: Context; data: pointer): bool =
function esc_close(Ihandle /*ih*/, atom c)
## Callback to draw/redraw the drawing area contents.
if c=K_ESC then return IUP_CLOSE end if
return IUP_CONTINUE
end function
 
area.draw(context)
function print_cb(Ihandle /*ih*/)
result = true
cdCanvan print_canvas = cdCreateCanvas(CD_PRINTER, "pinstripe -d")
if print_canvas!=NULL then
draw_to(print_canvas)
cdKillCanvas(print_canvas)
end if
return IUP_DEFAULT
end function
 
#---------------------------------------------------------------------------------------------------
function exit_cb(Ihandle /*ih*/)
return IUP_CLOSE
end function
 
proc activate(app: Application) =
procedure main()
## Activate the application.
IupOpen()
 
let window = app.newApplicationWindow()
Ihandle file_menu = IupMenu({IupMenuItem("&Print",Icallback("print_cb")),
window.setSizeRequest(Width, Height)
IupMenuItem("E&xit", Icallback("exit_cb"))})
window.setTitle("Color pinstripe")
 
# Create the drawing area.
Ihandle main_menu = IupMenu({IupSubmenu("File", file_menu)})
let area = newDrawingArea()
window.add(area)
 
# Connect the "draw" event to the callback to draw the color bars.
canvas = IupCanvas(NULL)
discard area.connect("draw", ondraw, pointer(nil))
IupSetAttribute(canvas, "RASTERSIZE", "600x400") -- initial size
 
window.showAll()
IupSetCallback(canvas, "MAP_CB", Icallback("map_cb"))
IupSetCallback(canvas, "UNMAP_CB", Icallback("unmap_cb"))
 
#———————————————————————————————————————————————————————————————————————————————————————————————————
dlg = IupDialog(canvas)
IupSetAttribute(dlg, "TITLE", "Colour pinstripe")
IupSetAttributeHandle(dlg,"MENU",main_menu)
IupSetCallback(canvas, "ACTION", Icallback("redraw_cb"))
IupSetCallback(dlg, "K_ANY", Icallback("esc_close"))
 
let app = newApplication(Application, "Rosetta.ColorPinstripe")
IupMap(dlg)
discard app.connect("activate", activate)
IupSetAttribute(canvas, "RASTERSIZE", NULL) -- release the minimum limitation
discard app.run()</syntaxhighlight>
 
=={{header|OCaml}}==
IupShowXY(dlg,IUP_CENTER,IUP_CENTER)
 
<syntaxhighlight lang="ocaml">open Graphics
IupMainLoop()
 
let () =
IupClose()
open_graph "";
end procedure
let width = size_x ()
and height = size_y () in
let colors = [| black; red; green; blue; magenta; cyan; yellow; white |] in
let num_colors = Array.length colors in
let h = height / 4 in
for i = 1 to 4 do
let j = 4 - i in
for x = 0 to pred width do
set_color colors.((x / i) mod num_colors);
moveto x (j * h); lineto x (j * h + h);
done
done;
ignore(read_key())</syntaxhighlight>
 
run with:
main()</lang>
<pre>$ ocaml graphics.cma pinstripe.ml</pre>
 
=={{header|Perl}}==
<syntaxhighlight lang="perl">use strict;
use warnings;
use GD;
 
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($height, $width) = (240, 320);
my $image = GD::Image->new( $width , $height );
 
my @paintcolors;
my $barheight = $height / 4;
my($startx, $starty, $run, $colorindex) = (0) x 4;
 
for my $color ( sort keys %colors ) {
push @paintcolors, $image->colorAllocate( @{$colors{ $color }} );
}
 
while ( $run < 4 ) {
my $barwidth = $run + 1;
while ( $startx + $barwidth < $width ) {
$image->filledRectangle( $startx, $starty,
$startx + $barwidth,
$starty + $barheight - 1,
$paintcolors[ $colorindex % 8 ] );
$startx += $barwidth;
$colorindex++;
}
$starty += $barheight;
$startx = 0;
$colorindex = 0;
$run++;
}
 
open ( DISPLAY , '>' , 'pinstripes.png' ) or die;
binmode DISPLAY;
print DISPLAY $image->png;
close DISPLAY;</syntaxhighlight>
 
=={{header|Phix}}==
{{libheader|Phix/pGUI}}
<!--<syntaxhighlight lang="phix">(phixonline)-->
<span style="color: #000080;font-style:italic;">--
-- demo\rosetta\Colour_pinstripe.exw
-- =================================
--</span>
<span style="color: #008080;">with</span> <span style="color: #008080;">javascript_semantics</span> <span style="color: #000080;font-style:italic;">-- but not yet CD_PRINTER</span>
<span style="color: #008080;">include</span> <span style="color: #000000;">pGUI</span><span style="color: #0000FF;">.</span><span style="color: #000000;">e</span>
<span style="color: #008080;">constant</span> <span style="color: #000000;">colours</span> <span style="color: #0000FF;">=</span> <span style="color: #0000FF;">{</span><span style="color: #004600;">CD_BLACK</span><span style="color: #0000FF;">,</span> <span style="color: #004600;">CD_RED</span><span style="color: #0000FF;">,</span> <span style="color: #004600;">CD_GREEN</span><span style="color: #0000FF;">,</span> <span style="color: #004600;">CD_MAGENTA</span><span style="color: #0000FF;">,</span> <span style="color: #004600;">CD_CYAN</span><span style="color: #0000FF;">,</span> <span style="color: #004600;">CD_YELLOW</span><span style="color: #0000FF;">,</span> <span style="color: #004600;">CD_WHITE</span><span style="color: #0000FF;">}</span>
<span style="color: #000080;font-style:italic;">--constant colours = {CD_BLACK, CD_WHITE}</span>
<span style="color: #008080;">procedure</span> <span style="color: #000000;">draw_to</span><span style="color: #0000FF;">(</span><span style="color: #004080;">cdCanvas</span> <span style="color: #000000;">cdcanvas</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">cdCanvasActivate</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cdcanvas</span><span style="color: #0000FF;">)</span>
<span style="color: #004080;">integer</span> <span style="color: #0000FF;">{</span><span style="color: #000000;">width</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">height</span><span style="color: #0000FF;">}</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">cdCanvasGetSize</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cdcanvas</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">for</span> <span style="color: #000000;">y</span><span style="color: #0000FF;">=</span><span style="color: #000000;">1</span> <span style="color: #008080;">to</span> <span style="color: #000000;">4</span> <span style="color: #008080;">do</span>
<span style="color: #004080;">integer</span> <span style="color: #000000;">x</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">0</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">c</span> <span style="color: #0000FF;">=</span> <span style="color: #000000;">1</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">h</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">floor</span><span style="color: #0000FF;">(</span><span style="color: #000000;">height</span><span style="color: #0000FF;">/(</span><span style="color: #000000;">5</span><span style="color: #0000FF;">-</span><span style="color: #000000;">y</span><span style="color: #0000FF;">))</span>
<span style="color: #008080;">while</span> <span style="color: #000000;">x</span><span style="color: #0000FF;"><</span><span style="color: #000000;">width</span> <span style="color: #008080;">do</span>
<span style="color: #7060A8;">cdCanvasSetForeground</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cdcanvas</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">colours</span><span style="color: #0000FF;">[</span><span style="color: #000000;">c</span><span style="color: #0000FF;">])</span>
<span style="color: #7060A8;">cdCanvasBox</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cdcanvas</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">x</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">x</span><span style="color: #0000FF;">+</span><span style="color: #000000;">y</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">height</span><span style="color: #0000FF;">-</span><span style="color: #000000;">h</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">height</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">x</span> <span style="color: #0000FF;">+=</span> <span style="color: #000000;">y</span>
<span style="color: #000000;">c</span> <span style="color: #0000FF;">=</span> <span style="color: #008080;">iff</span><span style="color: #0000FF;">(</span><span style="color: #000000;">c</span><span style="color: #0000FF;">=</span><span style="color: #7060A8;">length</span><span style="color: #0000FF;">(</span><span style="color: #000000;">colours</span><span style="color: #0000FF;">)?</span><span style="color: #000000;">1</span><span style="color: #0000FF;">:</span><span style="color: #000000;">c</span><span style="color: #0000FF;">+</span><span style="color: #000000;">1</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">while</span>
<span style="color: #000000;">height</span> <span style="color: #0000FF;">-=</span> <span style="color: #000000;">h</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">for</span>
<span style="color: #7060A8;">cdCanvasFlush</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cdcanvas</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #004080;">Ihandle</span> <span style="color: #000000;">dlg</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">canvas</span>
<span style="color: #004080;">cdCanvas</span> <span style="color: #000000;">cddbuffer</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">cdcanvas</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">redraw_cb</span><span style="color: #0000FF;">(</span><span style="color: #004080;">Ihandle</span> <span style="color: #000080;font-style:italic;">/*ih*/</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">draw_to</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cddbuffer</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">return</span> <span style="color: #004600;">IUP_DEFAULT</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">map_cb</span><span style="color: #0000FF;">(</span><span style="color: #004080;">Ihandle</span> <span style="color: #000000;">ih</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">cdcanvas</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">cdCreateCanvas</span><span style="color: #0000FF;">(</span><span style="color: #004600;">CD_IUP</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">ih</span><span style="color: #0000FF;">)</span>
<span style="color: #000000;">cddbuffer</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">cdCreateCanvas</span><span style="color: #0000FF;">(</span><span style="color: #004600;">CD_DBUFFER</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">cdcanvas</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">return</span> <span style="color: #004600;">IUP_DEFAULT</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">unmap_cb</span><span style="color: #0000FF;">(</span><span style="color: #004080;">Ihandle</span> <span style="color: #000080;font-style:italic;">/*ih*/</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">cdKillCanvas</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cddbuffer</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">cdKillCanvas</span><span style="color: #0000FF;">(</span><span style="color: #000000;">cdcanvas</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">return</span> <span style="color: #004600;">IUP_DEFAULT</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">print_cb</span><span style="color: #0000FF;">(</span><span style="color: #004080;">Ihandle</span> <span style="color: #000080;font-style:italic;">/*ih*/</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">if</span> <span style="color: #7060A8;">platform</span><span style="color: #0000FF;">()!=</span><span style="color: #004600;">JS</span> <span style="color: #008080;">then</span>
<span style="color: #004080;">cdCanvan</span> <span style="color: #000000;">print_canvas</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">cdCreateCanvas</span><span style="color: #0000FF;">(</span><span style="color: #004600;">CD_PRINTER</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"pinstripe -d"</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">if</span> <span style="color: #000000;">print_canvas</span><span style="color: #0000FF;">!=</span><span style="color: #004600;">NULL</span> <span style="color: #008080;">then</span>
<span style="color: #000000;">draw_to</span><span style="color: #0000FF;">(</span><span style="color: #000000;">print_canvas</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">cdKillCanvas</span><span style="color: #0000FF;">(</span><span style="color: #000000;">print_canvas</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">return</span> <span style="color: #004600;">IUP_DEFAULT</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #008080;">function</span> <span style="color: #000000;">exit_cb</span><span style="color: #0000FF;">(</span><span style="color: #004080;">Ihandle</span> <span style="color: #000080;font-style:italic;">/*ih*/</span><span style="color: #0000FF;">)</span>
<span style="color: #008080;">return</span> <span style="color: #004600;">IUP_CLOSE</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">function</span>
<span style="color: #008080;">procedure</span> <span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<span style="color: #7060A8;">IupOpen</span><span style="color: #0000FF;">()</span>
<span style="color: #004080;">Ihandle</span> <span style="color: #000000;">file_menu</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">IupMenu</span><span style="color: #0000FF;">({</span><span style="color: #7060A8;">IupMenuItem</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"&Print"</span><span style="color: #0000FF;">,</span><span style="color: #7060A8;">Icallback</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"print_cb"</span><span style="color: #0000FF;">)),</span>
<span style="color: #7060A8;">IupMenuItem</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"E&xit"</span><span style="color: #0000FF;">,</span> <span style="color: #7060A8;">Icallback</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"exit_cb"</span><span style="color: #0000FF;">))})</span>
<span style="color: #004080;">Ihandle</span> <span style="color: #000000;">main_menu</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">IupMenu</span><span style="color: #0000FF;">({</span><span style="color: #7060A8;">IupSubmenu</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"File"</span><span style="color: #0000FF;">,</span> <span style="color: #000000;">file_menu</span><span style="color: #0000FF;">)})</span>
<span style="color: #000000;">canvas</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">IupCanvas</span><span style="color: #0000FF;">(</span><span style="color: #004600;">NULL</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">IupSetAttribute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">canvas</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"RASTERSIZE"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"600x400"</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- initial size</span>
<span style="color: #7060A8;">IupSetCallback</span><span style="color: #0000FF;">(</span><span style="color: #000000;">canvas</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"MAP_CB"</span><span style="color: #0000FF;">,</span> <span style="color: #7060A8;">Icallback</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"map_cb"</span><span style="color: #0000FF;">))</span>
<span style="color: #7060A8;">IupSetCallback</span><span style="color: #0000FF;">(</span><span style="color: #000000;">canvas</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"UNMAP_CB"</span><span style="color: #0000FF;">,</span> <span style="color: #7060A8;">Icallback</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"unmap_cb"</span><span style="color: #0000FF;">))</span>
<span style="color: #000000;">dlg</span> <span style="color: #0000FF;">=</span> <span style="color: #7060A8;">IupDialog</span><span style="color: #0000FF;">(</span><span style="color: #000000;">canvas</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">IupSetAttribute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">dlg</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"TITLE"</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"Colour pinstripe"</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">IupSetAttributeHandle</span><span style="color: #0000FF;">(</span><span style="color: #000000;">dlg</span><span style="color: #0000FF;">,</span><span style="color: #008000;">"MENU"</span><span style="color: #0000FF;">,</span><span style="color: #000000;">main_menu</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">IupSetCallback</span><span style="color: #0000FF;">(</span><span style="color: #000000;">canvas</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"ACTION"</span><span style="color: #0000FF;">,</span> <span style="color: #7060A8;">Icallback</span><span style="color: #0000FF;">(</span><span style="color: #008000;">"redraw_cb"</span><span style="color: #0000FF;">))</span>
<span style="color: #7060A8;">IupShowXY</span><span style="color: #0000FF;">(</span><span style="color: #000000;">dlg</span><span style="color: #0000FF;">,</span><span style="color: #004600;">IUP_CENTER</span><span style="color: #0000FF;">,</span><span style="color: #004600;">IUP_CENTER</span><span style="color: #0000FF;">)</span>
<span style="color: #7060A8;">IupSetAttribute</span><span style="color: #0000FF;">(</span><span style="color: #000000;">canvas</span><span style="color: #0000FF;">,</span> <span style="color: #008000;">"RASTERSIZE"</span><span style="color: #0000FF;">,</span> <span style="color: #004600;">NULL</span><span style="color: #0000FF;">)</span> <span style="color: #000080;font-style:italic;">-- release the minimum limitation</span>
<span style="color: #008080;">if</span> <span style="color: #7060A8;">platform</span><span style="color: #0000FF;">()!=</span><span style="color: #004600;">JS</span> <span style="color: #008080;">then</span>
<span style="color: #7060A8;">IupMainLoop</span><span style="color: #0000FF;">()</span>
<span style="color: #7060A8;">IupClose</span><span style="color: #0000FF;">()</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">if</span>
<span style="color: #008080;">end</span> <span style="color: #008080;">procedure</span>
<span style="color: #000000;">main</span><span style="color: #0000FF;">()</span>
<!--</syntaxhighlight>-->
Simply change constant colours to {CD_BLACK, CD_WHITE} for the monochrome tasks (as redirected here).
 
Line 898 ⟶ 1,679:
 
=={{header|PicoLisp}}==
<langsyntaxhighlight PicoLisplang="picolisp">(de *Colors # Black Red Green Blue Magenta Cyan Yellow White
((0 0 0) (255 0 0) (0 255 0) (0 0 255)
(255 0 255) (0 255 255) (255 255 0) (255 255 255) .) )
Line 915 ⟶ 1,696:
(prinl (length (car Ppm)) " " (length Ppm))
(prinl 255)
(for Y Ppm (for X Y (apply wr X))) ) )</langsyntaxhighlight>
 
=={{header|Plain English}}==
<syntaxhighlight lang="plainenglish">To run:
Start up.
Clear the screen.
Imagine a box with the screen's left and the screen's top and the screen's right and the screen's bottom divided by 4.
Make a color pinstripe given 1 pixel and the box.
Draw the color pinstripe.
Draw the next color pinstripe given the color pinstripe.
Draw the next color pinstripe given the color pinstripe.
Draw the next color pinstripe given the color pinstripe.
Refresh the screen.
Wait for the escape key.
Shut down.
 
A color pinstripe has a width and a box.
 
To make a color pinstripe given a width and a box:
Put the width into the color pinstripe's width.
Put the box into the color pinstripe's box.
 
To draw a color pinstripe:
Put the color pinstripe's box into a bound box.
Put the color pinstripe's width into a width.
Imagine a box with the bound's left and the bound's top and the width and the bound's bottom.
Put the bound's right divided by the width into an amount.
Loop.
If a counter is past the amount, exit.
Draw and fill the box with the black color. Move the box right the width.
Draw and fill the box with the red color. Move the box right the width.
Draw and fill the box with the green color. Move the box right the width.
Draw and fill the box with the blue color. Move the box right the width.
Draw and fill the box with the magenta color. Move the box right the width.
Draw and fill the box with the cyan color. Move the box right the width.
Draw and fill the box with the yellow color. Move the box right the width.
Draw and fill the box with the white color.
Repeat.
 
To draw the next color pinstripe given a color pinstripe:
Add 1 pixel to the color pinstripe's width.
Move the color pinstripe's box down the color pinstripe's box's height.
Draw the color pinstripe.</syntaxhighlight>
 
=={{header|PureBasic}}==
<langsyntaxhighlight PureBasiclang="purebasic">;Create a Pinstripe image with a pattern of vertical stripe colors
Procedure PinstripeDisplay(width, height, Array psColors(1), numColors = 0)
Protected x, imgID, psHeight = height / 4, psWidth = 1, psTop, horzBand, curColor
Line 960 ⟶ 1,783:
While WaitWindowEvent() <> #PB_Event_CloseWindow
Wend
EndIf</langsyntaxhighlight>
 
=={{header|Python}}==
<syntaxhighlight lang="python">
<lang Python>
from turtle import *
 
Line 998 ⟶ 1,821:
notused = input("Hit enter to continue: ")
</syntaxhighlight>
</lang>
 
=={{header|QBasic}}==
{{works with|QBasic|1.1}}
{{trans|BASIC256}}
<syntaxhighlight lang="qbasic">SCREEN 12
w = 640: h = 480
 
h = h / 4
y2 = h - 1
 
FOR i = 1 TO 4
col = 0
y = (i - 1) * h
FOR x = 1 TO w STEP i
IF col MOD 15 = 0 THEN col = 0
LINE (x, y)-(x + i, y + h), col, BF
col = col + 1
NEXT x
NEXT i</syntaxhighlight>
 
=={{header|Quackery}}==
 
<syntaxhighlight lang="Quackery"> [ $ "turtleduck.qky" loadfile ] now!
 
[ 1280 ] is width ( --> n )
[ 720 ] is height ( --> n )
 
[ 0 0 0 ] is black ( --> n n n )
[ 255 0 0 ] is red ( --> n n n )
[ 0 255 0 ] is green ( --> n n n )
[ 0 0 255 ] is blue ( --> n n n )
[ 255 0 255 ] is magenta ( --> n n n )
[ 0 255 255 ] is cyan ( --> n n n )
[ 255 255 0 ] is yellow ( --> n n n )
[ 255 255 255 ] is white ( --> n n n )
 
[ [] swap
' [ black red
green blue
magenta cyan
yellow white ]
witheach
[ over times
[ dip swap tuck
nested join
unrot ]
drop ]
drop ] is colours ( n --> [ )
 
[ behead
dup dip
[ nested join ] ] is nextcolour ( [ --> [ [ )
 
[ nextcolour colour
-1 4 turn
height n->v
4 n->v v/ 2dup walk
-v fly
1 4 turn
1 n->v fly ] is stripe ( [ --> [ )
 
[ 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
drop
width n->v -v fly
-1 4 turn
height n->v
4 n->v v/ fly
1 4 turn ]
1 frames ] is pinstripes ( --> )
</syntaxhighlight>
 
{{out}}
[[File:Quackery colour pinstripe.png|thumb|center]]
 
=={{header|Racket}}==
<syntaxhighlight lang="racket">
<lang Racket>
#lang racket/gui
 
Line 1,032 ⟶ 1,936:
 
(void (new full-frame%))
</syntaxhighlight>
</lang>
 
=={{header|Raku}}==
(formerly Perl 6)
<syntaxhighlight lang="raku" line>my ($x,$y) = 1280, 720;
 
my @colors = map -> $r, $g, $b { [$r, $g, $b] },
0, 0, 0,
255, 0, 0,
0, 255, 0,
0, 0, 255,
255, 0, 255,
0, 255, 255,
255, 255, 0,
255, 255, 255;
 
my $img = open "pinstripes.ppm", :w orelse die "Can't create pinstripes.ppm: $_";
 
$img.print: qq:to/EOH/;
P3
# pinstripes.ppm
$x $y
255
EOH
 
my $vzones = $y div 4;
for 1..4 -> $width {
my $stripes = ceiling $x / $width / +@colors;
my $row = [flat ((@colors Xxx $width) xx $stripes).map: *.values].splice(0,$x);
$img.put: $row for ^$vzones;
}
 
$img.close;</syntaxhighlight>
 
=={{header|Ring}}==
<langsyntaxhighlight lang="ring">
# Project : Colour pinstripe/Display
 
Line 1,099 ⟶ 2,035:
}
label1 { setpicture(p1) show() }
</syntaxhighlight>
</lang>
 
See image:
Line 1,107 ⟶ 2,043:
=={{header|Scala}}==
===Java Swing Interoperability===
<langsyntaxhighlight Scalalang="scala">import java.awt.Color._
import java.awt._
 
Line 1,145 ⟶ 2,081:
)
 
}</langsyntaxhighlight>
 
=={{header|Sidef}}==
{{trans|Perl}}
<langsyntaxhighlight lang="ruby">require('GD')
 
func pinstripes(width = 1280, height = 720) {
Line 1,177 ⟶ 2,114:
}
 
File('pinstripes.png').write(pinstripes().png, :raw)</langsyntaxhighlight>
 
=={{header|SmileBASIC}}==
<syntaxhighlight lang="smilebasic">FOR I=1 TO 4
COLIDX=0
YTOP=(I-1)*60
FOR X=0 TO 399 STEP I
IF COLIDX MOD 8==0 THEN
RESTORE @COLOURS
ENDIF
READ R,G,B
GFILL X,YTOP,X+I,YTOP+59,RGB(R,G,B)
INC COLIDX
NEXT
NEXT
 
@COLOURS
DATA 0,0,0
DATA 255,0,0
DATA 0,255,0
DATA 0,0,255
DATA 255,0,255
DATA 0,255,255
DATA 255,255,0
DATA 255,255,255</syntaxhighlight>
 
=={{header|Tcl}}==
{{libheader|Tk}}
<langsyntaxhighlight lang="tcl">package require Tcl 8.5
package require Tk 8.5
Line 1,197 ⟶ 2,158:
}
incr y $dy
}</langsyntaxhighlight>
 
=={{header|True BASIC}}==
<syntaxhighlight lang="qbasic">LET w = 640
LET h = 480
SET WINDOW 0, w, 0, h
 
LET h = h/4
LET y2 = h-1
 
FOR i = 1 to 4
LET col = 0
LET y = (i-1)*h
FOR x = 1 to w step i
IF remainder(col,15) = 0 then LET col = 0
SET COLOR col
BOX AREA x, x+i, y, y+h
LET col = col+1
NEXT x
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}}==
<langsyntaxhighlight lang="vbnet">Public Class Main
Inherits System.Windows.Forms.Form
Public Sub New()
Line 1,218 ⟶ 2,240:
Next
End Sub
End Class</langsyntaxhighlight>
 
=={{header|Wren}}==
{{trans|Go}}
{{libheader|DOME}}
<syntaxhighlight lang="wren">import "graphics" for Canvas, Color
import "dome" for Window
 
class Game {
static init() {
Window.title = "Color pinstripe"
__width = 900
__height = 600
Canvas.resize(__width, __height)
Window.resize(__width, __height)
var colors = [
Color.hex("000000"), // black
Color.hex("FF0000"), // red
Color.hex("00FF00"), // green
Color.hex("0000FF"), // blue
Color.hex("FF00FF"), // magenta
Color.hex("00FFFF"), // cyan
Color.hex("FFFF00"), // yellow
Color.hex("FFFFFF") // white
]
pinstripe(colors)
}
 
static pinstripe(colors) {
var w = __width
var h = (__height/4).floor
for (b in 1..4) {
var x = 0
var ci = 0
while (x < w) {
var y = h * (b - 1)
Canvas.rectfill(x, y, b, h, colors[ci%8])
x = x + b
ci = ci + 1
}
}
}
 
static update() {}
 
static draw(dt) {}
}</syntaxhighlight>
 
=={{header|XPL0}}==
[[File:PinsXPL0.gif|right]]
<langsyntaxhighlight XPL0lang="xpl0">code ChIn=7, Point=41, SetVid=45;
int X, Y, W, C;
[SetVid($13); \set 320x200 graphics mode in 256 colors
Line 1,235 ⟶ 2,303:
X:= ChIn(1); \wait for keystroke
SetVid(3); \restore normal text mode display
]</langsyntaxhighlight>
 
=={{header|Yabasic}}==
{{trans|SmileBASIC}}
<syntaxhighlight lang="yabasic">w = 640 : h = 480
open window w, h
h4 = h/4
 
FOR I=1 TO 4
COLIDX=0
YTOP=(I-1)*h4
FOR X=1 TO w STEP I
IF mod(COLIDX, 8) = 0 RESTORE COLOURS
READ R,G,B
color R, G, B
fill rectangle X,YTOP,X+I,YTOP+h4
COLIDX = COLIDX + 1
NEXT
NEXT
label COLOURS
DATA 0,0,0
DATA 255,0,0
DATA 0,255,0
DATA 0,0,255
DATA 255,0,255
DATA 0,255,255
DATA 255,255,0
DATA 255,255,255
</syntaxhighlight>
 
{{omit from|AWK}}
57

edits