drawmatrix

package
v0.3.10 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2025 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Transform

func Transform(dr image.Rectangle, sr image.Rectangle, rotDeg float32) math32.Matrix3

Transform returns a transformation matrix for the generic Draw function that scales, translates, and rotates the source image by the given degrees, to make it fit within the destination rectangle dr, given its original size sr (unrotated). To avoid scaling, ensure that the dr and sr are the same dimensions (post rotation). rotDeg = rotation degrees to apply in the mapping: 90 = left, -90 = right, 180 = invert.

Types

type Matrix

type Matrix struct {
	// MVP is the vertex projection matrix,
	// for positioning the vertex points
	MVP math32.Matrix4

	// UVP is the U,V texture coordinate projection matrix
	// for positioning the texture. For fill mode, the
	// last column holds the fill color.
	UVP math32.Matrix4
}

Matrix holds the projection matricies.

func Config

func Config(destSz image.Point, xform math32.Matrix3, txsz image.Point, sr image.Rectangle, flipY bool) *Matrix

Config configures the draw matrix for given draw parameters: xform is the transform mapping source to destination coordinates (translation, scaling), txsz is the size of the texture to draw, sr is the source region (set to tex.Format.Bounds() for all) flipY inverts the Y axis of the source image.

Jump to

Keyboard shortcuts

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