Documentation
¶
Overview ¶
Package view is a display-free 2D pan/zoom camera: it maps between world and screen space around a centred focus, with follow and fit-to-bounds framing, and imports no rendering backend — so headless sims and web front-ends share the same camera math the Ebiten front-ends use. When a draw transform is needed on top of this, the front-end layers github.com/danielriddell21/crucible/camera over it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Camera ¶
type Camera struct {
// X and Y are the world point at the centre of the view.
X, Y float64
// Zoom is the magnification factor.
Zoom float64
// ViewW and ViewH are the screen size in pixels.
ViewW, ViewH float64
}
Camera frames a 2D world onto a ViewW×ViewH screen, centred on (X, Y) and magnified by Zoom.
func (*Camera) FitBounds ¶
FitBounds centres and zooms the camera so the world rectangle, grown by margin (a fraction of its size), fits the screen. A degenerate rectangle resets the zoom to 1.
func (*Camera) ScreenToWorld ¶
ScreenToWorld maps a screen point back to world coordinates.
func (*Camera) WorldToScreen ¶
WorldToScreen maps a world point to screen coordinates.