第一个效果图:
代码展示:
# coding:utf-8
from turtle import *
import turtle as t
from random import *
def infoPrt():
print('coordinate: ' + str(t.pos()))
print('angle: ' + str(t.heading()))
t.pensize(3)
t.hideturtle()
t.colormode(255)
t.color("black")
t.setup(700, 650)
t.speed(1)
t.st()
#t.dot()
t.pu()
#t.goto(-150,100)
t.goto(-210,86)
t.pd()
infoPrt()
# 头
print('头')
t.seth(85)
t.circle(-100,50)
#t.seth(78)
#t.circle(-100,25)
infoPrt()
t.seth(25)
t.circle(-170,50)
infoPrt()
# 右耳
print('右耳')
t.seth(40)
#t.circle(-250,52)
t.circle(-250,30)
infoPrt()
# 右耳尖
t.begin_fill()
# 左
t.circle(-250,22)
#t.fillcolor("pink")
# 右
t.seth(227)
t.circle(-270, 15)
prePos = t.pos()
infoPrt()
# 下
t.seth(105)
t.circle(100, 32)
t.end_fill()
t.pu()
t.setpos(prePos)
t.pd()
t.seth(212)
t.circle(-270, 28)
prePos = t.pos()
t.pu()
t.goto(t.xcor()+5,t.ycor()-2)
t.pd()
# 躯干
print('躯干')
t.seth(280)
t.circle(500, 30)
infoPrt()
# 臀部
print('臀部')
t.seth(120)
#t.circle(150, -55)
t.circle(150, -11)
p_tail=t.pos()
t.circle(150, -44)
p_butt=t.pos()
infoPrt()
# 尾巴
t.pu()
t.setpos(p_tail)
t.pd()
t.begin_fill()
t.seth(50)
t.fd(25)
t.seth(-50)
t.fd(30)
p_tail1=t.pos
t.seth(-140)
t.fd(36)
t.end_fill()
t.seth(39)
# 右尾和h1
t.fd(72)
# 右尾和v1
t.seth(125)
t.fd(48)
# 右尾和h2
t.seth(40)
t.fd(53)
# 右尾和v2
t.seth(88)
t.fd(45)
# 右尾和h3
t.seth(35)
t.fd(105)
# 右尾和v3
t.seth(105)
t.circle(850, 8)
#t.fd(105)
t.seth(215)
#t.fd(125)
t.circle(850, 11)
t.seth(280)
t.fd(110)
t.seth(220)
t.fd(50)
t.seth(309)
t.fd(56)
# 底盘
print('底盘')
t.pu()
t.setpos(p_butt)
t.pd()
t.seth(20)
t.circle(120, -45)
infoPrt()
t.seth(330)
t.circle(-150, -30)
infoPrt()
prePos = t.pos()
t.pu()
t.goto(t.xcor()+20,t.ycor())
t.pd()
t.seth(230)
t.circle(-70, 120)
p_bot=t.pos()
# 两脚-right
t.pu()
t.setpos(p_butt)
t.setpos(t.xcor()+5,t.ycor()+5)
t.pd()
t.seth(-86)
t.fd(30)
t.seth(-93)
t.fd(33)
t.seth(-225)
t.circle(-150, 22)
# 两脚-left
t.pu()
t.setpos(p_bot)
t.setpos(t.xcor()+85,t.ycor()-43)
t.pd()
t.seth(-105)
t.fd(50)
t.seth(-225)
t.circle(-150, 22)
# 左躯干
print('躯干')
t.pu()
t.setpos(p_bot)
t.pd()
t.seth(90)
t.circle(450, 13)
p_lfhd = t.pos()
t.circle(450, 5)
t.pu()
t.circle(450, 5)
t.pd()
t.circle(450, 6)
infoPrt()
# 左脸
t.begin_fill()
t.fillcolor("pink")
print('左脸')
t.seth(330)
t.circle(50, -90)
infoPrt()
# 左酒窝
t.seth(30)
t.circle(-15, 120)
t.seth(-70)
t.circle(-30, 90)
t.end_fill()
# 左手
t.pu()
t.setpos(p_lfhd)
t.pd()
t.seth(160)
t.circle(150, 30)
infoPrt()
t.seth(180)
t.circle(-30, 150)
t.fd(67)
t.pu()
t.setpos(t.xcor()-40,t.ycor()-60)
t.pd()
t.seth(200)
t.circle(-5, 180)
# 右手
t.pu()
t.setpos(p_lfhd)
t.setpos(t.xcor()+180,t.ycor()+5)
t.pd()
t.seth(200)
t.circle(-50, 100)
t.pu()
t.circle(-50, 15)
t.pd()
t.circle(-50, 65)
t.pu()
t.setpos(t.xcor()+10,t.ycor()-45)
t.pd()
#t.seth(270)
#t.circle(-30, -180)
t.seth(80)
t.fd(10)
t.seth(165)
t.circle(10, 60)
t.seth(90)
t.fd(5)
t.seth(165)
t.circle(10, 60)
t.seth(95)
t.fd(5)
t.seth(185)
t.circle(10, 60)
t.seth(105)
t.fd(10)
t.seth(230)
t.fd(20)
t.seth(145)
t.fd(10)
t.seth(285)
t.fd(20)
# 右酒窝
t.begin_fill()
t.fillcolor("pink")
t.pu()
t.setpos(t.xcor()-40,t.ycor()+110)
t.pd()
t.circle(27, 360)
t.end_fill()
#x-20 ,y+50
"""画嘴"""
color("black", "#F35590")
# 下嘴弧度并填充颜色
penup()
goto(-100, 72)
pendown()
begin_fill()
setheading(260)
forward(60)
circle(-11, 150)
forward(55)
print(position())
penup()
goto(-128.46, 71.97)
pendown()
end_fill()
#嘴中最上方的阴影部分
color("#6A070D", "#6A070D")
begin_fill()
penup()
goto(-99.00, 72.00)
pendown()
penup()
goto(-104.29, 48.3)
pendown()
penup()
goto(-142, 45)
pendown()
penup()
goto(-150.40, 62.74)
pendown()
penup()
goto(-128.46, 71.97)
pendown()
penup()
goto(-99.00, 72.00)
pendown()
end_fill()
#上嘴唇
color("black","#FFD624")
penup()
goto(-168, 65)
pendown()
begin_fill()
setheading(-25)
for i in range(2):
setheading(-25)
circle(35, 70)
end_fill()
#嘴中第二个阴影部分
color("#AB1945", "#AB1945")
penup()
goto(-142, 45)
pendown()
begin_fill()
setheading(40)
circle(-33, 70)
goto(-104,48.3)
penup()
goto(-108,33)
pendown()
setheading(155)
circle(25, 70)
end_fill()
# 左眼
t.pu()
t.color("black")
t.setpos(t.xcor()-40,t.ycor()+90)
t.pd()
t.circle(5)
t.pu()
t.setpos(t.xcor()+5,t.ycor()+10)
t.pd()
t.begin_fill()
t.seth(190)
t.circle(15, 130)
t.seth(310)
t.circle(10, 15)
t.seth(0)
t.circle(17, 133)
t.seth(90)
t.circle(10, 15)
t.end_fill()
t.pu()
t.setpos(t.xcor()+2,t.ycor()-15)
t.pd()
t.color("white")
t.begin_fill()
t.circle(5)
t.end_fill()
# 右眼
t.pu()
t.setpos(t.xcor()+85,t.ycor()+15)
t.pd()
t.color("black")
t.circle(5)
t.pu()
t.setpos(t.xcor()+5,t.ycor()+10)
t.pd()
t.begin_fill()
t.seth(190)
t.circle(20, 130)
t.seth(310)
t.circle(10, 15)
t.seth(0)
t.circle(22, 133)
t.seth(90)
t.circle(13, 15)
t.end_fill()
t.pu()
t.setpos(t.xcor()-7,t.ycor()-15)
t.pd()
t.color("white")
t.begin_fill()
t.circle(7)
t.end_fill()
# 左耳
t.color("black")
t.pu()
t.goto(-210,86)
t.setpos(t.xcor()+15,t.ycor()+38)
t.pd()
t.seth(90)
t.circle(-250,30)
t.begin_fill()
# 左
t.circle(-250,18)
# 右
t.seth(270)
t.circle(-270, 12)
prePos = t.pos()
# 下
t.seth(180)
t.circle(100, 30)
t.end_fill()
t.pu()
t.setpos(prePos)
t.pd()
t.seth(270)
t.circle(-270, 18)
t.screensize(50,50,bg='yellow')
# 输出文字
printer = t.Turtle()
printer.hideturtle()
printer.penup()
printer.goto(-350,-100)
printer.write("皮\n\n",move = True, align="left", font=("楷体", 30, "bold"))
printer.goto(-350,-150)
printer.write("卡\n\n",move = True, align="left", font=("楷体", 30, "bold"))
printer.goto(-350,-200)
printer.write("丘\n\n",move = True, align="left", font=("楷体", 30, "bold"))
printer.goto(-350,-250)
printer.write("!!\n\n",move = True, align="left", font=("楷体", 30, "bold"))
t.hideturtle()
t.done()
第二个效果图:
代码展示:
# -*- coding: UTF-8 -*-
import turtle as t
# 设置背景颜色,窗口位置以及大小
t.colormode(255) # 颜色模式
t.speed(0)
t.screensize(800, 800, "white") # 画布大小背景颜色
t.setup(width=800, height=800, startx=None, starty=None) # 绘图窗口的大小和起始坐标
# t.bgpic("di_2_800.gif")
t.title("逆境清醒皮卡丘!") # 设置绘图窗口的标题
t.resizemode('noresize') # 大小调整模式:auto,user,noresize
t.tracer(1)
t.hideturtle()
def mlingpen(x, y):
t.penup()
t.goto(x, y)
t.pendown()
def mlingpkqface(x, y):
mlingpen(x, y)
t.pensize(3)
t.pencolor("#923E24")
t.fillcolor('#FBD624')
t.begin_fill()
t.seth(40)
t.circle(100, 30)
t.circle(40, 60)
t.right(30)
t.circle(160, 20)
t.seth(-20)
t.circle(300, 30)
t.circle(30, 50)
t.left(85)
t.circle(300, 85)
t.left(1)
t.circle(300, 35)
t.circle(30, 40)
t.seth(40)
t.circle(300, 32)
t.right(150)
t.circle(100, 30)
t.circle(30, 60)
t.left(180)
t.circle(100, 60)
t.right(30)
t.circle(100, 60)
t.circle(70, 120)
t.circle(-120, 80)
t.circle(35, 140)
t.right(60)
t.circle(300, 23)
t.right(60)
t.fd(10)
t.left(90)
t.fd(10)
t.right(60)
t.fd(10)
t.left(90)
t.circle(30, 23)
t.right(60)
t.fd(10)
t.left(90)
t.circle(90, 80)
t.right(170)
t.circle(70, 65)
t.right(20)
t.circle(-150, 20)
t.circle(20, 90)
t.right(200)
t.circle(50, 50)
t.goto(x, y)
t.end_fill()
t.penup()
t.goto(-72, -25)
t.pendown()
t.pencolor("#923E24")
t.fillcolor("#923E24")
t.begin_fill()
t.seth(-6)
t.circle(120, 30)
t.right(160)
t.circle(-50, 65)
t.end_fill()
mlingpen(209.21, 135.02)
t.pensize(3)
t.pencolor("#000000")
t.fillcolor('#000000')
t.seth(145)
t.begin_fill()
t.circle(300, 12)
t.left(50)
t.circle(60, 59)
t.left(88)
t.circle(190, 30)
t.end_fill()
mlingpen(-253.14, -105.48)
t.pensize(3)
t.pencolor("#000000")
t.fillcolor('#000000')
t.seth(40)
t.begin_fill()
t.circle(300, 12)
t.left(50)
t.circle(60, 57)
t.left(88)
t.circle(190, 30)
t.end_fill()
def mlingpkqyingyinying():
t.penup()
t.seth(0)
t.pensize(1)
t.pencolor("#DDA120")
t.fillcolor('#DDA120')
t.begin_fill()
t.left(220)
mlingpen(-179, -90)
t.circle(97, 60)
t.circle(69, 122)
t.circle(-120, 80)
t.circle(33, 135)
t.left(90)
t.circle(-25, 150)
t.left(175)
t.circle(-60, 140)
t.left(175)
t.circle(-60, 100)
t.right(5)
t.circle(85, 60)
t.goto(-179, -90)
t.end_fill()
t.penup()
t.penup()
t.seth(0)
mlingpen(115.87, -170.16)
t.pencolor("#eca9a9")
t.fillcolor('#eca9a9')
t.begin_fill()
t.left(45)
t.circle(300, 20)
t.circle(8, 155)
t.left(3)
t.circle(300, 20)
t.circle(9, 155)
t.goto(115.87, -170.16)
t.end_fill()
t.penup()
def mlingpkqjiao():
mlingpen(-215, -160)
t.pensize(3)
t.pencolor("#FBD624")
t.fillcolor('#FBD624')
t.begin_fill()
t.seth(-30)
t.circle(30, 70)
t.left(20)
t.circle(-50, 150)
t.circle(10, 160)
t.circle(80, 80)
t.left(5)
t.circle(75, 110)
t.goto(-210, -160)
t.penup()
t.end_fill()
mlingpen(-149, -191)
t.pensize(3)
t.pencolor("#923E24")
t.fillcolor('#FBD624')
t.begin_fill()
t.seth(0)
t.left(40)
t.circle(148, 55)
t.right(38)
t.fd(20)
t.left(128)
t.fd(15)
t.right(88)
t.fd(15)
t.left(128)
t.fd(15)
t.right(88)
t.fd(15)
t.left(128)
t.fd(15)
t.right(45)
t.circle(130, 60)
t.circle(23, 75)
t.end_fill()
mlingpen(-149, -180)
t.pensize(3)
t.pencolor("#eca9a9")
t.fillcolor('#eca9a9')
t.begin_fill()
t.seth(0)
t.left(45)
t.circle(148, 45)
t.left(45)
t.circle(15, 110)
t.right(18)
t.circle(130, 40)
t.circle(17, 100)
t.end_fill()
def mlingpkqcap():
mlingpen(-210, 95)
t.pensize(4)
t.pencolor("#000000")
t.fillcolor('#CD0000')
t.begin_fill()
t.seth(290)
t.circle(45, 80)
t.circle(345, 30)
t.circle(45, 90)
t.left(2)
t.fd(120)
t.left(45)
t.circle(200, 60)
t.goto(-210, 95)
t.end_fill()
t.left(175)
t.circle(-290, 50)
t.pencolor("#000000")
t.pensize(3)
t.pencolor("#000000")
t.fillcolor('#ffffff')
mlingpen(-160, 272)
t.begin_fill()
t.goto(-80, 260)
t.goto(-45, 200)
t.left(186)
t.circle(230, 41)
t.goto(-210, 200)
t.goto(-180, 270)
t.goto(-160, 272)
t.end_fill()
mlingpen(-175, 265)
t.seth(0)
t.begin_fill()
t.circle(13)
t.end_fill()
t.penup()
mlingpen(-125, 222)
t.pensize(7)
t.pencolor("#6ba65a")
t.goto(-140, 225)
t.pensize(9)
t.goto(-155, 170)
t.left(45)
t.circle(-130, 30)
t.pensize(3)
mlingpen(-205, 96)
t.pensize(3)
t.pencolor("#ffffff")
t.seth(286)
t.circle(39, 74)
t.left(9)
t.circle(331, 32)
t.circle(45, 80)
t.pensize(3)
def mlingpkqeye():
t.color("#000000", "#702c00")
mlingpen(-110, 24)
t.begin_fill()
t.seth(0)
t.circle(24)
t.end_fill()
mlingpen(-110, 31)
t.color("black", "black")
t.begin_fill()
t.circle(20)
t.end_fill()
t.color("white", "white")
mlingpen(-105, 53)
t.begin_fill()
t.circle(8)
t.end_fill()
t.color("#000000", "#702c00")
mlingpen(0, 62)
t.begin_fill()
t.seth(0)
t.circle(24)
t.end_fill()
mlingpen(2, 70)
t.color("black", "black")
t.begin_fill()
t.circle(20)
t.end_fill()
mlingpen(5, 92)
t.color("white", "white")
t.begin_fill()
t.circle(8)
t.penup()
t.end_fill()
t.hideturtle()
def mlingpkqcheek1():
t.color("#9E4406", "#FE2C21")
t.penup()
t.goto(-130, -50)
t.pendown()
t.begin_fill()
t.setheading(0)
t.circle(27)
t.end_fill()
t.color("#9E4406", "#FE2C21")
t.penup()
mlingpen(53, -20)
t.pendown()
t.begin_fill()
t.setheading(0)
t.circle(27)
t.end_fill()
def mlingweiba(x, y):
mlingpen(x, y)
t.pensize(3)
t.pencolor("#923E24")
t.fillcolor('#CD853F')
t.begin_fill()
t.seth(40)
t.fd(200)
t.seth(-80)
t.fd(150)
t.seth(210)
t.fd(150)
t.left(90)
t.fd(100)
t.right(95)
t.fd(100)
t.left(110)
t.fd(70)
t.right(110)
t.fd(80)
t.left(110)
t.fd(30)
t.right(110)
t.fd(32)
t.right(106)
t.circle(100, 25)
t.right(15)
t.circle(-300, 2)
t.seth(30)
t.fd(40)
t.left(100)
t.fd(70)
t.right(100)
t.fd(80)
t.left(100)
t.fd(46)
t.seth(66)
t.circle(200, 38)
t.right(10)
t.fd(10)
t.end_fill()
mlingpen(202, 250)
t.pensize(3)
t.pencolor("#923E24")
t.fillcolor('#FBD624')
t.begin_fill()
t.seth(220)
t.fd(120)
t.circle(75, 120)
t.left(50)
t.fd(110)
t.end_fill()
def mlingpkqcheek2(x, y, fx):
mlingpen(x, y)
t.seth(fx)
t.pencolor("#840101")
t.fillcolor('#CD0000')
t.begin_fill()
n = 1.8
for i in range(120):
if 0 <= i < 30 or 60 <= i < 90:
n -= 0.05
t.left(3)
t.fd(n)
else:
n += 0.05
t.left(3)
t.fd(n)
t.end_fill()
def mlingpkqmouth():
mlingpen(-60, 20)
t.pensize(3)
t.pencolor("#923E24")
t.seth(-48)
t.begin_fill()
t.circle(15, 110)
t.right(90)
t.circle(15, 110)
t.seth(0)
mlingpen(-50, 45)
t.circle(5, 180)
def mlingpkqshou1():
mlingpen(-130, -30)
t.pensize(3)
t.pencolor("#923E24")
t.fillcolor('#FBD624')
t.seth(100)
t.begin_fill()
t.circle(130, 30)
t.right(100)
t.fd(10)
t.left(90)
t.fd(10)
t.right(60)
t.fd(10)
t.left(90)
t.fd(10)
t.right(30)
t.fd(10)
t.left(90)
t.fd(10)
t.right(30)
t.fd(10)
t.left(90)
t.fd(10)
t.right(50)
t.circle(70, 150)
t.end_fill()
mlingpen(-138, -67)
t.pensize(2)
t.pencolor("#DDA120")
t.fillcolor('#DDA120')
t.left(90)
t.begin_fill()
t.circle(40, 40)
t.left(10)
t.circle(-60, 70)
t.left(40)
t.circle(30, 40)
t.left(83)
t.circle(70, 110)
t.end_fill()
def mlingpkqshou2():
mlingpen(0, -40)
t.pensize(3)
t.pencolor("#923E24")
t.fillcolor('#FBD624')
t.seth(200)
t.begin_fill()
t.circle(55, 90)
t.fd(10)
t.left(90)
t.fd(10)
t.right(60)
t.fd(10)
t.left(90)
t.fd(10)
t.right(90)
t.fd(10)
t.left(90)
t.fd(10)
t.right(60)
t.fd(10)
t.left(90)
t.fd(10)
t.right(50)
t.circle(60, 80)
t.end_fill()
def mlingpkqball():
mlingpen(-30, -250)
t.pensize(3)
t.pencolor("#000000")
t.fillcolor('#CD0000')
t.seth(0)
t.begin_fill()
t.circle(80)
t.end_fill()
mlingpen(-110, -170)
t.seth(-90)
t.pencolor("#000000")
t.fillcolor('#ffffff')
t.begin_fill()
t.circle(80, 180)
t.end_fill()
t.pensize(12)
mlingpen(-105, -170)
t.pencolor("#000000")
t.goto(44, -170)
t.pensize(3)
mlingpen(-4, -170)
t.pencolor("#000000")
t.fillcolor('#000000')
t.begin_fill()
t.circle(28)
t.end_fill()
mlingpen(-11, -170)
t.pencolor("#000000")
t.fillcolor('#ffffff')
t.begin_fill()
t.circle(20)
t.end_fill()
mlingpen(-21, -170)
t.pencolor("#000000")
t.fillcolor('#ffffff')
t.begin_fill()
t.circle(10)
t.end_fill()
def main():
mlingweiba(50, 120)
mlingpkqface(30, 0)
mlingpkqyingyinying()
mlingpkqcap()
mlingpkqcheek2(-140, -10, 300)
mlingpkqcheek2(60, 50, 80)
mlingpkqshou1()
mlingpkqjiao()
mlingpkqball()
mlingpkqshou2()
mlingpkqmouth()
mlingpkqeye()
t.color('#321320')
t.penup()
t.goto(260, -40)
t.pendown()
t.write("愿\n你\n拥\n有\n一\n只\n会\n永\n远\n爱\n你\n的\n皮\n卡\n丘\n", align="center", font=("黑体", 15, "normal"))
t.penup()
t.goto(290, 215)
t.pendown()
t.write("逆\n境\n清\n醒\n", align="center", font=("黑体", 10, "normal"))
if __name__ == '__main__':
main()
t.done()
t.hideturtle()
第三个效果图:
代码展示:
# coding:utf-8
import turtle as t
import time
# 皮卡丘
# 基础设置
t.screensize(800, 600)
t.pensize(2) # 设置画笔的大小
t.speed(10) # 设置画笔速度为10
# 画左偏曲线函数
def radian_left(ang, dis, step, n):
for i in range(n):
dis += step # dis增大step
t.lt(ang) # 向左转ang度
t.fd(dis) # 向前走dis的步长
def radian_right(ang, dis, step, n):
for i in range(n):
dis += step
t.rt(ang) # 向左转ang度
t.fd(dis) # 向前走dis的步长
# 画耳朵
def InitEars():
t.color("black", "yellow")
# 左耳朵曲线
t.pu() # 提笔
t.goto(-50, 100) # 笔头初始位置
t.pd() # 下笔
t.setheading(110) # 画笔角度
t.begin_fill()
radian_left(1.2, 0.4, 0.1, 40)
t.setheading(270) # 画笔角度
radian_left(1.2, 0.4, 0.1, 40)
t.setheading(44) # 画笔角度
t.forward(32)
t.end_fill()
# 右耳朵曲线
t.pu() # 提笔
t.goto(50, 100) # 笔头初始位置
t.pd() # 下笔
t.setheading(70) # 画笔角度
t.begin_fill()
radian_right(1.2, 0.4, 0.1, 40)
t.setheading(270) # 画笔角度
radian_right(1.2, 0.4, 0.1, 40)
t.setheading(136) # 画笔角度
t.forward(32)
t.end_fill()
# 耳朵黑
t.begin_fill()
t.fillcolor("black")
t.pu() # 提笔
t.goto(88, 141) # 笔头初始位置
t.pd() # 下笔
t.setheading(35) # 画笔角度
radian_right(1.2, 1.6, 0.1, 16)
t.setheading(270) # 画笔角度
radian_right(1.2, 0.4, 0.1, 25)
t.setheading(132) # 画笔角度
t.forward(31)
t.end_fill()
t.begin_fill()
t.fillcolor("black")
t.pu() # 提笔
t.goto(-88, 141) # 笔头初始位置
t.pd() # 下笔
t.setheading(145) # 画笔角度
radian_left(1.2, 1.6, 0.1, 16)
t.setheading(270) # 画笔角度
radian_left(1.2, 0.4, 0.1, 25)
t.setheading(48) # 画笔角度
t.forward(31)
t.end_fill()
# 画尾巴
def InitTail():
# 尾巴
t.begin_fill()
t.fillcolor("yellow")
t.pu() # 提笔
t.goto(64, -140) # 笔头初始位置
t.pd() # 下笔
t.setheading(10) # 画笔角度
t.forward(20)
t.setheading(90) # 画笔角度
t.forward(20)
t.setheading(10) # 画笔角度
t.forward(10)
t.setheading(80) # 画笔角度
t.forward(100)
t.setheading(35) # 画笔角度
t.forward(80)
t.setheading(260) # 画笔角度
t.forward(100)
t.setheading(205) # 画笔角度
t.forward(40)
t.setheading(260) # 画笔角度
t.forward(37)
t.setheading(205) # 画笔角度
t.forward(20)
t.setheading(260) # 画笔角度
t.forward(25)
t.setheading(175) # 画笔角度
t.forward(30)
t.setheading(100) # 画笔角度
t.forward(13)
t.end_fill()
# 画脚
def InitFoots():
# 脚
t.begin_fill()
t.fillcolor("yellow")
t.pensize(2)
t.pu() # 提笔
t.goto(-70, -200) # 笔头初始位置
t.pd() # 下笔
t.setheading(225) # 画笔角度
radian_left(0.5, 1.2, 0, 12)
radian_left(35, 0.6, 0, 4)
radian_left(1, 1.2, 0, 18)
t.setheading(160) # 画笔角度
t.forward(13)
t.end_fill()
t.begin_fill()
t.fillcolor("yellow")
t.pensize(2)
t.pu() # 提笔
t.goto(70, -200) # 笔头初始位置
t.pd() # 下笔
t.setheading(315) # 画笔角度
radian_right(0.5, 1.2, 0, 12)
radian_right(35, 0.6, 0, 4)
radian_right(1, 1.2, 0, 18)
t.setheading(20) # 画笔角度
t.forward(13)
t.end_fill()
# 画身体
def InitBody():
# 外形轮廓
t.begin_fill()
t.pu() # 提笔
t.goto(112, 0) # 笔头初始位置
t.pd() # 下笔
t.setheading(90) # 画笔角度
t.circle(112, 180)
t.setheading(250) # 画笔角度
radian_left(1.6, 1.3, 0, 50)
radian_left(0.8, 1.5, 0, 25)
t.setheading(255) # 画笔角度
radian_left(0.4, 1.6, 0.2, 27)
radian_left(2.8, 1, 0, 45)
radian_right(0.9, 1.4, 0, 31)
t.setheading(355) # 画笔角度
radian_right(0.9, 1.4, 0, 31)
radian_left(2.8, 1, 0, 45)
radian_left(0.4, 7.2, -0.2, 27)
t.setheading(10) # 画笔角度
radian_left(0.8, 1.5, 0, 25)
radian_left(1.6, 1.3, 0, 50)
t.end_fill()
def InitEyes():
# 左眼睛
t.begin_fill()
t.fillcolor("black")
t.pu() # 提笔
t.goto(-46, 10) # 笔头初始位置
t.pd() # 下笔
t.setheading(90) # 画笔角度
t.circle(5, 360)
t.end_fill()
# 右眼睛
t.begin_fill()
t.fillcolor("black")
t.pu() # 提笔
t.goto(46, 10) # 笔头初始位置
t.pd() # 下笔
t.setheading(-90) # 画笔角度
t.circle(5, 360)
t.end_fill()
# 画脸
def InitFace():
# 脸蛋
t.begin_fill()
t.fillcolor("red")
t.pu() # 提笔
t.goto(-63, -10) # 笔头初始位置
t.pd() # 下笔
t.setheading(90) # 画笔角度
t.circle(10, 360)
t.end_fill()
t.begin_fill()
t.fillcolor("red")
t.pu() # 提笔
t.goto(63, -10) # 笔头初始位置
t.pd() # 下笔
t.setheading(-90) # 画笔角度
t.circle(10, 360)
t.end_fill()
# 嘴巴
t.pensize(2.2)
t.pu() # 提笔
t.goto(0, 0) # 笔头初始位置
t.pd() # 下笔
t.setheading(235) # 画笔角度
radian_right(5, 0.8, 0, 30)
t.pu() # 提笔
t.goto(0, 0) # 笔头初始位置
t.pd() # 下笔
t.setheading(305) # 画笔角度
radian_left(5, 0.8, 0, 30)
# 画手
def InitHands():
# 左手
t.pensize(2)
t.pu() # 提笔
t.goto(-46, -100) # 笔头初始位置
t.pd() # 下笔
t.setheading(285) # 画笔角度
radian_right(0.4, 1.2, 0, 26)
radian_right(5, 0.35, 0, 26)
radian_right(0.3, 1.2, 0, 15)
# 右手
t.pu() # 提笔
t.goto(46, -100) # 笔头初始位置
t.pd() # 下笔
t.setheading(255) # 画笔角度
radian_left(0.4, 1.2, 0, 26)
radian_left(5, 0.35, 0, 26)
radian_left(0.3, 1.2, 0, 15)
def CloseEyes():
# 左眼睛
t.pu() # 提笔
t.goto(-46, 12) # 笔头初始位置
t.pd() # 下笔
t.setheading(180) # 画笔角度
t.forward(10)
# 右眼睛
t.pu() # 提笔
t.goto(46, 12) # 笔头初始位置
t.pd() # 下笔
t.setheading(0) # 画笔角度
t.forward(10)
# 初始化
def Init():
InitEars()
InitTail()
InitFoots()
InitBody()
InitFace()
InitHands()
InitEyes()
# 眨眼睛
def Upgarde():
InitEars()
InitTail()
InitFoots()
InitBody()
InitFace()
InitHands()
CloseEyes()
def Upgarde_Init():
InitEars()
InitTail()
InitFoots()
InitBody()
InitFace()
InitHands()
InitEyes()
def main():
Init()
t.tracer(False)
# 眨眼睛动画
for i in range(30):
if i % 2 == 0:
t.reset()
t.hideturtle()
Upgarde()
t.update()
time.sleep(0.3)
else:
t.reset()
t.hideturtle()
Upgarde_Init()
t.update()
time.sleep(1)
main()
# 结束画笔
t.done()
第四个效果图:
代码展示:
from turtle import *
'''
绘制皮卡丘头部
'''
def face(x, y):
"""画脸"""
begin_fill()
penup()
goto(x, y)
pendown()
setheading(40)
circle(-150, 69)
fillcolor("#FBD624")
penup()
goto(53.14, 113.29)
pendown()
setheading(300)
circle(-150, 30)
setheading(295)
circle(-140, 20)
print(position())
forward(5)
setheading(260)
circle(-80, 70)
print(position())
penup()
goto(-74.43, -79.09)
pendown()
penup()
goto(-144, 103)
pendown()
setheading(242)
circle(110, 35)
right(10)
forward(10)
setheading(250)
circle(80, 115)
print(position())
penup()
goto(-74.43, -79.09)
pendown()
setheading(10)
penup()
goto(-144, 103)
pendown()
penup()
goto(x, y)
pendown()
end_fill()
penup()
goto(-50, -82.09)
pendown()
pencolor("#DDA120")
fillcolor("#DDA120")
begin_fill()
setheading(-12)
circle(120, 25)
setheading(-145)
forward(30)
setheading(180)
circle(-20, 20)
setheading(143)
forward(30)
end_fill()
def eye():
"""画眼睛"""
color("black", "black")
penup()
goto(-110, 27)
pendown()
begin_fill()
setheading(0)
circle(24)
end_fill()
color("white", "white")
penup()
goto(-105, 51)
pendown()
begin_fill()
setheading(0)
circle(10)
end_fill()
color("black", "black")
penup()
goto(25, 40)
pendown()
begin_fill()
setheading(0)
circle(24)
end_fill()
color("white", "white")
penup()
goto(17, 62)
pendown()
begin_fill()
setheading(0)
circle(10)
end_fill()
def cheek():
"""画脸颊"""
color("#9E4406", "#FE2C21")
penup()
goto(-130, -50)
pendown()
begin_fill()
setheading(0)
circle(27)
end_fill()
color("#9E4406", "#FE2C21")
penup()
goto(53, -20)
pendown()
begin_fill()
setheading(0)
circle(27)
end_fill()
def nose():
"""画鼻子"""
color("black", "black")
penup()
goto(-40, 38)
pendown()
begin_fill()
circle(7, steps=3)
end_fill()
def mouth():
"""画嘴"""
color("black", "#F35590")
penup()
goto(-10, 22)
pendown()
begin_fill()
setheading(260)
forward(60)
circle(-11, 150)
forward(55)
print(position())
penup()
goto(-38.46, 21.97)
pendown()
end_fill()
color("#6A070D", "#6A070D")
begin_fill()
penup()
goto(-10.00, 22.00)
pendown()
penup()
goto(-14.29, -1.7)
pendown()
penup()
goto(-52, -5)
pendown()
penup()
goto(-60.40, 12.74)
pendown()
penup()
goto(-38.46, 21.97)
pendown()
penup()
goto(-10.00, 22.00)
pendown()
end_fill()
color("black", "#FFD624")
penup()
goto(-78, 15)
pendown()
begin_fill()
setheading(-25)
for i in range(2):
setheading(-25)
circle(35, 70)
end_fill()
color("#AB1945", "#AB1945")
penup()
goto(-52, -5)
pendown()
begin_fill()
setheading(40)
circle(-33, 70)
goto(-16, -1.7)
penup()
goto(-18, -17)
pendown()
setheading(155)
circle(25, 70)
end_fill()
def ear():
"""画耳朵"""
color("black", "#FFD624")
penup()
goto(-145, 93)
pendown()
begin_fill()
setheading(165)
circle(-248, 50)
right(120)
circle(-248, 50)
end_fill()
color("black", "black")
penup()
goto(-240, 143)
pendown()
begin_fill()
setheading(107)
circle(-170, 25)
left(80)
circle(229, 15)
left(120)
circle(300, 15)
end_fill()
color("black", "#FFD624")
penup()
goto(30, 136)
pendown()
begin_fill()
setheading(64)
circle(-248, 50)
right(120)
circle(-248, 50)
end_fill()
color("black", "black")
penup()
goto(160, 200)
pendown()
begin_fill()
setheading(52)
circle(170, 25)
left(116)
circle(229, 15)
left(71)
circle(-300, 15)
end_fill()
def setting():
"""设置参数"""
pensize(2)
hideturtle()
speed(10)
def main():
"""主函数"""
setting()
face(-132, 115)
eye()
cheek()
nose()
mouth()
ear()
done()
if __name__ == '__main__':
main()
第五个效果图:
代码展示:
import turtle as t
def nose():
t.penup()
t.seth(90)
t.fd(100)
t.pendown()
t.begin_fill()
t.fillcolor('black')
t.seth(45)
t.fd(25)
t.seth(135)
t.circle(25, 90)
t.seth(315)
t.fd(25)
t.end_fill()
def eyes(seth, fd, c):
t.penup()
t.seth(seth)
t.fd(fd)
t.pendown()
t.begin_fill()
t.fillcolor('black')
t.circle(50)
t.end_fill()
t.penup()
t.circle(50, c)
t.pendown()
t.begin_fill()
t.fillcolor('white')
t.circle(20)
t.end_fill()
def face(seth, fd):
t.penup()
t.seth(seth)
t.fd(fd)
t.pendown()
t.begin_fill()
t.fillcolor('red')
t.circle(70)
t.end_fill()
def lip():
t.penup()
t.seth(135)
t.fd(250)
t.pendown()
t.seth(-300)
t.circle(30, -65)
t.begin_fill()
t.fillcolor('Firebrick')
t.seth(165)
t.fd(140)
t.seth(195)
t.fd(140)
t.seth(-360)
t.circle(30, -65)
t.penup()
t.seth(-60)
t.circle(30, 65)
t.pendown()
t.seth(-70)
t.fd(240)
t.circle(55, 140)
t.seth(70)
t.fd(240)
t.end_fill()
t.seth(-110)
t.fd(80)
t.begin_fill()
t.fillcolor('Firebrick1')
t.seth(120)
t.circle(120, 123)
t.seth(-70)
t.fd(165)
t.circle(55, 140)
t.seth(72)
t.fd(165)
t.end_fill()
def setting():
t.pensize(4)
t.hideturtle()
t.setup(1000, 600)
t.speed(10)
t.screensize(bg='yellow')
def main():
setting()
nose()
eyes(160, 250, 60)
eyes(-9.5, 530, 230)
face(195, 600)
face(-11, 720)
lip()
t.done()
if __name__ == '__main__':
main()