Rephrase spirograph code into function Rephrase spirograph code into function tkinter tkinter

Rephrase spirograph code into function


Your error is in

 for n in range(arms):        point = tuple(map(sum,zip(rotate((0, lenlist[n]), rotations[n], pointlist[n]))))        pointlist.append(point)

Specifically,

rotate((0, lenlist[n])

replace it with

 for n in range(arms):        point = tuple(map(sum,zip(rotate((pointlist[n][0], lenlist[n]), rotations[n], pointlist[n]))))        pointlist.append(point)

You go against the usual mathematical notation for polars (circular graphs) and that caused your confusion and eventual issues. As far as I can tell your function is plotting an (X,Y) point (0,length) and then finding the difference between that point and the center point (which is correctly defined as the last point you found) and rotating it around that center. The issue is that (0,length) is not 'length' away from the center. By replacing the (0,lenlist[n]) with (pointlist[n][0],lenlist[n]) makes the next point based upon the last point.

Also I would recommend editing your rotate function to be rotate(length,angle,centerpoint) which would simplify the inputs to a more traditional representation.