Python画动漫海贼王
代码实现如下:
import turtle as t
“”” t.hideturtle()
t.bgcolor(‘white’) “””
t.setup(800,500) # 创建画布并使其位于屏幕中心
t.pensize(2) # 画笔粗细
t.colormode(255) # 色彩模式
t.speed(10) # 绘画速度
t.color(‘black’,(255,228,181)) # 画笔颜色与填充色
t.shape(‘turtle’) # 画笔的形状
t.speed(10) #画笔速度
t.showturtle() # 使画笔显现
移动画笔
def move(x, y, angle):
t.pu()
t.goto(x, y)
t.seth(angle)
t.pd()
画圆填充颜色
def draw_circle(x, y, r, color):
t.color(color)
t.pu()
t.goto(x, y)
t.seth(-90)
t.fd(r)
t.seth(0)
t.pd
t.begin_fill()
t.circle(r)
t.end_fill()
pass
画圆不填充颜色
def draw_circle_normal(x, y, r):
t.pu()
t.goto(x, y)
t.seth(-90)
t.fd(r)
t.seth(0)
t.pd()
t.circle(r)
pass
画脸
def draw_face():
t.color(‘black’, ‘white’)
move(0, -103, 0)
t.begin_fill()
t.circle(103, 90)
t.seth(180)
t.fd(103*2)
t.seth(-90)
t.circle(103, 90)
t.end_fill()
pass
画眼睛、鼻子
def draw_eyes():
t.color(‘black’)
move(-40, 0, 180)
t.begin_fill()
t.circle(30)
t.end_fill()
move(40, 0, 180)
t.begin_fill()
t.circle(30)
t.end_fill()
move(0, -61, 180)
t.begin_fill()
t.circle(13)
t.end_fill()
画帽子
def draw_hat():
t.color(‘black’, ‘#fcd462’)
move(0, 0, 0)
t.begin_fill()
t.fd(175)
t.circle(15, 180)
t.fd(175*2)
t.circle(15, 180)
t.fd(175)
t.end_fill()
pass
move(0, 0, 17)
t.color(‘#fcd462’)
t.pu()
t.fd(103)
p1 = t.position()
t.left(90)
t.pd()
t.begin_fill()
t.circle(103, 147)
t.seth(0)
p2 = t.position()
t.goto(p1)
t.end_fill()
pass
t.color(‘#fe0202’)
t.seth(107)
t.begin_fill()
t.circle(103, 15)
p3 = t.position()
t.pu()
t.right(180)
t.circle(-103, 15)
t.seth(180)
t.pd()
t.goto(p2)
t.seth(77)
t.circle(-103, 15)
t.goto(p3)
t.end_fill()
pass
画嘴巴
def draw_mouth():
move(0, -90, 180)
t.color(‘black’, ‘white’)
t.begin_fill()
t.circle(50)
t.end_fill()
pass
draw_circle_normal(0, 0, 160)
draw_circle_normal(0, 0, 130)
move(0,-103,-90)
t.fd(57)
p4=t.position()
t.seth(0)
t.pu()
t.circle(160,10)
t.seth(100)
t.pd()
t.fd(57)
t.pu()
t.goto(p4)
t.seth(180)
t.pd()
t.circle(-160,10)
t.seth(80)
t.fd(57)
pass
画骨头十字架
def draw_bone():
t.color(‘black’,’white’)
move(-132,155,-42)
t.fd(404)
t.left(90)
t.circle(-20,270)
t.right(180)
t.circle(-20,270)
t.seth(138)
t.fd(404)
t.left(90)
t.circle(-20,270)
t.left(180)
t.circle(-20,270)
pass
move(-132,-155,48)
t.fd(404)
t.right(90)
t.circle(20,270)
t.right(180)
t.circle(20,270)
t.seth(228)
t.fd(404)
t.right(90)
t.circle(20,270)
t.left(180)
t.circle(20,270)
pass
t.pensize(5)
draw_bone()
t.pensize(2)
draw_circle(0,0,160,’black’)
draw_mouth()
draw_face()
draw_eyes()
draw_hat()
t.done()
安卓学习教程公众号


祝你事业顺心,富贵吉祥,赞赏鼓励