MCPcopy Index your code
hub / github.com/coder/coder / scaleDesktopCoordinate

Function scaleDesktopCoordinate

codersdk/workspacesdk/display.go:151–163  ·  view source on GitHub ↗
(coord, fromDim, toDim int)

Source from the content-addressed store, hash-verified

149}
150
151func scaleDesktopCoordinate(coord, fromDim, toDim int) int {
152 if toDim <= 0 {
153 return 0
154 }
155 if fromDim <= 0 || fromDim == toDim {
156 return clampDesktopCoordinate(coord, toDim)
157 }
158
159 scaled := (float64(coord)+0.5)*float64(toDim)/float64(fromDim) - 0.5
160 scaled = math.Max(scaled, 0)
161 scaled = math.Min(scaled, float64(toDim-1))
162 return int(math.Round(scaled))
163}
164
165func clampDesktopCoordinate(coord, dim int) int {
166 if dim <= 0 {

Callers 2

DeclaredPointToNativeMethod · 0.85
NativePointToDeclaredMethod · 0.85

Calls 2

clampDesktopCoordinateFunction · 0.85
MinMethod · 0.80

Tested by

no test coverage detected