如何以编程方式绘制矩形

How can I Draw rectangle in programmatically

如何通过给定高度、宽度和深度以编程方式(python)绘制矩形(倾斜投影视图)。

看看 Python 的 turtle 模块,here is the v3.3 documentation。除了高度、宽度和深度之外,您还需要考虑投影的角度 - 我认为这通常是 30/45 度。

让你开始...... adapting code by Y. Daniel Liang.

import turtle

w = 100
h = 50
d = 20
angle = 30

def drawRectangle(width, height): 
    turtle.right(90)
    turtle.forward(height)
    turtle.right(90)
    turtle.forward(width)
    turtle.right(90)
    turtle.forward(height)
    turtle.right(90)
    turtle.forward(width)

turtle.penup() 
turtle.goto(0, 0)
turtle.pendown()
drawRectangle(w, h)
turtle.left(angle)
turtle.forward(d)
turtle.right(angle)
drawRectangle(w, h)