如何在Python Turtle上皱着眉头?
我需要用python制作皱着眉头的乌龟脸,但是我无法像皱眉那样获得半圆形弧,它太大或不完整。
import turtle
t = turtle.Turtle(2)
t.speed(5)
t.forward(120)
t.left(105)
t.forward(130)
t.right(90)
t.forward(25)
t.right(80)
t.forward(140)
t.left(65)
t.forward(100)
t.right(30)
t.forward(30)
t.right(30)
t.forward(30)
t.right(70)
t.forward(30)
t.right(30)
t.forward(30)
t.right (20)
t.forward(80)
t.left(65)
t.forward(130)
t.right(90)
t.forward(25)
t.right(80)
t.forward(110)
t.left (105)
t.forward (160)
t.left(65)
t.forward(50)
t.right(90)
t.forward(25)
t.right(80)
t.forward(60)
t.left (105)
t.right(65)
t.forward(70)
t.right(90)
t.forward(25)
t.right(80)
t.forward(32)
t.left (55)
t.forward(60)
t.penup()
t.right(90)
t.forward(20)
t.pendown()
r = 15
t.circle(r)
t.penup()
t.left(90)
t.forward(10)
t.left(90)
t.forward(5)
t.pendown()
r = 2
t.circle(r)
t.penup()
t.right(90)
t.forward(10)
t.pendown()
r = 2
t.circle(r)
t.penup()
t.forward(5)
t.right(90)
t.forward(15)
t.pendown()
for x in range(180):
t.forward(1)
t.right(1)
t.left(90)
到目前为止,这是我的代码
I need to make a frowning turtle face in python however I can't get the semi-circle arc like frown right, it's too big or not complete.
import turtle
t = turtle.Turtle(2)
t.speed(5)
t.forward(120)
t.left(105)
t.forward(130)
t.right(90)
t.forward(25)
t.right(80)
t.forward(140)
t.left(65)
t.forward(100)
t.right(30)
t.forward(30)
t.right(30)
t.forward(30)
t.right(70)
t.forward(30)
t.right(30)
t.forward(30)
t.right (20)
t.forward(80)
t.left(65)
t.forward(130)
t.right(90)
t.forward(25)
t.right(80)
t.forward(110)
t.left (105)
t.forward (160)
t.left(65)
t.forward(50)
t.right(90)
t.forward(25)
t.right(80)
t.forward(60)
t.left (105)
t.right(65)
t.forward(70)
t.right(90)
t.forward(25)
t.right(80)
t.forward(32)
t.left (55)
t.forward(60)
t.penup()
t.right(90)
t.forward(20)
t.pendown()
r = 15
t.circle(r)
t.penup()
t.left(90)
t.forward(10)
t.left(90)
t.forward(5)
t.pendown()
r = 2
t.circle(r)
t.penup()
t.right(90)
t.forward(10)
t.pendown()
r = 2
t.circle(r)
t.penup()
t.forward(5)
t.right(90)
t.forward(15)
t.pendown()
for x in range(180):
t.forward(1)
t.right(1)
t.left(90)
This is my code so far
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我们可以再次使用
circle()
方法来皱眉,而不是使用显式循环。在这种情况下,我们需要添加可选的latect
参数,还可以了解使用正和负射线和分量的方法circle()
。以下是我的示例解决方案,我将最初的飞机图纸扔到,只是专注于面部:
Rather than using an explicit loop, we can use the
circle()
method again to draw the frown. In this case we need to add the optionalextent
argument, and also learn what using positive and negative radii and extents does tocircle()
.Below is my example solution where I've tossed your initial airplane drawing just to focus on the face:
您可以使用Turtle.circle(半径,弧度)进行半圆形。
例如:
这将使半径为50px的半圆。您可以相应地改变乌龟的方向,以使弧面朝下。
You can use turtle.circle(radius , extent of arc) to make a semi-circle.
For example:
This would make a semi circle of radius 50px. You can change the direction of the turtle accordingly to make the arc face down.