Update samples/Drawing/ColorWheel/ColorWheel-FastDraw.ring by Bert Mariani
load "guilib.ring"
-xWidth = 300
-yHeight = 300
+xWidth = 400
+yHeight = 400
-oApp = new QApp
+MyApp = new qapp
{
- oWin = new QWidget()
- {
- setWindowTitle("Color wheel")
- setGeometry(500,150,xWidth,yHeight)
- oCanvas = new QLabel(oWin)
- {
- ### daVinci paints the MonaLisa on the Canvas
- MonaLisa = new QPixMap2( xWidth, yHeight)
- color = new QColor() { setrgb(255,255,255,0) }
+ win1 = new qwidget()
+ { setwindowtitle("ColorWheel-FastDraw")
+ setgeometry(500,150,xWidth,yHeight)
+
+ Canvas = new qlabel(win1)
+ { ### daVinci paints the MonaLisa on the Canvas
+ MonaLisa = new qPixMap2( xWidth, yHeight)
+ color = new qcolor(){ setrgb(255,255,255,0) }
+ pen = new qpen() { setwidth(1) }
MonaLisa.fill(color)
- daVinci = new QPainter()
- {
- begin(MonaLisa)
+
+ daVinci = new qpainter()
+ { begin(MonaLisa)
+ #endpaint() ### This will Stop the Painting. For Animation comment it out
}
+
setPixMap(MonaLisa)
}
+
show()
}
- colorWheel()
+
+ ColorWheel()
exec()
}
+//=====================
-func colorWheel
+Func colorWheel
#=====================================================================#
? "Start Processing..."
@@ -42,16 +47,24 @@ func colorWheel
#=====================================================================#
aList = []
- pi = 3.14
- radius = 150
+ 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
- p = pow(i-radius,2)
+ iradius = i - radius
+ p = pow( iradius, 2)
+
for j = 1 to yHeight
- h = (atan2(i-radius,j-radius)+pi)/(2*pi)
- s = sqrt(p+pow(j-radius,2))/radius
+
+ h = (atan2( iradius, j-radius ) + pi ) / diameter // hue/color 1 to 360
+ s = sqrt( p + pow( j-radius, 2)) / radius // saturation/intensity 1 to 100
+
if s <= 1 and h <= 1
- aList + [i,j,h,s,1,1]
+ aList + [i,j,h,s,v,1]
ok
+
next
next
@@ -62,7 +75,7 @@ func colorWheel
#=====================================================================#
daVinci.drawHSVFList(aList)
- oCanvas.setPixMap(MonaLisa)
+ Canvas.setPixMap(MonaLisa)
#=====================================================================#
? "Done..."
@@ -73,3 +86,13 @@ func colorWheel
? "Drawing Time: " + ( (t3-t2)/ClocksPerSecond() ) + " seconds "
? "Total Time: " + ( (t3-t1)/ClocksPerSecond() ) + " seconds "
#=====================================================================#
+
+ return
+
+//==================
+
+
+
+
+
+
