Color wheel: Difference between revisions

Line 909:
<lang ring>
#===================================================================#
# Sample: Color Wheel
# Author: Gal Zsolt, Bert Mariani, Ilir Liburn & Mahmoud Fayed
#===================================================================#
 
load "guilib.ring"
xWidth = 300400
paint = null
yHeight = 300400
xWidth = 300
yHeight = 300
oAppMyApp = new QAppqapp
{
oWin win1 = new QWidgetqwidget()
{ setwindowtitle("ColorWheel-FastDraw")
{
setGeometry setgeometry(500,150,xWidth,yHeight)
setWindowTitle("Color wheel")
setGeometry(500,150,xWidth,yHeight)
oCanvas Canvas = new QLabelqlabel(oWinwin1)
{ ### daVinci paints the MonaLisa on the Canvas
{
### daVinci paints the MonaLisa on the= new qPixMap2( xWidth, CanvasyHeight)
color = new qcolor(){ setrgb(255,255,255,0) }
MonaLisa = new QPixMap2( xWidth, yHeight)
color pen = new QColorqpen() { setrgbsetwidth(255,255,255,01) }
MonaLisa.fill(color)
 
daVinci = new QPainterqpainter()
{
{ begin(MonaLisa)
#endpaint() ### This will Stop the Painting. For Animation comment it out
}
}
setPixMap(MonaLisa)
}
setPixMap(MonaLisa)
show()
} }
colorWheel()
show()
exec()
}
ColorWheel()
exec()
}
//=====================
funcFunc 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,1v,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..."
t2 = clock()
? "Clock : " + t2
#=====================================================================#
 
daVinci.drawHSVFList(aList)
oCanvas Canvas.setPixMap(MonaLisa)
 
#=====================================================================#
? "Done..."
t3 = clock()
? "Clock : " + t3
#=====================================================================#
? "Processing Time: " + ( (t2-t1)/ClocksPerSecond() ) + " seconds "
? "Drawing Time: " + ( (t3-t2)/ClocksPerSecond() ) + " seconds "
? "Total Time: " + ( (t3-t1)/ClocksPerSecond() ) + " seconds "
#=====================================================================#
return
//==================
</lang>
 
2,468

edits