Dot fever: Improved script
GGB script
#=====================================
# Improved script thanks to Thijs :)
#=====================================
N = 8
#=====================================
# Create list with names of Circles
#=====================================
Lk = Sequence(2 * N)
Lij = Flatten(Zip(Zip((m, n), n, Lk), m, Lk))
Lname = Zip("circleX"+Text(x(ij))+"Y"+Text(y(ij)), ij, Lij)
#===============================================
# Create list with Centers of Circles and the index of each circle
#===============================================
Lp = Sequence(-N, N - 1)
LC = Flatten(Zip(Zip((u,v), v, Lp), u, Lp))
LI = Zip(IndexOf(P, LC ), P, LC)
#=====================================
# Create t slider for animation
#=====================================
speed = 1
t = Slider(0, 2 pi, 0.01, speed, 170, false, true, false, false)
#============================================
# Functions: Some are auxiliary to define the behaviour
# of the circles.
# The main function is "f" where the variable "z" is for
# the index of the circle.
#============================================
r(x) = abs( 2 / (1+exp(-x)) - 1 )
hypot(x, y) = sqrt(x^2 + y^2)
modf(x, y) = y * (x / y - floor(x / y))
f(x, y, z) = 6 - hypot(x-0, y-0) - sin(z/3-t)
CR(x, y, z) = If(f(x, y, z) < 0, 0, 1)
CG(x, y, z) = If(f(x, y, z) < 0,102/255, 1)
CB(x, y, z) = If(f(x, y, z) < 0,153/255, 1)
R(x, y, z) = r(f(x, y, z)) / 2
#=====================================
# Create Circles with colors
#=====================================
Execute(Zip(name" = Circle( "+C+", R(x("+C+"), y("+C+"), "+In+") )", name, Lname, C, LC, In, LI))
Execute(Zip("ShowLabel("+name+", false)", name, Lname))
Execute(Zip("SetDynamicColor("+name+", CR(x("+C+"), y("+C+"), "+In+"), CG(x("+C+"), y("+C+"), "+In+"), CB(x("+C+"), y("+C+"), "+In+"), 1)", name, Lname, C, LC, In, LI))
Execute(Zip("SetLineThickness("+name+", 1)", name, Lname))
#=====================================
# Settings: Let's make it pretty :)
#=====================================
SetActiveView(1)
CenterView((-1/2, -1/2))
ZoomIn( (x(Corner(3))-x(Corner(1))) / (2N +3) )
SetVisibleInView(Lij, 1, false)
SetVisibleInView(LC, 1, false)
SetVisibleInView(Lname, 1, false)
SetVisibleInView(r, 1, false)
SetBackgroundColor(Black)
ShowAxes(false)
ShowGrid(false)
SetColor(t, Black)
ShowLabel(t, false)
StartAnimation(t, true)
SetVisibleInView(t, 1, false)
SetVisibleInView(button1, 1, true)
#=====================================
# That's it. Enjoy! :)
#=====================================