画企鹅,源码来自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()

 

你可能感兴趣的:(画企鹅,源码来自b站某up)