Color wheel: Difference between revisions
Content added Content deleted
Line 909: | Line 909: | ||
<lang ring> |
<lang ring> |
||
#===================================================================# |
#===================================================================# |
||
# |
# Sample: Color Wheel |
||
# |
# Author: Gal Zsolt, Bert Mariani, Ilir Liburn & Mahmoud Fayed |
||
#===================================================================# |
#===================================================================# |
||
load "guilib.ring" |
load "guilib.ring" |
||
⚫ | |||
paint = null |
|||
⚫ | |||
⚫ | |||
⚫ | |||
MyApp = new qapp |
|||
{ |
{ |
||
win1 = new qwidget() |
|||
{ setwindowtitle("ColorWheel-FastDraw") |
|||
{ |
|||
⚫ | |||
setWindowTitle("Color wheel") |
|||
⚫ | |||
Canvas = new qlabel(win1) |
|||
{ ### 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) |
|||
pen = new qpen() { setwidth(1) } |
|||
MonaLisa.fill(color) |
|||
daVinci = new qpainter() |
|||
{ |
|||
{ begin(MonaLisa) |
|||
#endpaint() ### This will Stop the Painting. For Animation comment it out |
|||
} |
|||
} |
|||
⚫ | |||
} |
|||
⚫ | |||
⚫ | |||
} |
|||
colorWheel() |
|||
⚫ | |||
⚫ | |||
} |
|||
ColorWheel() |
|||
⚫ | |||
} |
} |
||
//===================== |
|||
Func colorWheel |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
pi = 3.14159265359 |
|||
diameter = pi * 2 |
|||
radius = yHeight / 2 |
|||
v = 1 // value/brightness 1 to 100 1=bright 0=dark |
|||
⚫ | |||
iradius = i - radius |
|||
p = pow( iradius, 2) |
|||
for j = 1 to yHeight |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
h = (atan2( iradius, j-radius ) + pi ) / diameter // hue/color 1 to 360 |
|||
⚫ | |||
⚫ | |||
pi = 3.14 |
|||
radius = 150 |
|||
⚫ | |||
⚫ | |||
⚫ | |||
p = pow(i-radius,2) |
|||
ok |
|||
h = (atan2(i-radius,j-radius)+pi)/(2*pi) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
ok |
|||
⚫ | |||
⚫ | |||
#=====================================================================# |
|||
? "Start drawing..." |
|||
t2 = clock() |
|||
? "Clock : " + t2 |
|||
#=====================================================================# |
|||
daVinci.drawHSVFList(aList) |
|||
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> |
</lang> |
||