MCPcopy Create free account
hub / github.com/SolarLune/masterplan / RawWorldPosition

Method RawWorldPosition

events.go:219–244  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

217}
218
219func (mouse *Mouse) RawWorldPosition() Vector {
220
221 width, height, err := globals.Renderer.CurrentOutputSize()
222
223 if err != nil {
224 panic(err)
225 }
226
227 wx := mouse.screenPosition.X/float32(width) - 0.5
228 wy := mouse.screenPosition.Y/float32(height) - 0.5
229
230 viewArea := globals.Project.Camera.ViewArea()
231
232 wx *= float32(viewArea.W)
233 wy *= float32(viewArea.H)
234
235 wx += globals.Project.Camera.Position.X
236 wy += globals.Project.Camera.Position.Y
237
238 // Debug view
239 // globals.Renderer.SetDrawColor(255, 0, 0, 255)
240 // globals.Renderer.DrawRectF(globals.Project.Camera.Translate(&sdl.FRect{wx, wy, 16, 16}))
241
242 return Vector{wx, wy}
243
244}
245
246func (mouse *Mouse) WorldPosition() Vector {
247

Callers 4

WorldPositionMethod · 0.95
RawClickedInRectFunction · 0.80
ImmediateIconButtonFunction · 0.80
UpdateMethod · 0.80

Calls 1

ViewAreaMethod · 0.80

Tested by

no test coverage detected