Jump to content

Color wheel: Difference between revisions

m
No edit summary
 
(4 intermediate revisions by 4 users not shown)
Line 329:
{{out}}
Png Image [https://ibb.co/T0w8KyF].
=={{header|EasyLang}}==
[https://easylang.dev/show/#cod=bZLdboMwDIXveYpzSagaCrTVqi4Pw08CSHSBkG3w9pOBCjK4AKJzPtvBdmt0jqrPYlNmqL4l+tQiMzU4DEpk4B6ACgI+uWeoRmtDJEOAO5kKAtXqkNRCTEkC+BHOlJOR3O1kBFCTZY+s6agYe19hU6FWk3KhMwCzhD9RQsDiiQwCLbmyWdhow3YLOcfs2XjDtjvWOmxywHYLmZnaYa8b1i5s+5/t5eFfvbmOXO5xr6XZ5b+VlA34PCilDUbqC6zG9fFYEhWkjTgjvr07RuSwJwkmeXBgUuueZtR3xsIvBgTEnShzgGJkK1irmf0UbgIaciVtCoHUpl8xhRaD49OGCfgzdkL0cWEIkdzdLNtt9adSIVViiOaVdeBcN9okB8ZL/0gMCHHDSG/HNDK3uPCEntXg3uZLA5h773l/ Run it]
 
{{trans|Go}}
<syntaxhighlight>
proc hsb2rgb hue sat bri . r g b .
h = (hue - floor hue) * 6
f = h - floor h
p = bri * (1 - sat)
q = bri * (1 - sat * f)
t = bri * (1 - sat * (1 - f))
h = floor h
if h = 0
r = bri ; g = t ; b = p
elif h = 1
r = q ; g = bri ; b = p
elif h = 2
r = p ; g = bri ; b = t
elif h = 3
r = p ; g = q ; b = bri
elif h = 4
r = t ; g = p ; b = bri
else
r = bri ; g = p ; b = q
.
.
proc cwheel . .
for y = 0 to 499
dy = y - 250
for x = 0 to 499
dx = x - 250
dist = sqrt (dx * dx + dy * dy)
if dist <= 250
theta = atan2 dy dx
hue = (theta + 180) / 360
hsb2rgb hue (dist / 250) 1 r g b
color3 r g b
move x / 5 y / 5
rect 0.3 0.3
.
.
.
.
cwheel
 
</syntaxhighlight>
 
=={{header|Fōrmulæ}}==
 
{{FormulaeEntry|page=https://formulae.org/?script=examples/Color_wheel}}
 
'''Solution:'''
 
[[File:Fōrmulæ - Color wheel 01.png]]
 
'''Test case'''
 
Generating a color wheel of 300x300 pixels:
Line 1,222 ⟶ 1,271:
(formerly Perl 6)
{{works with|Rakudo|2016.08}}
[[File:Color-wheel-perl6.png|thumb]]
 
<syntaxhighlight lang="raku" line>use Image::PNG::Portable;
 
Line 1,259 ⟶ 1,308:
} ).map: ((*+$m) * 255).Int
}</syntaxhighlight>
 
Until local image uploading is re-enabled, see [https://github.com/thundergnat/rc/blob/master/img/Color-wheel-perl6.png Color-wheel-perl6.png]
 
=={{header|Ring}}==
Line 1,927 ⟶ 1,974:
=={{header|Wren}}==
{{libheader|DOME}}
<syntaxhighlight lang="ecmascriptwren">import "graphics" for Canvas, Color
import "dome" for Window
import "random" for Random
2,063

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.