MCPcopy Create free account
hub / github.com/e2b-dev/surf / scaleToModelSpace

Method scaleToModelSpace

lib/streaming/resolution.ts:154–164  ·  view source on GitHub ↗

* 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])

Source from the content-addressed store, hash-verified

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.

Callers 2

testSmallTargetEdgeCasesFunction · 0.95

Calls

no outgoing calls

Tested by 1

testSmallTargetEdgeCasesFunction · 0.76