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