global ToneRANGE -- 256 used i getting color values

global clr -- colorvalues 2D list [][]

 

on Startmovie

 LookupTable()

 pause

end

 

On LookupTable()

 -- clr is a list made up of 3 lists inside it,

 clr = [[],[],[]] -- RGB look-up table list with 256 values for each list 0..256,0..256,0..256

 ToneRANGE = 256 -- 8 bit Max colors value for look-up table */

 

 tone1 = 100-- 7.3 -- 9       -- any number, sets color quality

 tone2 = 25-- 18.9 -- 29       -- any number, sets color quality

 tone3 = 25--9.99  -- 34      -- any number, sets color quality

 --------------------------------------------------------------

 -- nice patterns: 57,11,13;

 --------------------------------------------------------------

 -- do only 256 colors starting at 1

 --------------------------------------------------------------

 repeat with x = 1 to ToneRANGE-1

   clr[1][x] = (ToneRANGE)*abs(sin((tone1* pi())/x/ToneRANGE))

   clr[2][x] = (clr[1][x])*abs(sqrt((tone2* pi())*x/ToneRANGE))

   clr[3][x] = (clr[2][x])*abs(sqrt((tone3* pi())/x/ToneRANGE))

   --  put clr[1][a],clr[2][a], clr[3][a]

 end repeat

 put x,clr[1].count,"lut done"

 ----print onto screen

 ShowColorsOnScreen

 -- draw image with look up table colors

 dotexture

end

 

on ShowColorsOnScreen

 repeat with x = 1 to 800

   repeat with y = 1 to 600

     if x < ToneRANGE then

       c = rgb(clr[1][x],clr[2][x],clr[3][x])

       (the stage).image.setpixel(x,y,c)

     else

       exit repeat

     end if

   end repeat

   updatestage

 end repeat

 put x, c, "showcolors on screen done"

end

 

 

 

on dotexture

 TRange = 123

 midtone = 123

 repeat with x = 1 to 800

   repeat with y = 1 to 600

     sx = sin(((1*pi())*x)/800)

     sy = sin(((20*pi())*y)/600)

     z = (Trange*(sx*sy))  + midtone

     z = max(min(z,256),1)

     --z = abs(integer(z) - 1) -- list value goes from 1 to 256, colors go from 0 to 255

     --  put x,y,z,clr[1][z],clr[2][z],clr[3][z]

     (the stage).image.setpixel(x,y,rgb(clr[1][z],clr[2][z],clr[3][z]))

   end repeat

   updatestage

 end repeat

end

 

on mouseUp me

member(3).image = (the stage).image

duplicate member(3)

end