【发布时间】:2018-11-20 02:12:50
【问题描述】:
如何更改下面的代码,使 drawRect 也接受 angle 参数?
(x, y) 代表质心。据我所知,我想确定四个角的坐标,然后将它们全部围绕(x, y) 旋转那么多度,保持相同的距离。
# draw a line from a to b
def line(a, b):
# [code omitted]
def drawRect(x, y, w, h):
a = (x - w / 2, y - h / 2)
b = (x + w / 2, y - h / 2)
c = (x + w / 2, y + h / 2)
d = (x - w / 2, y + h / 2)
line(a, b)
line(b, c)
line(c, d)
line(d, a)
【问题讨论】:
-
感谢您纠正我的回答,非常感谢。
标签: python graphics drawing trigonometry