How to resolve the algorithm Draw a cuboid step by step in the Ring programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Draw a cuboid step by step in the Ring programming language
Table of Contents
Problem Statement
Draw a cuboid with relative dimensions of 2 × 3 × 4.
The cuboid can be represented graphically, or in ASCII art, depending on the language capabilities. To fulfill the criteria of being a cuboid, three faces must be visible. Either static or rotational projection is acceptable for this task.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Draw a cuboid step by step in the Ring programming language
Source code in the ring programming language
# Project : Draw a cuboid
load "guilib.ring"
paint = null
new qapp
{
win1 = new qwidget() {
setwindowtitle("Draw a cuboid")
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)
color = new qcolor()
color.setrgb(255,0,0,255)
mybrush = new qbrush() {setstyle(1) setcolor(color)}
setbrush(mybrush)
paint.drawPolygon([[200,200],[300,200],[300,100],[200,100]], 0)
color = new qcolor()
color.setrgb(0,255,0,255)
mybrush = new qbrush() {setstyle(1) setcolor(color)}
setbrush(mybrush)
paint.drawPolygon([[200,100],[250,50],[350,50],[300,100]], 0)
color = new qcolor()
color.setrgb(0, 0, 255,255)
mybrush = new qbrush() {setstyle(1) setcolor(color)}
setbrush(mybrush)
paint.drawPolygon([[350,50],[350,150],[300,200],[300,100]], 0)
endpaint()
}
label1 { setpicture(p1) show() }
return
You may also check:How to resolve the algorithm First class environments step by step in the Order programming language
You may also check:How to resolve the algorithm Amicable pairs step by step in the Clojure programming language
You may also check:How to resolve the algorithm Magic 8-ball step by step in the FOCAL programming language
You may also check:How to resolve the algorithm Function definition step by step in the JavaScript programming language
You may also check:How to resolve the algorithm Fixed length records step by step in the Mathematica / Wolfram Language programming language