1.源代码
import turtle # 设置画笔 t = turtle.Pen() t.pensize(5) t.speed(10) # 画头部 t.fillcolor('pink') t.begin_fill() t.circle(100) t.end_fill() # 画眼睛 t.penup() t.goto(-40, 120) t.pendown() t.fillcolor('white') t.begin_fill() t.circle(20) t.end_fill() t.penup() t.goto(-40, 130) t.pendown() t.fillcolor('black') t.begin_fill() t.circle(10) t.end_fill() t.penup() t.goto(40, 120) t.pendown() t.fillcolor('white') t.begin_fill() t.circle(20) t.end_fill() t.penup() t.goto(40, 130) t.pendown() t.fillcolor('black') t.begin_fill() t.circle(10) t.end_fill() # 画鼻子 t.penup() t.goto(0, 80) t.pendown() t.fillcolor('red') t.begin_fill() t.circle(30) t.end_fill() # 画嘴巴 t.penup() t.goto(-60, 50) t.pendown() t.right(45) t.circle(80, 90) # 画身体 t.penup() t.goto(-100, -50) t.pendown() t.fillcolor('pink') t.begin_fill() for i in range(2): t.forward(200) t.circle(50, 180) t.end_fill() # 画手臂 def draw_arm(x, y): t.penup() t.goto(x, y) t.pendown() t.right(45) t.forward(100) t.right(90) t.forward(50) t.right(180) t.circle(-50, 90) t.right(180) t.forward(50) draw_arm(-150, -50) draw_arm(50, -50) # 画腿 t.penup() t.goto(-70, -200) t.pendown() t.fillcolor('white') t.begin_fill() t.right(45) t.forward(100) t.right(180) t.circle(-50, 90) t.right(180) t.forward(100) t.end_fill() t.penup() t.goto(70, -200) t.pendown() t.fillcolor('white') t.begin_fill() t.right(45) t.forward(100) t.right(180) t.circle(-50, 90) t.right(180) t.forward(100) t.end_fill() # 隐藏画笔 t.hideturtle() # 等待用户关闭窗口 turtle.done()
python画猪猪侠
最新推荐文章于 2024-02-28 10:54:03 发布