Color wheel: Difference between revisions
Content added Content deleted
No edit summary |
|||
Line 905: | Line 905: | ||
=={{header|Ring}}== |
=={{header|Ring}}== |
||
[https://kepfeltoltes.zapto.org/public/ |
[https://kepfeltoltes.zapto.org/public/20210909181910ColorWheel.jpg Color wheel - image] |
||
<lang ring> |
<lang ring> |
||
load "stdlib.ring" |
load "stdlib.ring" |
||
load "guilib.ring" |
load "guilib.ring" |
||
paint = null |
paint = null |
||
new qapp |
new qapp { win1 = new qwidget() |
||
{ |
{ |
||
setwindowtitle("Color wheel") |
|||
setgeometry(540,140,400,400) |
|||
label1 = new qlabel(win1) { |
|||
setgeometry(30,30,320,320) |
|||
settext("") |
|||
} |
|||
show() |
|||
} |
|||
draw() |
|||
exec() |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
color = new qcolor() { |
|||
setrgb(0,0,255,255) |
|||
} |
} |
||
⚫ | |||
paint = new qpainter() { |
|||
p1 = new qpicture() |
|||
⚫ | |||
begin(p1) |
|||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
⚫ | |||
func colorWheel() |
func colorWheel() |
||
pi = 3.14 |
pi = 3.14 |
||
radius = |
radius = 150 |
||
x = win1.width() |
x = win1.width() |
||
y = win1.height() |
y = win1.height() |
||
for i=1 to x |
for i=1 to x |
||
for j=1 to y |
for j=1 to y |
||
color = new qcolor() |
color = new qcolor(){ setrgb(255,255,255,255) } |
||
pen1 = new qpen() { setcolor(color) setwidth(5) } |
|||
h = (atan2(i-radius,j-radius)+pi)/(2*pi) |
h = (atan2(i-radius,j-radius)+pi)/(2*pi) |
||
s = sqrt(pow(i-radius,2)+pow(j-radius,2))/radius |
s = sqrt(pow(i-radius,2)+pow(j-radius,2))/radius |
||
v = 1 |
v = 1 |
||
if s < 1 |
if s < = 1 and h < = 1 |
||
color.setHsvF(h,s,v,1) |
color.setHsvF(h,s,v,1) |
||
pen1 = new qpen() { setcolor(color) setwidth(5) } |
pen1 = new qpen() { setcolor(color) setwidth(5) } |
||
⚫ | |||
⚫ | |||
ok |
ok |
||
paint.setPen(pen1) |
|||
paint.drawPoint(i,j) |
|||
next |
next |
||
next |
next |