1

我目前正在尝试做的是将屏幕上的一组点从中心点扩展开。我目前正在使用此代码(注意我已修改此代码以便于理解):

    #d_x - the x coordinate of the dot at its default position 
    #d_y - the y coordinate of the dot at its default position 
    #dis_x - the distance along the x grid the point is away from the centre point 
    #dis_y - the distance along the y grid the point is away from the centre point
    #zoom_level - the zoom level increased or decreased depending on the mouse wheel
z_x = (d_x + (dis_x * (1 + (zoom_level * 0.01))))
    z_y = (d_y + (dis_y * (1 + (zoom_level * 0.01))))
drawText("*",z_x,z_y,)

这段代码几乎可以工作,唯一的问题是,当 zoom_level 为 0 时,点位于正确的位置,但是当我增加缩放级别时,点向错误的方向扩展,而不是从中心点向外扩展,相反的方向,向中心点行进。

任何有关如何解决此问题的建议将不胜感激。

[编辑] - 我没有这么说,但每个点都分布在中心点周围的随机点上。

4

1 回答 1

1

让我们的中心点有坐标(c_x,c_y)。然后(默认缩放 = 1)

z_x = c_x + (d_x - c_x) * Zoom
z_y = c_y + (d_y - c_y) * Zoom

示例:中心点(黑色)(2,2),点(蓝色)(3,3)和(0,1)缩放= 2:新点(红色)(4,4)和(-2, 0) 在此处输入图像描述

于 2013-06-04T11:54:45.487 回答