On Dec 15, 2014, at 11:07 PM, Mike Bonner <bonnm...@gmail.com> wrote:

>I have a chance of understanding) is to determine if an angle falls between
say, red and green, find the ratio of the distances to each, and use that
as a factor of 255 to create the color.


That is exactly what my code is doing. There are several numbers in the code 
that help cheat towards an easy solution. I’ll talk through a few of those 
lines:

   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 

This just gives PI * 100 (roughly) objects spread over a 2*PI range, to draw 
the circle of graphics.

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

120 degrees is 2/3PI. I take the angle we’re at and make it be in the range of 
-PI to +PI, and then take the absolute value of that. I subtract the angle from 
2/3*PI, to find out how far from zero we are. If it’s more than 120 degrees, 
the max(0, takes care of it. The divide by 2/3*PI makes the results be in the 
range 0-1, which gets multiplied by 255.

function getgreen val
   subtract 2/3*PI from 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 get green

I just add 2/3* PI or 4/3*PI to offset the green and blue angles, so that the 
math becomes just the same as it was for red.



_______________________________________________
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode

Reply via email to