* Converts coordinates from original desktop space to model space. * Use this when desktop coordinates need to be represented in the model's scaled space. * * @param coordinate - Coordinates in original desktop space [x, y] * @returns Coordinates in model's scaled space [x, y]
(coordinate: [number, number])
| 152 | * @returns Coordinates in model's scaled space [x, y] |
| 153 | */ |
| 154 | public scaleToModelSpace(coordinate: [number, number]): [number, number] { |
| 155 | // Store the exact scaled values before rounding |
| 156 | const exactScaledX = coordinate[0] * this.scaleFactor; |
| 157 | const exactScaledY = coordinate[1] * this.scaleFactor; |
| 158 | |
| 159 | // Round only at the final step for pixel-perfect representation |
| 160 | const finalX = Math.round(exactScaledX); |
| 161 | const finalY = Math.round(exactScaledY); |
| 162 | |
| 163 | return [finalX, finalY]; |
| 164 | } |
| 165 | |
| 166 | /** |
| 167 | * Tests the round-trip accuracy of coordinate scaling. |
no outgoing calls