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 に答える