时间:2021-07-01 10:21:17 帮助过:50人阅读
今年的双十一到了
但还有谁记得双十一是
单身狗的节日
单身狗的我是时候站出来
捍卫自己的权益了
单身是一种怎样的状态? 我们所有人都单身过,但也许只有很少的人真正体验过。
短视频内容完全是假的,全程是一个人的操作,你必须拥有一台好的手机、一个好的文案想法。
Turtle库是Python语言中一个很流行的绘制图像的函数库,想象一只小乌龟,在一个横轴为x、纵轴为y的坐标系内,从原点(0,0)位置开始,它根据一组函数指令,在这个平面坐标系中移动,从而在它爬行的路径上绘制了图形。
操纵海龟绘图有着许多的函数,这些函数可以划分为3种:一种为画笔控制函数,一种为运动控制函数,还有一种是方向控制函数。
函数名 | 作用 |
---|---|
turtle.penup() | 抬起画笔,不绘画 |
turtle.pendown() | 落下画笔,开始绘画,前两者成对出现 |
turtle.pencolor() | 绘画颜色 |
turtle.pensize() | 画笔粗细 |
函数名 | 作用 |
---|---|
turtle.forward(d) | 向前行进,走直线,d可以为负值 |
turtle.circle(r,extent=None) | 以r为半径绘制extent角度的弧形,extent可缺省,默认绘制整圆。r为正,即在前进方向的左侧绘制,为负,即在右侧绘制。 |
函数名 | 作用 |
---|---|
turtle.setheading(angle) | 改变行进方向,但不行进,为绝对角度 |
turtle.left(angel) | 海龟向左转,angel在海龟当前行进方向上旋转的角度 |
turtle.right(angel) | 海龟向右转,angel在海龟当前行进方向上旋转的角度 |
- import turtle as t
- t.screensize(500, 500)# 【头部轮廓】t.pensize(5)
- t.home()
- t.seth(0)
- t.pd() #pendownt.color('black')
- t.circle(20, 80) # 0t.circle(200, 30) # 1t.circle(30, 60) # 2t.circle(200, 29.5) # 3t.color('black')
- t.circle(20, 60) # 4t.circle(-150, 22) # 5t.circle(-50, 10) # 6t.circle(50, 70) # 7# 确定鼻头大概位置 t.xcor和t.ycor乌龟一开始的位置x_nose = t.xcor()
- y_nose = t.ycor()
- t.circle(30, 62) # 8t.circle(200, 15) # 9# 【鼻子】t.pu() #penupt.goto(x_nose, y_nose + 25)
- t.seth(90)
- t.pd()
- t.begin_fill()
- t.circle(8)
- t.end_fill()# 【眼睛】t.pu()
- t.goto(x_nose + 48, y_nose + 55)
- t.seth(90)
- t.pd()
- t.begin_fill()
- t.circle(8)
- t.end_fill()# 【耳朵】t.pu()
- t.color('#444444')
- t.goto(x_nose + 100, y_nose + 110)
- t.seth(182)
- t.pd()
- t.circle(15, 45)
- t.color('black')
- t.circle(10, 15)
- t.circle(90, 70)
- t.circle(25, 110)
- t.rt(4)
- t.circle(90, 70)
- t.circle(10, 15)
- t.color('#444444')
- t.circle(15, 45)
- # 【身体】t.pu()
- t.color('black')
- t.goto(x_nose + 90, y_nose - 30)
- t.seth(-130)
- t.pd()
- t.circle(250, 28)
- t.circle(10, 140)
- t.circle(-250, 25)
- t.circle(-200, 25)
- t.circle(-50, 85)
- t.circle(8, 145)
- t.circle(90, 45)
- t.circle(550, 5)
- # 【尾巴】t.seth(0)
- t.circle(60, 85)
- t.circle(40, 65)
- t.circle(40, 60)
- t.lt(150) #leftt.circle(-40, 90)
- t.circle(-25, 100)
- t.lt(5)
- t.fd(20)
- t.circle(10, 60)
- # 【背部】t.rt(80) #rightt.circle(200, 35)# 【项圈】t.pensize(20)
- t.color('#F03C3F')
- t.lt(10)
- t.circle(-200, 25)
- # 【爱心铃铛】t.pu()
- t.fd(18)
- t.lt(90)
- t.fd(18)
- t.pensize(6)
- t.seth(35) #setheadingt.color('#FDAF17')
- t.begin_fill()
- t.lt(135)
- t.fd(6)
- t.right(180) # 画笔掉头t.circle(6, -180)
- t.backward(8)
- t.right(90)
- t.forward(6)
- t.circle(-6, 180)
- t.fd(15)
- t.end_fill()# 【前小腿】t.pensize(5)
- t.pu()
- t.color('black')
- t.goto(x_nose + 100, y_nose - 125)
- t.pd()
- t.seth(-50)
- t.fd(25)
- t.circle(10, 150)
- t.fd(25)# 【后小腿】t.pensize(4)
- t.pu()
- t.goto(x_nose + 314, y_nose - 125)
- t.pd()
- t.seth(-95)
- t.fd(25)
- t.circle(-5, 150)
- t.fd(2)
- t.hideturtle()
- t.done()复制代码
得到的结果如下:
相关免费学习推荐:python视频教程
以上就是用turtle画个单身狗送给自己~的详细内容,更多请关注gxlcms其它相关文章!