利用python的turtle库画辛普森(新手练习)



一、生成图

新手实验,请勿喷
生成图

二、使用步骤

1.引入库

import turtle as t
t.screensize(2000,2000) 
t.pensize(4)
t.hideturtle()
t.pencolor('black')
t.speed(10)

总代码

// An highlighted block
import turtle as t
t.screensize(2000,2000) 
t.pensize(4)
t.hideturtle()
t.pencolor('black')
t.speed(10)
#填充颜色
t.colormode(255)
t.fillcolor(224,190,4)
t.setup(840, 500)
t.speed(20)
# 鼻子
#轮廓
t.begin_fill()
#一、脖子
t.pu()
t.goto(200, 0)
t.pd()
t.seth(-90)
t.fd(20)
t.seth(-30)
t.circle(200,60)
t.seth(90)
t.fd(20)
t.end_fill()
#二、下吧
t.begin_fill()
t.seth(0)
t.circle(250,16)
t.seth(80)
a=1
for i in range(60):
    a=a+0.12
    t.seth(80+i/3)
    t.fd(a)
t.penup()
t.goto(200,0)
t.goto(200,-20)
t.pendown()
t.seth(90)
t.fd(20)
t.seth(-180)
t.circle(-250,16)

t.seth(100)
a=1
for i in range(60):
    a=a+0.12
    t.seth(100-i/3)
    t.fd(a)
pos1=t.pos()
t.end_fill()
t.goto(pos1)

#头发
t.begin_fill()
t.setheading(90)
t.circle(-100,30)
t.right(90)
t.circle(-100,30)
t.setheading(90)
t.circle(-100,30)
t.right(90)
t.circle(-100,30)
t.setheading(90)
t.circle(-100,30)
t.right(80)
t.circle(-100,32)
t.penup()
t.goto(458,285)
t.pendown()
t.end_fill()
#右边头发
t.begin_fill()
t.setheading(90)
t.circle(100,30)
t.left(90)
t.circle(100,30)
t.setheading(90)
t.circle(100,30)
t.left(90)
t.circle(100,30)
t.setheading(90)
t.circle(100,30)
t.left(80)
t.circle(100,32)
t.end_fill()
t.penup()
#脸部颜色填充
t.goto(200,0)
t.begin_fill()
t.goto(400,0)
t.goto(458,285)
t.goto(143,290)
t.goto(200,0)
t.end_fill()

#填充颜色(白)
t.colormode(255)
t.fillcolor(224,224,224)
#左眼睛
t.begin_fill()
t.pensize(5)
t.goto(260,170)
t.pendown()
t.seth(90)
t.circle(70)
t.end_fill()
t.penup()
t.colormode(255)
t.fillcolor(0,0,0)
t.begin_fill()
t.goto(190,190)
t.seth(180)
t.circle(12)
t.end_fill()
#右眼睛
t.colormode(255)
t.fillcolor(224,224,224)
t.begin_fill()
t.penup()
t.goto(450,170)
t.pendown()
t.seth(90)
t.circle(70)
t.end_fill()
t.penup()
t.colormode(255)
t.fillcolor(0,0,0)
t.pensize(5)
t.begin_fill()
t.goto(380,190)
t.pendown()
t.seth(180)
t.circle(10)
t.end_fill()

#鼻子
t.colormode(255)
t.pencolor('black')
t.pensize(5)
t.fillcolor(224,190,4)
t.begin_fill()
t.penup()
t.goto(270,170)
t.pendown()
t.seth(180)
t.circle(30,270)
t.penup()
t.circle(30,90)
t.end_fill()

#嘴巴
t.goto(190,80)
t.pendown()
t.seth(-100)
t.circle(80,30)
t.penup()
t.circle(80,140)
t.pendown()
t.circle(80,30)
t.penup()
t.goto(188,65)
t.pendown()
t.seth(-16)
t.circle(300,30)

t.done()

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值