import turtle
import math
from random import uniform
#准备:
t = turtle.Turtle() #这个变量在定义函数时也可用
t.reset()
t.tracer(0)
x = float(input(\"Please input the X-axis of the graph\"))
y = float(input(\"Please input the Y-axis of the graph\"))
size = float(input(\"Please input the size of this graph\"))
side = math.sqrt(size**2/2.0)
#画圆:
def draw_circle(diameter,x,y,color,fill=\"fill\"):
t.pu()
t.goto(x,y-diameter/2)
t.pd()
t.color(color)
if fill == \"fill\":
t.begin_fill()
t.circle(diameter/2)
if fill == \"fill\":
t.end_fill()
#科赫雪花:
def koch(level,size):
if(level==0):
t.forward(size)
else:
new_size = size/3
koch(level-1,new_size)
t.left(60)
koch(level-1,new_size)
t.right(120)
koch(level-1,new_size)
t.left(60)
koch(level-1,new_size)
#背景:
draw_circle(side,x,y,\"#69D9FF\",\"fill\")
#雪花:
#定义
def draw_snow(size,x,y,color,fill=\"fill\"):
tside = math.sqrt(3)
side = size/4*3/tside*2
t.color(color)
t.pu()
t.goto(x-side/2,y-size/4)
t.pd()
level = 3
if fill == \"fill\" :
t.begin_fill()
for a in range(3):
koch(3,side)
t.rt(120)
if fill == \"fill\" :
t.end_fill()
#绘图
for a in range(70):
x1 = uniform(x-side/2,x+side/2)
y1 = uniform(y-side/2,y+side/2)
side1 = uniform(side/45,side/22.5)
draw_snow(side1,x1,y1,\"white\")
#雪人:
#身体
for a in range(3):
if a == 0: s = side/1.8 ; y2 = y-side/2.4/2
if a == 1: s = side/3 ; y2 = y+side/3./2
if a == 2: s = side/3.6 ; y2 = y+side/1.44/2
draw_circle(s,x,y2,\"white\",\"fill\")
#脸
for a in range(2):
if a == 0: b = -1
else : b = 1
draw_circle(side/30,x+side/12/2*b,y+side/180*145/2,\"black\",\"fill\")
for a in range(2):
if a == 0: color = \"red\" ; y3 = y+side/1.5/2
else : color = \"white\" ; y3 = y+side/1.44/2
draw_circle(side/18,x,y3,color,\"fill\")
#扣子
v = 50
for a in range(5):
draw_circle(side/36,x,y+side/180*v/2,\"black\")
v -= 40
#手
for a in range(2):
if a == 0: b = -1
else : b = 1
t.pu()
t.goto(x+side/4.5/2*b,y+side/2.25/2)
t.pd()
t.color(\"brown\")
t.lt(-140*b)
t.pensize(side/36/2)
t.fd(-side/3/2*b)
t.bk(-side/9/2*b)
t.lt(-60*b)
t.fd(-side/9/2*b)
t.bk(-side/9/2*b)
t.right(-120*b)
t.fd(-side/9/2*b)
t.rt(-80*b)
t.ht()
t.update()