* Converts coordinates from model space to original desktop space. * Use this when the model sends coordinates (based on scaled screenshot) * that need to be converted to the original desktop space for actual interaction. * * @param coordinate - Coordinates in model's scaled space [x, y]
(coordinate: [number, number])
| 133 | * @returns Coordinates in original desktop space [x, y] |
| 134 | */ |
| 135 | public scaleToOriginalSpace(coordinate: [number, number]): [number, number] { |
| 136 | // Store the exact scaled values before rounding |
| 137 | const exactScaledX = coordinate[0] / this.scaleFactor; |
| 138 | const exactScaledY = coordinate[1] / this.scaleFactor; |
| 139 | |
| 140 | // Round only at the final step for pixel-perfect positioning |
| 141 | const finalX = Math.round(exactScaledX); |
| 142 | const finalY = Math.round(exactScaledY); |
| 143 | |
| 144 | return [finalX, finalY]; |
| 145 | } |
| 146 | |
| 147 | /** |
| 148 | * Converts coordinates from original desktop space to model space. |
no outgoing calls