如何以编程方式绘制矩形

时间:2016-05-23 07:01:40

标签: python math diagram projection

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

1 个答案:

答案 0 :(得分:1)

查看Python的turtle模块https://developer.wordpress.org/reference/functions/get_filesystem_method/。在高度,宽度和深度之上,您需要考虑投影的角度 - 我认为这通常是30/45度。

让你开始...... here is the v3.3 documentation

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)