Jump to content

Color wheel: Difference between revisions

Line 908:
 
<lang ring>
#===================================================================#
# Project : Color Wheel
# Sample: Color Wheel
# Date : 2021/09/09
# Author : Gal Zsolt (CalmoSoft), Bert Mariani, Ilir Liburn & Mahmoud Fayed
#===================================================================#
# Email : calmosoft@gmail.com
 
load "stdlib.ring"
load "guilib.ring"
paint = null
xWidth = 300
yHeight = 300
MyAppoApp = new qappQApp
{
{
win1 oWin = new qwidgetQWidget() {
{
setwindowtitle("Color wheel")
setWindowTitle("Color wheel")
setgeometry(500,150,xWidth,yHeight)
setGeometry(500,150,xWidth,yHeight)
oCanvas = new QLabel(oWin)
{
Canvas = new qlabel(win1)
### daVinci paints the MonaLisa on the Canvas
{
MonaLisa = new QPixMap2( xWidth, yHeight)
### daVinci paints the MonaLisa on the Canvas
color = new QColor() { setrgb(255,255,255,0) }
MonaLisa = new qPixMap2( xWidth, yHeight)
MonaLisa.fill(color)
daVinci = new QPainter()
{
begin(MonaLisa)
}
setPixMap(MonaLisa)
}
show()
}
colorWheel()
exec()
}
func colorWheel
 
#=====================================================================#
daVinci = new qpainter()
? "Start Processing..."
{
t1 = clock()
begin(MonaLisa)
? "Clock : " + t1
#endpaint() ### This will Stop the Painting. For Animation comment it out
#=====================================================================#
}
 
aList = []
setPixMap(MonaLisa)
pi = 3.14
}
radius = 150
color = new QColor()
pen1 = new QPen()
for i = 1 to xWidth
p = pow(i-radius,2)
for j = 1 to yHeight
h = (atan2(i-radius,j-radius)+pi)/(2*pi)
s = sqrt(p+pow(j-radius,2))/radius
if s < = 1 and h < = 1
aList + [i,j,h,s,1,1]
ok
next
next
 
#=====================================================================#
show()
? "Start drawing..."
}
t2 = clock()
? "Clock : " + t2
ColorWheel()
#=====================================================================#
exec()
 
}
daVinci.drawHSVFList(aList)
oCanvas.setPixMap(MonaLisa)
 
func colorWheel()
#=====================================================================#
pi = 3.14
? "Done..."
radius = 150
t3 = clock()
x = xWidth
? "Clock : " + t3
y = yHeight
#=====================================================================#
? "Processing Time: " + ( (t2-t1)/ClocksPerSecond() ) + " seconds "
for i = 1 to x
? "Drawing Time: " + ( (t3-t2)/ClocksPerSecond() ) + " seconds "
for j = 1 to y
? "Total Time: " + ( (t3-t1)/ClocksPerSecond() ) + " seconds "
#=====================================================================#
color = new qcolor() { setrgb(255,255,255,255) }
pen1 = new qpen() { setcolor(color) setwidth(5) }
h = (atan2(i-radius,j-radius)+pi)/(2*pi)
s = sqrt(pow(i-radius,2)+pow(j-radius,2))/radius
v = 1
if s < = 1 and h < = 1
color.setHsvF(h,s,v,1)
pen1 = new qpen() { setcolor(color) setwidth(5) }
ok
daVinci.setPen(pen1)
daVinci.drawPoint(i,j)
next
Canvas.setPixMap(MonaLisa) ### Need this setPixMap to display imageLabel
MyApp.ProcessEvents() ### <<< EXEC the Draw
next
</lang>
 
2,468

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.