繁体   English   中英

在Tkinter Canvas中旋转线条

[英]Rotate line in Tkinter Canvas

我在画布上有一条线,我想旋转en x度,同时保持canvs中间的起点,我想知道找出终点坐标的公式是什么?,类似于

degrees=xnumberofdegrees
lineEndPoint=degrees*someformulaforxandy
canvas = Canvas(root, width=500, height=500, bg="white")
canvas.pack()
rotatedline=space.create_line(250,250,lineEndPoint)    

起始点应始终为250,250,因为画布的大小为500x500,所以我只需要终点。 欢迎任何帮助。

相当简单的三角学应用。

angle_in_radians = angle_in_degrees * math.pi / 180
line_length = 100
center_x = 250
center_y = 250
end_x = center_x + line_length * math.cos(angle_in_radians)
end_y = center_y + line_length * math.sin(angle_in_radians)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM