Color wheel: Difference between revisions

Content added Content deleted
Line 909: Line 909:
<lang ring>
<lang ring>
#===================================================================#
#===================================================================#
# Sample: Color Wheel
# Sample: Color Wheel
# Author: Gal Zsolt, Bert Mariani, Ilir Liburn & Mahmoud Fayed
# Author: Gal Zsolt, Bert Mariani, Ilir Liburn & Mahmoud Fayed
#===================================================================#
#===================================================================#


load "guilib.ring"
load "guilib.ring"
xWidth = 400
paint = null
yHeight = 400
xWidth = 300
yHeight = 300
oApp = new QApp
MyApp = new qapp
{
{
oWin = new QWidget()
win1 = new qwidget()
{ setwindowtitle("ColorWheel-FastDraw")
{
setgeometry(500,150,xWidth,yHeight)
setWindowTitle("Color wheel")
setGeometry(500,150,xWidth,yHeight)
oCanvas = new QLabel(oWin)
Canvas = new qlabel(win1)
{ ### daVinci paints the MonaLisa on the Canvas
{
### daVinci paints the MonaLisa on the Canvas
MonaLisa = new qPixMap2( xWidth, yHeight)
color = new qcolor(){ setrgb(255,255,255,0) }
MonaLisa = new QPixMap2( xWidth, yHeight)
color = new QColor() { setrgb(255,255,255,0) }
pen = new qpen() { setwidth(1) }
MonaLisa.fill(color)
MonaLisa.fill(color)

daVinci = new QPainter()
daVinci = new qpainter()
{
begin(MonaLisa)
{ begin(MonaLisa)
#endpaint() ### This will Stop the Painting. For Animation comment it out
}
}
setPixMap(MonaLisa)
}
setPixMap(MonaLisa)
show()
}
}
colorWheel()
show()
exec()
}
ColorWheel()
exec()
}
}
//=====================
func colorWheel
Func colorWheel

#=====================================================================#
? "Start Processing..."
t1 = clock()
? "Clock : " + t1
#=====================================================================#

aList = []
pi = 3.14159265359
diameter = pi * 2
radius = yHeight / 2
v = 1 // value/brightness 1 to 100 1=bright 0=dark

for i = 1 to xWidth
iradius = i - radius
p = pow( iradius, 2)


for j = 1 to yHeight
#=====================================================================#
? "Start Processing..."
t1 = clock()
? "Clock : " + t1
#=====================================================================#


h = (atan2( iradius, j-radius ) + pi ) / diameter // hue/color 1 to 360
aList = []
s = sqrt( p + pow( j-radius, 2)) / radius // saturation/intensity 1 to 100
pi = 3.14
radius = 150
if s <= 1 and h <= 1
for i = 1 to xWidth
aList + [i,j,h,s,v,1]
p = pow(i-radius,2)
for j = 1 to yHeight
ok
h = (atan2(i-radius,j-radius)+pi)/(2*pi)
next
s = sqrt(p+pow(j-radius,2))/radius
next
if s < = 1 and h < = 1
aList + [i,j,h,s,1,1]
ok
next
next


#=====================================================================#
#=====================================================================#
? "Start drawing..."
? "Start drawing..."
t2 = clock()
t2 = clock()
? "Clock : " + t2
? "Clock : " + t2
#=====================================================================#
#=====================================================================#


daVinci.drawHSVFList(aList)
daVinci.drawHSVFList(aList)
oCanvas.setPixMap(MonaLisa)
Canvas.setPixMap(MonaLisa)


#=====================================================================#
#=====================================================================#
? "Done..."
? "Done..."
t3 = clock()
t3 = clock()
? "Clock : " + t3
? "Clock : " + t3
#=====================================================================#
#=====================================================================#
? "Processing Time: " + ( (t2-t1)/ClocksPerSecond() ) + " seconds "
? "Processing Time: " + ( (t2-t1)/ClocksPerSecond() ) + " seconds "
? "Drawing Time: " + ( (t3-t2)/ClocksPerSecond() ) + " seconds "
? "Drawing Time: " + ( (t3-t2)/ClocksPerSecond() ) + " seconds "
? "Total Time: " + ( (t3-t1)/ClocksPerSecond() ) + " seconds "
? "Total Time: " + ( (t3-t1)/ClocksPerSecond() ) + " seconds "
#=====================================================================#
#=====================================================================#
return
//==================
</lang>
</lang>