Welcome to Code Sharer, a code gallery for creating, saving and sharing all kinds of code snippets.

Python — Simple Spirograph

Posted On: Sunday, June 24, 2018 at 1:37 PM

Simple code to draw Spirographs by repeating circles.
import turtle
import math
import random
wn = turtle.Screen()
wn.bgcolor('black')
Albert = turtle.Turtle()
Albert.speed(0)
Albert.color('white')
rotate=int(360)
def drawCircles(t,size):
for i in range(10):
t.circle(size)
size=size-4
def drawSpecial(t,size,repeat):
for i in range (repeat):
drawCircles(t,size)
t.right(600/repeat)
drawSpecial(Albert,50,10)
S = turtle.Turtle()
S.speed(0)
S.color('yellow')
rotate=int(30)
def drawCircles(t,size):
for i in range(4):
t.circle(size)
size=size-10
def drawSpecial(t,size,repeat):
for i in range (repeat):
drawCircles(t,size)
t.right(700/repeat)
drawSpecial(S,100,10)
B = turtle.Turtle()
B.speed(0)
B.color('blue')
rotate=int(80)
def drawCircles(t,size):
for i in range(4):
t.circle(size)
size=size-5
def drawSpecial(t,size,repeat):
for i in range (repeat):
drawCircles(t,size)
t.right(360/repeat)
drawSpecial(B,100,10)
C = turtle.Turtle()
C.speed(0)
C.color('orange')
rotate=int(90)
def drawCircles(t,size):
for i in range(4):
t.circle(size)
size=size-19
def drawSpecial(t,size,repeat):
for i in range (repeat):
drawCircles(t,size)
t.right(700/repeat)
drawSpecial(C,100,10)
D = turtle.Turtle()
D.speed(0)
D.color('purple')
rotate=int(90)
def drawCircles(t,size):
for i in range(4):
t.circle(size)
size=size-20
def drawSpecial(t,size,repeat):
for i in range (repeat):
drawCircles(t,size)
t.right(700/repeat)
drawSpecial(D,120,10)

Ryan Bradley-Evans (Admin)

Joined on
Contributed 22 Snips

Get Social and Share

Tags