camzoom

package
v0.0.0-...-94fff03 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2026 License: MIT Imports: 5 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package camzoom is the wheel zoom of the editors' cameras: each wheel unit scales the zoom by a fixed factor (so a trackpad's small deltas zoom slowly and a mouse notch a little), and the camera eases toward the target zoom around the cursor instead of jumping.

Index

Constants

View Source
const (
	// Min and Max bound the camera zoom (1/16 to 64).
	Min, Max = 1.0 / 16, 64
	// Step is the zoom factor per wheel unit; a mouse notch is one unit.
	Step = 1.1
)

Variables

This section is empty.

Functions

func Clamp

func Clamp(z float32) float32

Clamp limits z to [Min, Max].

func Of

func Of(cam *render.Camera) float32

Of returns the camera's zoom, treating the zero value as 1.

Types

type Zoom

type Zoom struct {
	// contains filtered or unexported fields
}

Zoom eases a camera toward a wheel-driven target zoom. The zero value is ready; it follows a camera that other code (framing, restoring) changes.

func (*Zoom) Update

func (z *Zoom) Update(cam *render.Camera, cur gfx.Vec2, screen image.Point)

Update moves the camera one tick toward the target, keeping the world point under the screen point cur where it is. It does nothing when the camera is at the target.

func (*Zoom) Wheel

func (z *Zoom) Wheel(cam *render.Camera, wheel float32)

Wheel moves the target zoom by wheel units (positive zooms in, as [input.MouseFrame] reports it, negative out); call it once per tick with that tick's wheel movement, then Zoom.Update.

Jump to

Keyboard shortcuts

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