viewport

package
v0.0.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 15, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = Origin(0, 0, 1, 1)

Functions

This section is empty.

Types

type Viewport

type Viewport struct{ Prescale, Postscale matrix.Matrix }

Viewport

func Center

func Center(offsetX, offsetY, width, height float64, dist ...float64) Viewport

Center creates a viewport in which the scene's origin maps to the centre of the view.

By default the projection's scale and camera distance follow the view's width and height, so the scene fills the view and rescales as the view is resized.

Pass an optional dist to lock the projection to that fixed reference distance instead. The scale and camera distance then no longer depend on width and height — those only position the centre — so one world unit projects to a constant number of pixels at any view size. Use this to keep on-screen size from changing as the window resizes; only the first dist value is used. Center(ox, oy, s, s) and Center(ox, oy, w, h, s) coincide when w == h == s.

func Origin

func Origin(offsetX, offsetY, width, height float64, dist ...float64) Viewport

Origin creates a viewport in which the scene's origin aligns with the view's origin ([0, 0]), which is usually the top left.

As with Center, the projection by default follows the view's width and height. Pass an optional dist to lock the scale and camera distance to that fixed reference instead, so on-screen size stays constant as the view is resized (width and height then only place the origin); only the first dist value is used.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL