Documentation
¶
Index ¶
- Variables
- func BuildPolygonFan(points []types.Vec2, textured bool, img *ebiten.Image) ([]ebiten.Vertex, []uint16)
- func ComputeMeshAABB(verts []ebiten.Vertex) types.Rect
- func EarClipIndices(pts []types.Vec2) []uint16
- func EnsureTransformedVerts(n *node.Node) []ebiten.Vertex
- func EnsureWhitePixel() *ebiten.Image
- func MeshWorldAABB(n *node.Node, transform [6]float64, ...) types.Rect
- func MeshWorldAABBOffset(n *node.Node, transform [6]float64) types.Rect
- func NewPolygon(name string, points []types.Vec2) *node.Node
- func NewPolygonTextured(name string, img *ebiten.Image, points []types.Vec2) *node.Node
- func NewRegularPolygon(name string, sides int, radius float64) *node.Node
- func NewStar(name string, outerR, innerR float64, points int) *node.Node
- func Perpendicular(a, b types.Vec2) (float64, float64)
- func Poly2DCross(o, a, b types.Vec2) float64
- func PtInTriangle(p, a, b, c types.Vec2) bool
- func RecomputeMeshAABB(n *node.Node)
- func SetPolygonPoints(n *node.Node, points []types.Vec2)
- func TransformVertices(src, dst []ebiten.Vertex, transform [6]float64, tint types.Color)
- type DistortionGrid
- func (g *DistortionGrid) Cols() int
- func (g *DistortionGrid) Node() *node.Node
- func (g *DistortionGrid) Reset()
- func (g *DistortionGrid) Rows() int
- func (g *DistortionGrid) SetAllVertices(fn func(col, row int, restX, restY float64) (dx, dy float64))
- func (g *DistortionGrid) SetVertex(col, row int, dx, dy float64)
- type Rope
- type RopeConfig
- type RopeCurveMode
- type RopeJoinMode
Constants ¶
This section is empty.
Variables ¶
var ( // NewMeshFn creates a mesh node. Set by root package. NewMeshFn func(name string, img *ebiten.Image, verts []ebiten.Vertex, inds []uint16) *node.Node )
Function pointers wired by root to break dependency on constructors.
Functions ¶
func BuildPolygonFan ¶
func BuildPolygonFan(points []types.Vec2, textured bool, img *ebiten.Image) ([]ebiten.Vertex, []uint16)
BuildPolygonFan generates vertices and indices for an arbitrary simple polygon.
func ComputeMeshAABB ¶
ComputeMeshAABB scans DstX/DstY of the given vertices and returns the axis-aligned bounding box in local space.
func EarClipIndices ¶
EarClipIndices triangulates a simple polygon using ear-clipping.
func EnsureTransformedVerts ¶
EnsureTransformedVerts grows the node's transformedVerts buffer to fit len(n.Mesh.Vertices), using a high-water-mark strategy (never shrinks).
func EnsureWhitePixel ¶
EnsureWhitePixel returns a lazily-initialized 1x1 white pixel image.
func MeshWorldAABB ¶
func MeshWorldAABB(n *node.Node, transform [6]float64, worldAABBFn func([6]float64, float64, float64) types.Rect) types.Rect
MeshWorldAABB computes the world-space AABB for a mesh node, accounting for the fact that mesh vertices may not start at origin (0,0).
func MeshWorldAABBOffset ¶
MeshWorldAABBOffset computes mesh world AABB by transforming the four corners.
func NewPolygon ¶
NewPolygon creates an untextured polygon mesh from the given vertices.
func NewPolygonTextured ¶
NewPolygonTextured creates a textured polygon mesh.
func NewRegularPolygon ¶
NewRegularPolygon creates an untextured regular polygon with the given number of sides, centered at the origin with the specified radius.
func Perpendicular ¶
Perpendicular returns the unit left-perpendicular of the segment from a to b.
func Poly2DCross ¶
Poly2DCross returns (a-o) × (b-o). Positive = CCW turn.
func PtInTriangle ¶
PtInTriangle reports whether p lies inside triangle (a, b, c).
func RecomputeMeshAABB ¶
RecomputeMeshAABB recomputes the cached local-space AABB if dirty.
func SetPolygonPoints ¶
SetPolygonPoints updates the polygon's vertices.
Types ¶
type DistortionGrid ¶
type DistortionGrid struct {
// contains filtered or unexported fields
}
DistortionGrid provides a grid mesh that can be deformed per-vertex.
func NewDistortionGrid ¶
func NewDistortionGrid(name string, img *ebiten.Image, cols, rows int) *DistortionGrid
NewDistortionGrid creates a grid mesh over the given image. cols and rows define the number of cells (vertices = (cols+1) * (rows+1)).
func (*DistortionGrid) Cols ¶
func (g *DistortionGrid) Cols() int
Cols returns the number of grid columns.
func (*DistortionGrid) Node ¶
func (g *DistortionGrid) Node() *node.Node
Node returns the underlying mesh node.
func (*DistortionGrid) Reset ¶
func (g *DistortionGrid) Reset()
Reset returns all vertices to their original positions.
func (*DistortionGrid) Rows ¶
func (g *DistortionGrid) Rows() int
Rows returns the number of grid rows.
func (*DistortionGrid) SetAllVertices ¶
func (g *DistortionGrid) SetAllVertices(fn func(col, row int, restX, restY float64) (dx, dy float64))
SetAllVertices calls fn for each vertex, passing (col, row, restX, restY). fn returns the (dx, dy) displacement from the rest position.
func (*DistortionGrid) SetVertex ¶
func (g *DistortionGrid) SetVertex(col, row int, dx, dy float64)
SetVertex offsets a single grid vertex by (dx, dy) from its rest position.
type Rope ¶
type Rope struct {
// contains filtered or unexported fields
}
Rope generates a ribbon/rope mesh that follows a polyline path.
func NewRope ¶
NewRope creates a rope mesh node that renders a textured ribbon along the given points.
func (*Rope) Config ¶
func (r *Rope) Config() *RopeConfig
Config returns a pointer to the rope's configuration.
type RopeConfig ¶
type RopeConfig struct {
Width float64
JoinMode RopeJoinMode
CurveMode RopeCurveMode
Segments int // number of subdivisions (default 20)
Start *types.Vec2
End *types.Vec2
Sag float64
Controls [2]*types.Vec2
Amplitude float64
Frequency float64
Phase float64
// Custom callback. Receives a preallocated buffer; must return the slice to use.
PointsFunc func(buf []types.Vec2) []types.Vec2
}
RopeConfig configures a Rope mesh.
type RopeCurveMode ¶
type RopeCurveMode uint8
RopeCurveMode selects the curve algorithm used by Rope.Update().
const ( RopeCurveLine RopeCurveMode = iota RopeCurveCatenary RopeCurveQuadBezier RopeCurveCubicBezier RopeCurveWave RopeCurveCustom )
type RopeJoinMode ¶
type RopeJoinMode uint8
RopeJoinMode controls how segments join in a Rope mesh.
const ( RopeJoinMiter RopeJoinMode = iota RopeJoinBevel )