Documentation ¶
Overview ¶
zoom is a handler for dealing with zoom.
Example ¶
package main import ( "github.com/omustardo/gome/camera/zoom" "log" ) func main() { var mouseScrollY float32 zoomer := zoom.NewScrollZoom( // Allow zooming out to 25% of the original size, and in to 300% of the original size. 0.25, 3, // For this example, simulate getting mouse input by changing this variable. func() float32 { return mouseScrollY }, ) log.Println(zoomer.GetCurrentPercent()) // 1.0 : no change since the mouse hasn't scrolled yet. mouseScrollY = 30 log.Println(zoomer.GetCurrentPercent()) // value > 1.0 : the mouse was scrolled. }
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ScrollZoom ¶
type ScrollZoom struct {
// Range of percent zoom allowed. If the range doesn't include 1.0, then the default starting zoom will be (Min+Max)/2.
// Min zoom means zoomed out as far as possible - everything will look small. Max zoom is zoomed in as close as possible.
Min, Max float32
// GetScrollAmount is expected to return the amount scrolled in the last update period.
GetScrollAmount func() float32
// contains filtered or unexported fields
}
ScrollZoom implements Zoom. Intended for use with a camera's projection matrix. Intended to get data from a mouse scroll wheel.
func NewScrollZoom ¶
func NewScrollZoom(min, max float32, GetScrollAmount func() float32) *ScrollZoom
NewScrollZoom creates a ScrollZoom struct. Example usage:
zoomer := zoom.NewScrollZoom(0.25, 3, // allows zooming out to 25% of the original size, and in to 300% of the original size. func() float32 { return mouse.Handler.Scroll().Y() }, )
func (*ScrollZoom) GetCurrentPercent ¶
func (z *ScrollZoom) GetCurrentPercent() float32
func (*ScrollZoom) Range ¶
func (z *ScrollZoom) Range() (min, max float32)
func (*ScrollZoom) Update ¶
func (z *ScrollZoom) Update()
type Zoom ¶
type Zoom interface { // GetCurrentPercent returns the current percent zoom. Always a positive value. GetCurrentPercent() float32 // Range returns the limits of zooming in and out. // min is the limit of zooming out, max is the limit of zooming in. // For example a min of 0.25 means objects appear to be 25% of their original size when zoomed out fully. // A max of 3 means objects will appear to be 300% of their original size when fully zoomed in. Range() (min, max float32) // Update must be called every frame. Update() }
Zoom provides handling for zooming in and out.
Click to show internal directories.
Click to hide internal directories.