python运用turtle库画图--关于疫情主题的图片

初学python中的turtle库,个人认为画图前要先建立好直角坐标系,确定好各主要点的坐标,这样提笔的时候更加容易画出准确的图。
使用turtle库画出了这样一张关于疫情主题的图片,寄托我们美好的祝愿。
在这里插入图片描述
代码如下:

import turtle as t
import random

def wheregoto(x,y): #x,y表示坐标
    t.up()
    t.goto(x,y)
    t.down()

t.speed(0)
t.pensize(4)
t.screensize(690,764) #设置画布
t.pensize(4)
wheregoto(-325,352)
t.setheading(270)
t.pencolor("gray1")
for j in range (2):
    t.forward(734)
    t.left(90)
    t.forward(650)
    t.left(90)
t.pencolor("red3")
t.penup()

#枕头
t.speed(0)
t.fillcolor("mint cream")
t.setheading(180)
wheregoto(-86,-22)
t.begin_fill()
t.pendown()
t.left(-10)
t.circle(160,12)
t.left(-41)
t.circle(60,10)
t.left(70)
t.circle(60,10)
t.left(40)
t.circle(200,8)
t.left(-8)
t.circle(200,4)
t.left(-18)
t.circle(200,4)
t.right(10)
t.circle(200,4)
t.left(10)
t.circle(200,4)
t.left(10)
t.circle(200,4)
t.left(10)
t.circle(200,3)
t.right(15)
t.circle(200,3)
t.right(25)
t.circle(200,3)
t.left(55)
t.circle(200,3)
t.left(25)
t.circle(200,14)
t.fd(150)
t.setheading(-5)
t.pendown()
t.circle(200,8)
t.right(40)
t.circle(200,2)
t.left(30)
t.circle(200,3)
t.left(20)
t.circle(200,2)
t.left(45)
t.circle(70,40)
t.right(30)
t.circle(200,17)
t.right(20)
t.circle(200,3)
t.left(10)
t.circle(200,3)
t.left(20)
t.circle(200,3)
t.left(20)
t.circle(60,3)
t.left(60)
t.circle(60,5)
t.left(20)
t.circle(60,5)
t.right(50)
t.circle(300,9)
t.seth(176)
t.fd(168)
t.end_fill()

#杯子
t.setheading(0)
wheregoto(-100,90)
t.fillcolor("floral white")
t.begin_fill()
t.left(-80)
t.forward(160)
t.left(30)
t.circle(100,95)
t.left(35)
t.forward(163)
t.end_fill()
t.fillcolor("khaki1")
t.begin_fill()
t.left(57)
t.circle(150,85)
t.left(103)
t.circle(180,68)
t.end_fill()

#面
#面底色
wheregoto(-86,81)
t.pencolor("red3")
t.fillcolor("khaki")
t.begin_fill()
t.setheading(56)
t.circle(-103,114)
t.pensize(2)
t.setheading(212)
t.circle(-154,70)
t.end_fill()

#大面
wheregoto(-76,78)
t.pencolor("Darkgoldenrod3")
t.setheading(36)
t.pensize(4)
t.circle(-140,70)
wheregoto(-76,90)#面条1
t.pencolor("Darkgoldenrod3")
t.setheading(30)
t.pensize(4)
t.circle(-160,50)
wheregoto(-54,110)#2
t.pencolor("Darkgoldenrod3")
t.setheading(18)
t.pensize(4)
t.circle(-150,50)
wheregoto(-36,115)#3
t.pencolor("Darkgoldenrod3")
t.setheading(19)
t.pensize(4)
t.circle(-90,60)
wheregoto(-36,115)#4
t.pencolor("Darkgoldenrod3")
t.setheading(24)
t.pensize(4)
t.circle(-90,60)
wheregoto(-66,75)#5
t.pencolor("Darkgoldenrod3")
t.setheading(41)
t.circle(-90,90)
wheregoto(-10,103)#6
t.pencolor("Darkgoldenrod3")
t.setheading(0)
t.circle(-110,47)
wheregoto(-10,103)#7
t.pencolor("Darkgoldenrod3")
t.setheading(0)
t.circle(-150,37)

#小面
t.pensize(5)
t.pencolor("red3")
wheregoto(-63,71)
t.setheading(39)
t.circle(-110,30)
t.setheading(10)
t.circle(-56,76)
wheregoto(-63,71)#面条1
t.pencolor("Darkgoldenrod3")
t.setheading(34)
t.circle(-110,30)
t.setheading(10)
t.circle(-56,72)
wheregoto(-54,67)#2
t.pencolor("Darkgoldenrod3")
t.setheading(30)
t.circle(-130,24)
t.setheading(6)
t.circle(-56,61)
wheregoto(-42,63)#3
t.pencolor("Darkgoldenrod3")
t.setheading(30)
t.circle(-130,20)
t.setheading(6)
t.circle(-56,52)
wheregoto(-28,60)#4
t.pencolor("Darkgoldenrod3")
t.setheading(30)
t.circle(-130,16)
t.setheading(6)
t.circle(-56,48)
wheregoto(-15,56)#5
t.pencolor("Darkgoldenrod3")
t.setheading(32)
t.circle(-130,14)
t.setheading(6)
t.circle(-40,48)
wheregoto(-1,56)#6
t.pencolor("Darkgoldenrod3")
t.setheading(34)
t.circle(-120,9)
t.setheading(6)
t.circle(-30,48)
wheregoto(13,56)#7
t.pencolor("Darkgoldenrod3")
t.setheading(30)
t.circle(-120,9)
t.setheading(6)
t.circle(-10,60)

#面轮廓
wheregoto(-86,81)
t.pencolor("red3")
t.setheading(56)
t.circle(-103,114)
t.pensize(4)
t.setheading(212)
t.circle(-154,70)

#酱汁
wheregoto(-34,110)
t.pensize(3)
t.pendown()
t.pencolor("orange4")
t.fillcolor("orange4")
t.begin_fill()
t.setheading(56)
t.circle(-40,50)
t.setheading(26)
t.circle(-40,70)
t.setheading(-15)
t.circle(-70,30)
t.circle(-30,30)
t.circle(-10,30)
t.circle(-10,100)
t.circle(-190,10)
t.circle(-5,360)
t.seth(-170)
t.circle(-180,20)
t.seth(145)
t.circle(-30,50)
t.end_fill()
t.penup()

wheregoto(55,75)
t.begin_fill()
t.circle(3,360)
t.end_fill()

wheregoto(40,90)
t.begin_fill()
t.circle(5,360)
t.end_fill()

wheregoto(-45,95)
t.begin_fill()
t.circle(2,360)
t.end_fill()

#葱
t.pencolor("lawn green")
t.fillcolor("lawn green")
wheregoto(0,110)
t.begin_fill()
t.circle(3,360,4)
t.end_fill()

t.pencolor("lawn green")
t.fillcolor("lawn green")
wheregoto(35,65)
t.begin_fill()
t.circle(2,360,4)
t.end_fill()

t.pencolor("DarkOliveGreen1")
t.fillcolor("DarkOliveGreen1")
wheregoto(45,90)
t.begin_fill()
t.circle(2
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值