package f32
import "gioui.org/f32"
Package f32 is a float32 implementation of package image's Point and affine transformations.
The coordinate space has the origin in the top left corner with the axes extending right and down.
Index ¶
- type Affine2D
- func NewAffine2D(sx, hx, ox, hy, sy, oy float32) Affine2D
- func (a Affine2D) Elems() (sx, hx, ox, hy, sy, oy float32)
- func (a Affine2D) Invert() Affine2D
- func (A Affine2D) Mul(B Affine2D) (r Affine2D)
- func (a Affine2D) Offset(offset Point) Affine2D
- func (a Affine2D) Rotate(origin Point, radians float32) Affine2D
- func (a Affine2D) Scale(origin, factor Point) Affine2D
- func (a Affine2D) Shear(origin Point, radiansX, radiansY float32) Affine2D
- func (a *Affine2D) Split() (srs Affine2D, offset Point)
- func (a Affine2D) String() string
- func (a Affine2D) Transform(p Point) Point
- type Point
Types ¶
type Affine2D ¶
type Affine2D struct {
// contains filtered or unexported fields
}
Affine2D represents an affine 2D transformation. The zero value of Affine2D represents the identity transform.
func NewAffine2D ¶
NewAffine2D creates a new Affine2D transform from the matrix elements in row major order. The rows are: [sx, hx, ox], [hy, sy, oy], [0, 0, 1].
func (Affine2D) Elems ¶
Elems returns the matrix elements of the transform in row-major order. The rows are: [sx, hx, ox], [hy, sy, oy], [0, 0, 1].
func (Affine2D) Invert ¶
Invert the transformation. Note that if the matrix is close to singular numerical errors may become large or infinity.
func (Affine2D) Mul ¶
Mul returns A*B.
func (Affine2D) Offset ¶
Offset the transformation.
func (Affine2D) Rotate ¶
Rotate the transformation by the given angle (in radians) counter clockwise around the given origin.
func (Affine2D) Scale ¶
Scale the transformation around the given origin.
func (Affine2D) Shear ¶
Shear the transformation by the given angle (in radians) around the given origin.
func (*Affine2D) Split ¶
Split a transform into two parts, one which is pure offset and the other representing the scaling, shearing and rotation part.
func (Affine2D) String ¶
func (Affine2D) Transform ¶
Transform p by returning a*p.
type Point ¶
type Point struct { X, Y float32 }
A Point is a two dimensional point.
func Pt ¶
Pt is shorthand for Point{X: x, Y: y}.
func (Point) Add ¶
Add return the point p+p2.
func (Point) Div ¶
Div returns the vector p/s.
func (Point) Mul ¶
Mul returns p scaled by s.
func (Point) Round ¶
Round returns the integer point closest to p.
func (Point) String ¶
String return a string representation of p.
func (Point) Sub ¶
Sub returns the vector p-p2.
Source Files ¶
affine.go f32.go
- Version
- v0.8.0 (latest)
- Published
- Jan 14, 2025
- Platform
- linux/amd64
- Imports
- 3 packages
- Last checked
- 9 hours ago –
Tools for package owners.