How to resolve the algorithm Colour pinstripe/Display step by step in the Icon and Unicon programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Colour pinstripe/Display step by step in the Icon and Unicon programming language
Table of Contents
Problem Statement
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, and white:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Colour pinstripe/Display step by step in the Icon and Unicon programming language
Source code in the icon programming language
link graphics,numbers,printf
procedure main() # pinstripe
&window := open("Colour Pinstripe","g","bg=black") |
stop("Unable to open window")
WAttrib("canvas=hidden")
WAttrib(sprintf("size=%d,%d",WAttrib("displaywidth"),WAttrib("displayheight")))
WAttrib("canvas=maximal")
Colours := ["black", "red", "green", "blue", "magenta", "cyan", "yellow", "white"]
height := WAttrib("height")
width := WAttrib("width")
maxbands := 4 # bands to draw
bandheight := height / maxbands # height of each band
every bands := 1 to maxbands do { # for each band
top := 1 + bandheight * (bands-1) # .. top of band
every c := 1 to width do {
colour := Colours[ceil((c+0.)/bands)%*Colours+1]
if colour == "black" then next # skip black
else {
Fg(colour)
DrawLine(c,top,c,top+bandheight-1)
}
}
}
WDone()
end
You may also check:How to resolve the algorithm Pan base non-primes step by step in the Nim programming language
You may also check:How to resolve the algorithm Knuth's algorithm S step by step in the zkl programming language
You may also check:How to resolve the algorithm McNuggets problem step by step in the FutureBasic programming language
You may also check:How to resolve the algorithm Arithmetic evaluation step by step in the Icon and Unicon programming language
You may also check:How to resolve the algorithm Delete a file step by step in the LabVIEW programming language