# Direction, and color

Colin Holgate coiin at verizon.net
Tue Dec 16 04:02:06 CET 2014

```So, I had a go at this. Here’s my test stack:

go url "http://colin.scienceninja.com/colorwheel.livecode”

Choose the browse tool and click the button. The script deletes any existing graphics and then makes 315 new graphics, with the forelock set to a calculated amount.

There’s one difference from what was asked for, because angles start from the east, not from the north. In my example red is to the right, blue is lower left, and green upper left. Like, 3, 7, and 11 if it was a clock. I suspect I have something reversed, I wanted green to be where blue is. But still, it’ll show off the idea.

Here’s the button script, take a look at it for a while, and the stack, then ask questions!

on mouseUp
lock screen
repeat while the number of graphics > 0
delete graphic 1
end repeat
repeat with a = 1 to 315
new graphic
set the width of graphic a to 10
set the height of graphic a to 10
put (a-1)/50 into ang
put cos(ang) * 200 into dx
put sin(ang) * 200 into dy
set the loc of graphic a to 300 + dx,300+dy
set the forecolor of graphic a to getred(ang),getgreen(ang),getblue(ang)
if a = 1 then put the forecolor of graphic a
end repeat
unlock screen
end mouseUp

function getred val
if val > PI then put 2*PI - val into val
put abs(val) into val
return round(max(0,(2/3*Pi - val)/(2/3*PI)) * 255)
end getred

function getgreen val
if val > PI then put 2*PI - val into val
put abs(val) into val
return round(max(0,(2/3*Pi - val)/(2/3*PI)) * 255)
end getgreen

function getblue val