-- Lindsay Orndorff Art Studio 122
-- Exploration of the fibonacci series
--*********************************************************************
global ToneRANGE -- 256 used i getting color values
global clr -- colorvalues 2D list [][]
on Startmovie
LookupTable()
pause
end
On LookupTable()
-- Used same look-up table as code already given
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 = 0.8 --10.5 --0.5 --0.5 --0.5 -- any number, sets color quality
tone2 = 2.5 --10.5 --10.5 --10.5--0.5 -- any number, sets color quality
tone3 = 5.8 --10.5 --0.5--10.5 --10.6 -- any number, sets color quality
--------------------------------------------------------------
-- do only 256 colors starting at 1
--------------------------------------------------------------
repeat with x = 1 to ToneRANGE
-- change values to get different sets of colors (good arrangement sin, cos, tan)
clr[1][x] = (ToneRANGE)*abs(sin((tone1* pi())*x/ToneRANGE))
clr[2][x] = (clr[1][x])*abs(sin((tone2* pi())*x/ToneRANGE))
clr[3][x] = (clr[2][x])*abs(sin((tone3* pi())*x/ToneRANGE))
-- put clr[1][a],clr[2][a], clr[3][a]
end repeat
-- draw image with look up table colors
dotexture
end
---------------------------------------------------
-- draw image with colors
---------------------------------------------------
on dotexture
--parameters of what can be modified to alter image states
TRange = 96 -- 128
midtone = 196 -- 128 default
fibStartValue = 1 -- first fib number value 1
fibSecondValue = 5 -- change number according to fibonacci series (ie 1,2,3,5,8...)
num = 10 --size of basic unit
xScale = 1 -- 0 - 1
yScale = 1 -- 0 - 1
xDistortValue = -1 -- value or -1 to set to divval
yDistortValue = -1 -- value or -1 to set to divval
xShift = 1 -- any value; shifts x left or right
yShift = -1 -- any value; shifts y up or down
CustomDivVal = 600
--------------------------------------------------------------------------
xDistort = 1 -- 0 or 1
yDistort = 1 -- 0 or 1
div = 0 -- 0 or 1 or 2 = CustomDivVal
customColor = 0 -- 0 or 1
--end parameters
--calculate the value of the numth fib number
fibn = 0
f1 = fibStartValue
f2 = fibSecondValue
repeat with i = 1 to num
temp = f2
f2= f1 + f2
f1 = temp
if i = num then
fibn = f2
end if
end repeat
f1 = fibStartValue
f2 = f1 + 1
repeat with x = 1 to 800
if div = 1 then
divval = f2
end if
if div = 0 then
divval = f1
end if
if div = 2 then
divval = CustomDivVal
end if
if x mod (800 / divval)= 0 then
temp = f2
f2= f1 + f2
f1 = temp
end if
repeat with y = 1 to 600
-- controls the appearance of the image
xfunc = sin(tan(pi() * f2/fibn * x *xScale +xShift))
yfunc = cos(tan(pi() * f2/fibn * y *yScale +yShift))
if yDistortValue < 0 then
yDistortValue = divval
end if
if xDistortValue <0 then
xDistortValue = divval
end if
if yDistort = 1 then
yfunc = yfunc * x/(800/yDistortValue)
end if
if xDistort = 1 then
xFunc = xfunc * y/(600/xDistortValue)
end if
sx = sin(xfunc)
sy = sin(yfunc)
z = (Trange*(sx*sy)) + midtone
z = max(min(z,256),1)
if customColor = 1 then
(the stage).image.setpixel(x,y,rgb(z,z,z))
else
(the stage).image.setpixel(x,y,rgb(clr[1][z],clr[2][z],clr[3][z]))
end if
end repeat
updatestage
end repeat
end
---------------------------------------------------
-- save image to cast library by clicking on it when finished
---------------------------------------------------
on mouseUp me
member(2).image = (the stage).image
duplicate member(2)
end