MCPcopy Create free account
hub / github.com/B33pBeeps/redthread / ScreenDeltaToWorld

Function ScreenDeltaToWorld

internal/app/notes.go:83–99  ·  view source on GitHub ↗

ScreenDeltaToWorld converts a 1-cell screen delta into a world delta, ensuring a non-zero input always moves at least 1 world cell.

(d, zoom int)

Source from the content-addressed store, hash-verified

81// ScreenDeltaToWorld converts a 1-cell screen delta into a world delta,
82// ensuring a non-zero input always moves at least 1 world cell.
83func ScreenDeltaToWorld(d, zoom int) int {
84 if d == 0 {
85 return 0
86 }
87 s := zoomScale(zoom)
88 if s == 0 {
89 return d
90 }
91 v := int(float32(d)/s + 0.5)
92 if v == 0 {
93 if d > 0 {
94 return 1
95 }
96 return -1
97 }
98 return v
99}
100
101// --- Note -------------------------------------------------------------
102

Callers 1

nudgeSelMethod · 0.85

Calls 1

zoomScaleFunction · 0.85

Tested by

no test coverage detected