How to resolve the algorithm Colour pinstripe/Display step by step in the Ring programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Colour pinstripe/Display step by step in the Ring 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 Ring programming language
Source code in the ring programming language
# Project : Colour pinstripe/Display
load "guilib.ring"
paint = null
new qapp
{
win1 = new qwidget() {
setwindowtitle("archimedean spiral")
setgeometry(100,100,500,600)
label1 = new qlabel(win1) {
setgeometry(10,10,400,400)
settext("")
}
new qpushbutton(win1) {
setgeometry(150,500,100,30)
settext("draw")
setclickevent("draw()")
}
show()
}
exec()
}
func draw
p1 = new qpicture()
color = new qcolor() {
setrgb(0,0,255,255)
}
pen = new qpen() {
setcolor(color)
setwidth(1)
}
paint = new qpainter() {
begin(p1)
setpen(pen)
w = 100
h = 100
color = list(8)
color[1] = [0 ,0, 0]
color[2] = [255, 0, 0]
color[3] = [0, 255, 0]
color[4] = [0, 0, 255]
color[5] = [255, 0, 255]
color[6] = [0, 255, 255]
color[7] = [255, 255, 0]
color[8] = [255, 255, 255]
y = h*4
for p = 1 to 4
y = y - h
for x = 0 to w step 4*p
col = random(7) + 1
color2 = new qcolor()
color2.setrgb(color[col][1],color[col][2],color[col][3],255)
mybrush = new qbrush() {setstyle(1) setcolor(color2)}
setbrush(mybrush)
paint.drawrect(x, y, 2*p, h)
next
next
endpaint()
}
label1 { setpicture(p1) show() }
You may also check:How to resolve the algorithm Ethiopian multiplication step by step in the Object Pascal programming language
You may also check:How to resolve the algorithm 9 billion names of God the integer step by step in the Clojure programming language
You may also check:How to resolve the algorithm Sorting algorithms/Quicksort step by step in the Emacs Lisp programming language
You may also check:How to resolve the algorithm The sieve of Sundaram step by step in the C# programming language
You may also check:How to resolve the algorithm Exponentiation operator step by step in the Brat programming language