在 python Turtle 中绘制字母“R”

问题描述 投票:0回答:1

我在海龟中创建“R”字母时遇到了一些小问题。这是我的代码

import turtle

t = turtle.Turtle()
t.forward(100)
t.right(90)
t.forward(75)
t.right(90)
t.forward(50)
t.left(120)
t.forward(75)
t.left(-120)
t.forward(25)
t.right(60)
t.forward(75)
t.left(150)
t.forward(70)
t.left(-90)
t.forward(25)
t.right(90)
t.forward(145)

有人可以帮我改进如何写“R”字母,目前它不太准确吗?

python turtle-graphics python-turtle
1个回答
1
投票
import turtle

t = turtle.Turtle()

# Draw the vertical line of 'R'
t.forward(100)
t.right(90)
t.forward(75)
t.right(90)
t.forward(100)

# Draw the slanted leg of 'R'
t.left(180)
t.forward(50)
t.left(120)
t.forward(75)
t.left(60)
t.forward(35)

turtle.done()

所做的更改:

最后使用

turtle.done()
来保持绘制后窗口打开。 更正了角度以确保准确绘制“R”。 调整长度和角度以创建更平衡的“R”形状。 请随意尝试这些值,根据您的喜好调整字母“R”的大小和比例。

© www.soinside.com 2019 - 2024. All rights reserved.