from sympy import *
from spb import *
import param
a, b, c, d, e, f, theta, tp = symbols("a:f theta tp")
def func(n):
    t1 = (c + sin(a * theta + d))
    t2 = ((b + sin(b * theta + e)) - (c + sin(a * theta + d)))
    t3 = (f + sin(a * theta + n / pi))
    return t1 + t2 * t3 / 2
params = {
    a: param.Integer(6, label="a"),
    b: param.Integer(12, label="b"),
    c: param.Integer(18, label="c"),
    d: (4.7, 0, 2*pi),
    e: (1.8, 0, 2*pi),
    f: (3, 0, 5),
    tp: (2, 0, 2)
}
series = []
for n in range(20):
    series += line_polar(
        func(n), prange(theta, 0, tp*pi), params=params,
        rendering_kw={"line_color": "black", "line_width": 0.5})
graphics(
    *series,
    aspect="equal",
    layout = "sbl",
    ncols = 1,
    title="Guilloché Pattern Explorer",
    backend=BB,
    legend=False,
    servable=True,
    imodule="panel"
)