turtle画图

在这里插入图片描述

代码:
import turtle as t
import random
t.pensize(1)
t.delay(0)
t.hideturtle()
t.screensize(800,600,‘black’)
t.penup()
t.color(‘white’)
t.goto(-200,0)
t.write(“每个人,都有属于自己的星空!\n”,move=True,align=“left”,font=(“楷体”, 30, “bold”))
t.goto(30,-10)
t.write("–<<小王子>>",move=True,align=“left”,font=(“楷体”,20, “bold”))
#小王子的身体
t.up()
t.goto(-20,-220)
t.pd()
t.seth(90)
t.fillcolor(‘green’)
t.begin_fill()
t.pencolor(‘green’)
t.fd(60)
t.left(90)
t.fd(45)
t.left(90)
t.fd(60)
t.left(90)
t.fd(45)
t.up()
t.goto(-43,-185)
t.circle(22)
t.end_fill()
#小王子的头
t.up()
t.goto(-43,-150)
t.pd()
t.fillcolor(‘orange’)
t.begin_fill()
t.pencolor(‘orange’)
t.circle(15)
t.end_fill()
#月亮
t.up()
t.goto(0,-800)
t.pd()
t.fillcolor(‘yellow’)
t.begin_fill()
t.pencolor(‘yellow’)
t.circle(312)
t.end_fill()
#小王子的围巾
t.up()
t.goto(-62,-151)
t.pd()
t.pensize(10)
t.pencolor(‘red’)
t.fd(10)
t.seth(-40)
for i in range(3):
t.circle(15, 80)
t.circle(-15, 80)
t.circle(15, 80/2)
t.fd(20)

t.pensize(1)
def stars1(x,y,angle,lenth):
t.pencolor(“yellow”)
t.fillcolor(‘yellow’)
t.speed(0)
t.penup()
t.goto(x,y)
t.begin_fill()
t.pendown()
t.left(angle)
for i in range(5):
t.fd(lenth)
t.right(144)
t.end_fill()
t.left(-angle)
def stars2(x,y):
t.pencolor(“yellow”)
t.fillcolor(‘yellow’)
t.speed(0)
t.penup()
t.goto(x,y)
t.begin_fill()
t.pendown()
t.left(angle)
for i in range(4):
t.circle(2)
t.end_fill()
def stars(x,y,angle,lenth):
t.pencolor(“white”)
t.fillcolor(‘white’)
t.speed(0)
t.penup()
t.goto(x,y)
t.begin_fill()
t.pendown()
t.left(angle)
for i in range(5):
t.fd(lenth)
t.right(144)
t.end_fill()
t.left(-angle)
def stars3(x,y):
t.pencolor(“white”)
t.fillcolor(‘white’)
t.speed(0)
t.penup()
t.goto(x,y)
t.begin_fill()
t.pendown()
t.left(angle)
for i in range(4):
t.circle(1)
t.end_fill()

for i in range(150):
x=random.randint(-400,400)
y=random.randint(-300,300)
lenth=random.randint(1,8)
angle=random.randint(0,180)
stars(x,y,angle,lenth)
x=random.randint(-400,400)
y=random.randint(-300,300)
lenth=random.randint(1,8)
angle=random.randint(0,180)
stars1(x,y,angle,lenth)
x=random.randint(-400,400)
y=random.randint(-300,300)
stars2(x,y)
x=random.randint(-400,400)
y=random.randint(-300,300)
stars3(x,y)
t.done()

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值