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

Method scaleToOriginalSpace

lib/streaming/resolution.ts:135–145  ·  view source on GitHub ↗

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

Source from the content-addressed store, hash-verified

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.

Callers 2

testSmallTargetEdgeCasesFunction · 0.95

Calls

no outgoing calls

Tested by 1

testSmallTargetEdgeCasesFunction · 0.76