#coding=utf8
import turtle
import turtle as t # 导入turtle赋值给t
turtle.tracer(False)
t.speed(10) #笔画绘制的速度
t.pensize(2) # 笔的尺寸
t.hideturtle() #隐藏图标
#参数分别为画布 的宽(单位像素), 高, 背景颜色
t.screensize(500, 500, bg="white")
# 参数:width, height: 输入宽和高为整数时, 表示像素; 为小数时, 表示占据电脑屏幕的比例,
# (startx, starty): 这一坐标表示矩形窗口左上角顶点的位置, 如果为空,则窗口位于屏幕中心。
t.setup(width=0.5, height=0.75, startx=None, starty=None)
# 猫脸头的大圆
t.fillcolor('DodgerBlue') #填充颜色,蓝色(道奇蓝)
t.begin_fill() #开始填充
t.circle(120) #绘制半径为120的图形
t.end_fill() #结束填充
# 猫脸头里面的小圆
t.pensize(3) # 笔的尺寸
t.fillcolor('white') #填充颜色,白色
t.begin_fill() #开始填充
t.circle(100) #绘制半径为100的图形
t.end_fill() #结束填充
#鼻子
t.pu() #笔画抬起,笔头移动,不划线
t.home() #回家
t.goto(0, 134) #移动到(0, 134)坐标位置
t.pd() #绘制图形
t.pensize(4)
t.fillcolor("red")
t.begin_fill()
t.circle(18)
t.end_fill()
#鼻子里面的高光白点
t.pu()
t.goto(7, 155)
t.pensize(2)
t.color('white','white') #圈的颜色和填充的颜色
t.pd()
t.begin_fill()
t.circle(4)
t.end_fill()
# 左眼
t.pu()
t.goto(-30, 160)
t.pensize(4)
t.pd()
t.color('black','white') #圈的颜色和填充的颜色
t.begin_fill()
a = 0.4
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
a = a+0.08
t.lt(3) #向左转3度
t.fd(a) #向前走a的步长
else:
a = a-0.08
t.lt(3)
t.fd(a)
t.end_fill()
t.pu()
t.goto(30, 160)
t.pensize(4)
t.pd()
t.color('black', 'white')
t.begin_fill()
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
a = a+0.08
t.lt(3) # 向左转3度
t.fd(a) # 向前走a的步长
else:
a = a-0.08
t.lt(3)
t.fd(a)
t.end_fill()
t.pu()
t.goto(-38,190)
t.pensize(8)
t.pd()
t.right(-30)
t.forward(15)
t.right(70)
t.forward(15)
# 右眼里的眼球
t.pu()
t.goto(15, 185)
t.pensize(4)
t.pd()
t.color('black', 'black')
t.begin_fill()
t.circle(13)
t.end_fill()
# 右眼里的眼球里的高光
t.pu()
t.goto(13, 190)
t.pensize(2)
t.pd()
t.color('white', 'white')
t.begin_fill()
t.circle(5)
t.end_fill()
# 鼻子下方的竖线
t.pu()
t.home()
t.goto(0, 134)
t.pensize(4)
t.pencolor('black') #笔画颜色
t.pd()
t.right(90)
t.forward(40)
# 右边的第一根胡子
t.pu()
t.home()
t.goto(0, 124)
t.pensize(3)
t.pencolor('black') #笔画颜色
t.pd()
t.left(10)
t.forward(80)
# 右边的第二根胡子
t.pu()
t.home()
t.goto(0, 114)
t.pensize(3)
t.pencolor('black') #笔画颜色
t.pd()
t.left(6)
t.forward(80)
# 右边的第三根胡子
t.pu()
t.home()
t.goto(0,104)
t.pensize(3)
t.pencolor('black') #笔画颜色
t.pd()
t.left(0)
t.forward(80)
# 左边的第一根胡子
t.pu()
t.home()
t.goto(0,124)
t.pensize(3)
t.pencolor('black') #笔画颜色
t.pd()
t.left(170)
t.forward(80)
# 左边的第二根胡子
t.pu()
t.home()
t.goto(0, 114)
t.pensize(3)
t.pencolor('black') #笔画颜色
t.pd()
t.left(174)
t.forward(80)
# 左边的第三根胡子
t.pu()
t.home()
t.goto(0, 104)
t.pensize(3)
t.pencolor('black') #笔画颜色
t.pd()
t.left(180)
t.forward(80)
# 嘴巴
t.pu()
t.goto(-70, 70)
t.pd()
t.color('black', 'red')
t.pensize(6)
t.seth(-60) #前进方向为to_angle,角度是绝对方向的角度值
t.begin_fill()
t.circle(80,40)
t.circle(80,80)
t.end_fill()
t.pu()
t.home()
t.goto(-80,70)
t.pd()
t.forward(160)
# 舌头
t.pu()
t.home()
t.goto(-50,50)
t.pd()
t.pensize(1)
t.fillcolor("#eb6e1a")
t.seth(40)
t.begin_fill()
t.circle(-40, 40)
t.circle(-40, 40)
t.seth(40)
t.circle(-40, 40)
t.circle(-40, 40)
t.seth(220)
t.circle(-80, 40)
t.circle(-80, 40)
t.end_fill()
# 领带项圈颜色
t.pu()
t.goto(-70, 12)
t.pensize(14)
t.pencolor('red')
t.pd()
t.seth(-20)
t.circle(200, 30)
t.circle(200, 10)
# 铃铛
t.pu()
t.goto(0, -46)
t.pd()
t.pensize(3)
t.color("black", '#f8d102')
t.begin_fill()
t.circle(25)
t.end_fill()
t.pu()
t.goto(-5, -40)
t.pd()
t.pensize(2)
t.color("black", '#79675d')
t.begin_fill()
t.circle(5)
t.end_fill()
t.pensize(3)
t.right(115)
t.forward(7)
t.mainloop()
turtle.done()
得到图形: