Documentation
¶
Overview ¶
Package geo defines the fundamental geometry types used throughout Bellui: Size, Position, and Delta.
These types have no dependencies on the rest of the Bellui framework, making them safe to import from any package without circular dependency concerns.
import "github.com/belluikit/bellui/geo" size := geo.NewSize(200, 100) pos := geo.NewPos(10, 20) delta := geo.NewDelta(5, 5)
Index ¶
- func Max(x, y float32) float32
- func Min(x, y float32) float32
- type Delta
- type Matrix
- func (m Matrix) AABB(w, h float32) (minX, minY, maxX, maxY float32)
- func (m Matrix) Determinant() float32
- func (m Matrix) Inverse() (Matrix, bool)
- func (m Matrix) IsIdentity() bool
- func (m Matrix) IsZeroOrIdentity() bool
- func (m Matrix) Multiply(n Matrix) Matrix
- func (m Matrix) ToGL() [9]float32
- func (m Matrix) TransformPoint(x, y float32) (float32, float32)
- func (m Matrix) TransformVector(x, y float32) (float32, float32)
- type Position
- type Rectangle
- type Size
- func (s Size) Add(v Vector2) Size
- func (s Size) AddWidthHeight(width, height float32) Size
- func (s Size) Components() (float32, float32)
- func (s Size) IsZero() bool
- func (s Size) Max(v Vector2) Size
- func (s Size) Min(v Vector2) Size
- func (s Size) Subtract(v Vector2) Size
- func (s Size) SubtractWidthHeight(width, height float32) Size
- type Vector2
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Delta ¶
type Delta struct {
DX, DY float32
}
Delta is a generic X, Y movement or offset representation.
func NewDelta ¶
NewDelta returns a newly allocated Delta representing a movement in the X and Y axis.
func (Delta) Components ¶
type Matrix ¶
type Matrix struct {
A, B, C, D, TX, TY float32
}
Matrix represents a 2D affine transformation matrix.
The matrix is stored as 6 float32 values in row-major order:
| A C TX | | B D TY | | 0 0 1 |
The zero value is NOT identity — use Identity to create an identity matrix. However, [canvas.baseObject.Transform] treats the zero value as identity for ergonomics (objects with no transform set behave as untransformed).
func NewRotation ¶
NewRotation returns a matrix that rotates counter-clockwise by the given angle in radians around the origin.
func NewRotationAround ¶
NewRotationAround returns a matrix that rotates counter-clockwise by the given angle in radians around the point (px, py).
func NewTranslation ¶
NewTranslation returns a matrix that translates by (tx, ty).
func (Matrix) AABB ¶
AABB computes the axis-aligned bounding box of the rectangle (0,0)-(w,h) after applying this transform. Returns (minX, minY, maxX, maxY).
func (Matrix) Determinant ¶
Determinant returns the determinant of the linear part of the matrix.
func (Matrix) Inverse ¶
Inverse returns the inverse of m and true, or the zero matrix and false if m is not invertible (determinant is zero).
func (Matrix) IsIdentity ¶
IsIdentity reports whether m is the identity matrix.
func (Matrix) IsZeroOrIdentity ¶
IsZeroOrIdentity reports whether m is the zero value or the identity matrix. This is useful for checking if a transform has been set on an object where the zero value of Matrix is used as "no transform".
func (Matrix) Multiply ¶
Multiply returns the matrix product m * n. This applies n first, then m. For example, to translate then rotate:
rotate.Multiply(translate)
func (Matrix) ToGL ¶
ToGL returns the matrix as a 9-element column-major array suitable for uploading to an OpenGL mat3 uniform via glUniformMatrix3fv.
Column-major layout:
[A, B, 0, C, D, 0, TX, TY, 1]
func (Matrix) TransformPoint ¶
TransformPoint applies the full affine transform (including translation) to the point (x, y) and returns the transformed coordinates.
type Position ¶
type Position struct {
X float32 // The position from the parent's left edge
Y float32 // The position from the parent's top edge
}
Position describes a generic X, Y coordinate relative to a parent canvas or object.
func NewSquareOffsetPos ¶
NewSquareOffsetPos returns a Position with the same x and y.
func (Position) Components ¶
func (Position) SubtractXY ¶
type Rectangle ¶
Rectangle describes an axis-aligned rectangle by its top-left position and its size. The zero Rectangle (zero Pos and zero Size) is used by callers to signal "no/invalid rectangle" — e.g. a caret position that is out of range or scrolled out of view.
Since: 1.0
func NewRectangle ¶
NewRectangle returns a Rectangle at (x, y) with the given width and height.
Since: 1.0
type Size ¶
type Size struct {
Width float32 // The number of units along the X axis.
Height float32 // The number of units along the Y axis.
}
Size describes something with width and height.
func NewSquareSize ¶
NewSquareSize returns a Size with the same width and height.