Centered Pentagonal Numbers II
New version with a slighty improve script. This time I typed the correct name :)
Script
#-------------------------------------------------------------------------------------------------
# Basic
# I checked this site for the equation of the pentagon
# https://math.stackexchange.com/questions/41940/is-there-an-equation-to-describe-regular-polygons/41954#41954
#-------------------------------------------------------------------------------------------------
Mod(x, y) = y (x / y - floor(x / y))
f(θ) = cos(π / 5) / cos(Mod(θ, 2π / 5) - π / 5)
cx(r, θ) = -r * sin(θ) f(θ)
cy(r, θ) = r * cos(θ) f(θ)
N = 20
LN = Sequence(0, N)
pV = Zip((5k² + 5k + 2) / 2, k, LN)
pVp = Zip((5(k + 1)² - 5 (k + 1) + 2) / 2 - (5(k)² - 5 (k) + 2) / 2, k, LN)
L_1 = Zip(Curve(cx(k, θ), cy(k, θ), θ, 0, 2 pi), k, LN)
L_2 = Zip(Sequence(C(k), k, 0, 2π, 2π / Element(pVp, val) ), C, L_1, val, LN+1)
#-------------------------
# Add colors
#-------------------------
speed = 1
n = Slider(1, 21, 1, speed, 210, false, true, false, false)
size = 1.2
#-------------------------------------
# Once 'n' and 'size' are defined,
# enter these values in the
# dimensions of the graphics option.
#----------------------------------------------
Execute(Join({"A1=1"}, Sequence("A"+(k+1)+"=A"+k+"+1", k, 1, 20)))
Execute(Sequence("B"+k+" = Element(L_1, "+k+")", k, 1, 21))
Execute(Sequence("C"+k+" = Element(L_2, "+k+")", k, 1, 21))
Execute(Sequence("D"+k+" = A"+k+" / 21", k, 1, 21))
Execute(Sequence("SetConditionToShowObject(B"+k+", "+k+"<=n)", k, 1, 21))
Execute(Sequence("SetConditionToShowObject(C"+k+", "+k+"<=n)", k, 1, 21))
Execute(Sequence("SetDynamicColor(C"+k+", D"+k+", 1, 1)", k, 1, 21))
g(x) = floor(11/20 * (21 - x) - 4/20 * (1 - x))
Execute(Sequence("SetPointSize(C"+k+", g(n))", k, 1, 21))