画企鹅,源码来自b站某up

import turtle as t


def draw():
	t.screensize(canvwidth=600,canvheight=600,bg="white")
	t.pensize(5) # 设置画笔的大小
	t.colormode(255) # 设置颜色范围为0-255
	t.speed(10) # 设置画笔速度为10

	#左脚
	t.color("#FFA500","orange")# 设置画笔颜色和填充颜色
	t.penup() # 提笔
	t.goto(-23,-295)# 左脚
	t.seth(185)
	t.pendown()# 落笔
	t.begin_fill()
	for d in range(60):
	    if 0<=d<50:
	        t.rt(0.2) #向右转0.2度
	        t.fd(1.5)  #向前走的步长
	    else:
	        t.rt(15)
	        t.fd(1.2)
	for d in range(60):
	    if 0<=d<60:
	        t.rt(0.2) #向右转0.2度
	        t.fd(0.5)  #向前走的步长
	t.goto(-23,-295)
	t.end_fill()

	#右脚
	t.color("#FFA500","orange")# 设置画笔颜色和填充颜色
	t.penup() # 提笔
	t.goto(27,-295)# 右脚
	t.seth(355)
	t.pendown()# 落笔
	t.begin_fill()
	for d in range(60):
	    if 0<=d<50:
	        t.lt(0.2) #向右转0.2度
	        t.fd(1.5)  #向前走的步长
	    else:
	        t.lt(15)
	        t.fd(1.2)
	for d in range(60):
	    if 0<=d<60:
	        t.lt(0.2) #向右转0.2度
	        t.fd(0.5)  #向前走的步长
	t.goto(27,-295)
	t.end_fill()

	#企鹅下体
	t.color("#FF0000","red")# 设置画笔颜色和填充颜色
	t.penup() # 提笔
	t.goto(-150,0)# 围巾左上角
	t.seth(255)
	t.pendown()# 落笔
	t.begin_fill()
	t.fd(60)
	t.color("#000000","black")# 设置画笔颜色和填充颜色
	t.fd(30)
	for c in range(60):
	    if 0<=c<50:
	        t.lt(0.2) #向左转0.2度
	        t.fd(2) #向前走的步长
	    else:
	        t.lt(13)
	        t.fd(1)
	for c in range(60):
	    if 0<=c<60:
	         t.lt(0.5)
	         t.fd(1) #向前走的步长
	t.seth(-90)
	t.circle(150,90)
	t.seth(0)
	t.circle(150,90)
	t.seth(295)
	for c in range(60):
	    if 0<=c<60:
	         t.lt(0.5)
	         t.fd(1) #向前走的步长
	for c in range(60):
	    if 0<=c<10:
	        t.lt(13)
	        t.fd(1)
	    else:
	        t.lt(0.2) #向左转0.2度
	        t.fd(2) #向前走的步长
	t.fd(23)
	#t.penup()
	t.goto(120,-75)
	t.seth(270)
	t.fd(80)
	t.circle(-120,180)
	t.seth(-270)
	t.fd(83)
	t.goto(-168,-63)
	t.end_fill()

	#围巾
	t.color("#FF0000","red") # 设置画笔颜色和填充颜色
	t.penup() # 提笔
	t.seth(0)
	t.goto(-150,0)# 围巾左上角
	t.pendown()# 落笔
	t.begin_fill()
	t.right(15)
	t.circle(600,30)
	t.right(90)
	t.forward(60)
	t.right(90)
	t.circle(-660,30)
	t.goto(-150,0)
	t.end_fill() # 依据轮廓填充
	t.penup() # 提笔
	t.goto(-30,-80)
	t.pendown()# 落笔
	t.begin_fill()
	t.seth(-90)
	t.forward(80)
	t.seth(-182)
	t.forward(60)
	t.seth(90)
	t.forward(90)
	t.end_fill()

	#头
	t.color("#000000","black")# 设置画笔颜色和填充颜色
	t.penup() # 提笔
	t.goto(-150,0)
	t.pendown()# 落笔
	t.begin_fill()
	t.forward(30)
	for a in range(88):
	    t.forward(5.4)
	    t.right(2)
	t.goto(160,0)
	t.penup() # 提笔
	t.goto(-150,1)
	t.pendown()# 落笔
	t.seth(360)
	t.right(15)
	t.circle(600,30)
	t.end_fill()

	#左眼睛
	t.color("#FFFFFF","white")# 设置画笔颜色和填充颜色
	t.penup() # 提笔
	t.goto(-40,60)
	t.pendown()# 落笔
	t.begin_fill()
	t.seth(360)
	c=0.4
	for b in range(120):
	   if 0<=b<30 or 60<=b<90:
	       c=c+0.08
	       t.lt(3) #向左转3度
	       t.fd(c) #向前走的步长
	   else:
	       c=c-0.08
	       t.lt(3)
	       t.fd(c)
	t.end_fill()
	t.color("#000000","black")# 设置画笔颜色和填充颜色
	t.penup() # 提笔
	t.goto(-33,80)
	t.pendown()# 落笔
	t.begin_fill()
	c=0.2
	for b in range(120):
	   if 0<=b<30 or 60<=b<90:
	       c=c+0.02
	       t.lt(3) #向左转3度
	       t.fd(c) #向前走的步长
	   else:
	       c=c-0.02
	       t.lt(3)
	       t.fd(c)
	t.end_fill()

	#右眼睛
	t.color("#FFFFFF","white")# 设置画笔颜色和填充颜色
	t.penup() # 提笔
	t.goto(40,60)
	t.pendown()# 落笔
	t.begin_fill()
	t.seth(360)
	c=0.4
	for b in range(120):
	   if 0<=b<30 or 60<=b<90:
	       c=c+0.08
	       t.lt(3) #向左转3度
	       t.fd(c) #向前走的步长
	   else:
	       c=c-0.08
	       t.lt(3)
	       t.fd(c)
	t.end_fill()
	t.color("#000000","black")# 设置画笔颜色和填充颜色
	t.pensize(5)
	t.penup() # 提笔
	t.goto(30,88)
	t.pendown()# 落笔
	t.begin_fill()
	t.seth(360)
	t.left(22)
	t.circle(-30,50)

	#嘴巴
	t.color("#FFA500","orange")# 设置画笔颜色和填充颜色
	t.pensize(5)
	t.seth(335)
	t.penup() # 提笔
	t.goto(-80,20) #左上
	t.pendown()# 落笔
	t.begin_fill()
	t.circle(200,50)
	t.penup() # 提笔
	t.seth(155)
	t.pendown()# 落笔
	t.circle(200,50)
	t.end_fill()

def main():
	draw()


if __name__ == '__main__':
	main()

 

  • 4
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 6
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值