PYTHON:turtle函数详解 ,turtle画图完整代码

import turtle as t
import math

#画面的布局
t.screensize(1000,1000,'white')
t.title("龙猫")
t.hideturtle()
t.speed(5)
#t.begin_fill()
#t.fillcolor("red")


#头上的右半圆
t.penup()
t.goto(0,250)
t.pendown()
t.pensize(5)
t.color('black')
t.circle(-250,25)

#右耳朵
t.left(90)
t.forward(20)
t.circle(-100,50)
t.right(90)
t.circle(-100,50)
t.right(10)
t.forward(20)
t.left(108)

#头上的右半圆
t.penup()
t.goto(0,250)
t.pendown()
t.left(25)
t.circle(-250,-25)

#左耳朵
t.left(75)
t.forward(20)
t.circle(100,50)
t.left(90)
t.circle(100,50)
t.left(10)
t.forward(20)

#左半脸
t.right(55)
t.circle(200,45)

#左半身和右半身
t.right(40)
t.circle(186,220)

#右半脸
t.right(27)
t.circle(205,43)

#t.end_fill()
t.right(32)
t.penup()

t.pensize(3)
#两个眼睛
t.goto(115,125)
t.pendown()
t.circle(40)

t.penup()
t.goto(-35,125)
t.pendown()
t.circle(40)

t.begin_fill()
t.fillcolor("black")
t.penup()
t.goto(100,135)
t.pendown()
t.circle(15)
t.end_fill()

t.begin_fill()
t.fillcolor("black")
t.penup()
t.goto(-50,135)
t.pendown()
t.circle(15)
t.end_fill()

t.begin_fill()
t.fillcolor("white")
t.penup()
t.goto(100,135)
t.pendown()
t.circle(5)
t.end_fill()

t.begin_fill()
t.fillcolor("white")
t.penup()
t.goto(-50,135)
t.pendown()
t.circle(5)
t.end_fill()

#鼻子
t.begin_fill()
t.fillcolor("grey")
t.penup()
t.goto(-30,85)
t.pendown()
t.right(65)
t.circle(-80,50)
t.right(130)
t.circle(-80,50)
t.end_fill()

#嘴巴
t.pensize(4)
t.penup()
t.goto(-12,45)
t.pendown()
t.right(130)
t.circle(-40,50)

#肚子

t.pensize(5)
t.color("grey")
t.penup()
t.goto(-175,-40)
t.pendown()
t.left(50)
t.circle(-350,8)
t.color("white")
t.circle(-350,10.5)
t.color("grey")
t.circle(-350,24.5)
t.color("white")
t.circle(-350,10.5)
t.color("grey")
t.circle(-350,7.5)


#左手臂
t.pensize(5)
t.color("green")
t.penup()
t.goto(-135,-10)
t.pendown()
t.right(40)
t.circle(130,35)
t.circle(20,120)
t.left(10)
t.circle(130,35)

#右手臂
t.penup()
t.goto(90,-5)
t.pendown()
t.left(100)
t.circle(130,30)
t.circle(20,120)
t.left(10)
t.circle(130,35)

#右胡子
t.pensize(2)
t.color("black")
t.penup()
t.goto(140,80)
t.pendown()
t.right(35)
t.circle(-200,30)
t.penup()
t.goto(145,70)
t.pendown()
t.circle(-150,30)

#左胡子
t.penup()
t.goto(-140,80)
t.pendown()
t.left(190)
t.circle(200,30)
t.penup()
t.goto(-145,70)
t.pendown()
t.circle(150,30)

#衣服口袋
t.penup()
t.goto(-6,-130)
t.color('red', 'pink')
t.pensize(2)
t.pendown()
t.setheading(150)
t.begin_fill()
t.fd(10)
t.circle(15 * -3.745, 45)
t.circle(15 * -1.431, 165)
t.left(120)
t.circle(15 * -1.431, 165)
t.circle(15 * -3.745, 45)
t.fd(15)
t.end_fill()

#耳朵的装饰
t.penup()
t.goto(110,220)
t.begin_fill()
t.setheading(270)
for i in range(4):
    t.pendown()
    t.circle(15,180)
    t.penup()
    t.setheading(i*90)
t.end_fill()
t.penup()
t.goto(117,235)
t.pencolor("yellow")
t.pensize(2)
t.pendown()
t.begin_fill()
t.fillcolor("yellow")
t.circle(7)
t.end_fill()

t.done()

在 import turtle as t 的条件下

抬笔t.penup()
落笔t.pendown()
画笔角度t.setheading(角度)
画笔颜色t.pencolor(颜色)
画笔粗细t.pensize(像素)
画布设置t.screensize(长,宽,'颜色')
隐藏画笔t.hideturtle()
显示画笔t.showturtle()
画画速度t.speed(速度)
画笔左转t.left(角度)
画笔右转t.right(角度)
画笔去处t.goto(x,y)
开始填充颜色t.begin_fill()
结束填充颜色t.end_fill()
填充颜色t.fillcolor("颜色")
画作的主题t.title("名称")
画笔的速度0~10,0最快
画圆t.circle(半径,角度)
清除内容(不改笔参数)t.clear()
清除内容(参数置为初始值)t.reset()
设置笔的位置t.setpos(x,y)
画点t.dot(像素)
结束运行t.down()

一定要有t.down()不然会死机!!!

  • 7
    点赞
  • 35
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值