在 Tkinter 中旋转线条 Canvas
Rotate line in Tkinter Canvas
我在 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,因为 canvas 的大小为 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)
我在 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,因为 canvas 的大小为 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)