/
recCircle.py
55 lines (51 loc) · 1.4 KB
/
recCircle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import turtle
'''
filename: recCircle.py
language: python3
author: Alex Habermann hehe3301@gmail.com
purpose: This program draws recursive circles with one circle at each four vertexs of the circle
'''
def ready(rad):
turtle.speed(0)
turtle.ht()
turtle.up()
turtle.goto(0,-rad)
turtle.down()
turtle.colormode(1)
turtle.bgcolor('black')
turtle.pensize(1.1)
def drawcircle(depth,rad,maxdepth):
if depth == 0:
pass
else:
colorset(depth,maxdepth)
turtle.circle(rad,90)
drawcircle(depth-1,41.4*rad/100,maxdepth)
colorset(depth,maxdepth)
turtle.circle(rad,90)
drawcircle(depth-1,41.4*rad/100,maxdepth)
colorset(depth,maxdepth)
turtle.circle(rad,90)
drawcircle(depth-1,41.4*rad/100,maxdepth)
colorset(depth,maxdepth)
turtle.circle(rad,90)
drawcircle(depth-1,41*rad/100,maxdepth)
colorset(depth,maxdepth)
def colorset(depth,maxdepth):
x,y=turtle.pos()
R=((depth-1)/maxdepth)
G=(x*x + y*y)/(300*300)
B=((maxdepth-depth+1)/maxdepth)
turtle.pencolor((R,G,B))
def main():
rad=250
depth=6
# rad=int(input('What max radius do you want to use? '))
# depth=int(input('What depth do you want to draw? '))
ready(rad)
drawcircle(depth,rad,depth)
turtle.up()
turtle.goto(-250,-250)
turtle.down()
turtle.write('Alex Habermann')
main()