Documentation
¶
Index ¶
- Variables
- func Angle(a, b Vec2) float64
- func Clamp[T cmp.Ordered](low, high, val T) T
- type Box
- type IVec2
- type Line2
- type Mat2
- type Mat3
- type Mat4
- func (m *Mat4) Apply(v Vec3) Vec3
- func (m *Mat4) GetTranslation() Vec3
- func (m *Mat4) Inv() *Mat4
- func (m *Mat4) Mul(n *Mat4) *Mat4
- func (m *Mat4) Rotate(angle float64, axis Vec3) *Mat4
- func (m *Mat4) RotateQuat(quat Quat) *Mat4
- func (m *Mat4) RotateZ(angle float64) *Mat4
- func (m *Mat4) Scale(x, y, z float64) *Mat4
- func (m *Mat4) Translate(x, y, z float64) *Mat4
- func (m *Mat4) Transpose() *Mat4
- type Quat
- type RGBA
- type Rect
- func (r Rect) Anchor(r2 Rect, anchor Vec2) Rect
- func (r Rect) BR() Vec2
- func (r Rect) BottomHalf() Rect
- func (r Rect) Box() Box
- func (r Rect) Center() Vec2
- func (r Rect) CenterScaled(scale float64) Rect
- func (r Rect) CenterScaledXY(scaleX, scaleY float64) Rect
- func (r Rect) Contains(pos Vec2) bool
- func (r *Rect) CutBottom(amount float64) Rect
- func (r *Rect) CutLeft(amount float64) Rect
- func (r *Rect) CutRight(amount float64) Rect
- func (r *Rect) CutTop(amount float64) Rect
- func (r Rect) Fit(r2 Rect) Rect
- func (r Rect) FitInt(r2 Rect) Rect
- func (r Rect) FitScale(r2 Rect) float64
- func (r Rect) FullAnchor(r2 Rect, anchor, pivot Vec2) Rect
- func (r Rect) H() float64
- func (r Rect) Intersects(r2 Rect) bool
- func (r Rect) LayoutHorizontal(n int, padding float64) Rect
- func (r Rect) LeftHalf() Rect
- func (r Rect) MoveMin(pos Vec2) Rect
- func (r Rect) Moved(v Vec2) Rect
- func (r Rect) Norm() Rect
- func (r Rect) OverlapsPoint(pos Vec3) bool
- func (r Rect) Pad(pad Rect) Rect
- func (r Rect) PadAll(padding float64) Rect
- func (r Rect) PadBottom(padding float64) Rect
- func (r Rect) PadLeft(padding float64) Rect
- func (r Rect) PadRight(padding float64) Rect
- func (r Rect) PadTop(padding float64) Rect
- func (r Rect) PadX(padding float64) Rect
- func (r Rect) PadY(padding float64) Rect
- func (r Rect) Point(x, y float64) Vec2
- func (r Rect) RectDraw(r2 Rect) Mat4
- func (r Rect) RightHalf() Rect
- func (r Rect) Scaled(scale float64) Rect
- func (r Rect) ScaledToFit(r2 Rect) Rect
- func (r Rect) ScaledXY(scale Vec2) Rect
- func (r Rect) Size() Vec2
- func (r Rect) SliceHorizontal(amount float64) Rect
- func (r Rect) SliceSquare(amount float64) Rect
- func (r Rect) SliceVertical(amount float64) Rect
- func (r Rect) Snap() Rect
- func (r Rect) SubSquare() Rect
- func (r Rect) TL() Vec2
- func (r Rect) ToBox() Box
- func (r Rect) TopHalf() Rect
- func (r Rect) Union(s Rect) Rect
- func (r Rect) Unpad(pad Rect) Rect
- func (r Rect) W() float64
- func (r Rect) WithCenter(v Vec2) Rect
- type Vec2
- func (v Vec2) Add(v2 Vec2) Vec2
- func (v Vec2) Angle() float64
- func (v Vec2) Dist(u Vec2) float64
- func (v Vec2) DistSq(u Vec2) float64
- func (v Vec2) Dot(u Vec2) float64
- func (v Vec2) Len() float64
- func (v Vec2) LenSq() float64
- func (v Vec2) Mult(s Vec2) Vec2
- func (v Vec2) Norm() Vec2
- func (v Vec2) Rotated(radians float64) Vec2
- func (v Vec2) Scaled(s float64) Vec2
- func (v Vec2) ScaledXY(s Vec2) Vec2
- func (v Vec2) Snap() Vec2
- func (v Vec2) Sub(v2 Vec2) Vec2
- func (v Vec2) Vec3() Vec3
- type Vec3
- func (v Vec3) Add(u Vec3) Vec3
- func (v Vec3) Angle(u Vec3) float64
- func (v Vec3) Dot(u Vec3) float64
- func (v Vec3) Len() float64
- func (v Vec3) Mult(s Vec3) Vec3
- func (v Vec3) Rotate2D(theta float64) Vec3
- func (v Vec3) Scaled(x, y, z float64) Vec3
- func (v Vec3) Sub(u Vec3) Vec3
- func (v Vec3) Theta() float64
- func (v Vec3) Unit() Vec3
- func (v Vec3) Vec2() Vec2
- type Vec4
Constants ¶
This section is empty.
Variables ¶
var ( White = RGBA{1, 1, 1, 1} Black = RGBA{0, 0, 0, 1} )
Functions ¶
Types ¶
type Line2 ¶
type Line2 struct {
A, B Vec2
}
func (Line2) Intersects ¶
Returns true if the two lines intersect
type Mat4 ¶
type Mat4 [16]float64
var Mat4Ident Mat4 = Mat4{
1.0, 0.0, 0.0, 0.0,
0.0, 1.0, 0.0, 0.0,
0.0, 0.0, 1.0, 0.0,
0.0, 0.0, 0.0, 1.0,
}
This is in column major order
func (*Mat4) GetTranslation ¶
func (*Mat4) RotateQuat ¶
type Quat ¶
type Quat struct {
// contains filtered or unexported fields
}
func QuatRotate ¶
func (*Quat) RotateQuat ¶
type RGBA ¶
type RGBA struct {
R, G, B, A float64
}
Premultipled RGBA value scaled from [0, 1.0]
func FromStraightRGBA ¶
func (RGBA) Desaturate ¶
type Rect ¶
type Rect struct {
Min, Max Vec2
}
func (Rect) Anchor ¶
Takes r2 and places it in r based on the alignment TODO - rename to InnerAnchor?
func (Rect) BottomHalf ¶
Returns the bottom half of the rectangle. Doesn't modify the original rectangle
func (Rect) CenterScaled ¶
func (Rect) CenterScaledXY ¶
func (Rect) FullAnchor ¶
Anchors r2 to r1 based on two anchors, one for r and one for r2 TODO - rename to Anchor?
func (Rect) Intersects ¶
func (Rect) LayoutHorizontal ¶
Layous out 'n' rectangles horizontally with specified padding between them and returns that rect The returned rectangle has a min point of 0,0
func (Rect) LeftHalf ¶
Returns the left half of the rectangle. Doesn't modify the original rectangle
func (Rect) OverlapsPoint ¶
Returns true if the point is inside or on the edge of the rect
func (Rect) RightHalf ¶
Returns the right half of the rectangle. Doesn't modify the original rectangle
func (Rect) Scaled ¶
TODO: I need to deprecate this. This currently just indepentently scales the min and max point which is only useful if the center, min, or max is on (0, 0)
func (Rect) ScaledToFit ¶
Scales rect r uniformly to fit inside rect r2 TODO This only scales around {0, 0}
func (Rect) SliceHorizontal ¶
Returns a centered horizontal sliver with height set by amount
func (Rect) SliceSquare ¶
Returns a centered square with height and width set by amount
func (Rect) SliceVertical ¶
Returns a centered vertical sliver with width set by amount
func (Rect) Union ¶
TODO: Should I make a pointer version of this that handles the nil case too? Returns the smallest rect which contains both input rects
func (Rect) Unpad ¶
Removes padding from a rectangle (pads outward if padding is negative). Essentially calls pad but with negative values
func (Rect) WithCenter ¶
func (r Rect) CenterAt(v Vec2) Rect { return r.Moved(r.Center().Scaled(-1)).Moved(v) }
type Vec2 ¶
type Vec2 struct {
X, Y float64
}