Documentation
¶
Index ¶
- func BilinearColor(g *GradientColors, u, v float64) sg.Color
- func LayoutNineSlice(nodes *NineSliceNodes, ns *NineSlice, w, h float64)
- func LerpColor(a, b sg.Color, t float64) sg.Color
- func RoundedRectBorderMesh(w, h, r, bw float64, segments int) ([]engine.Vertex, []uint16)
- func RoundedRectGradientMesh(w, h, cornerRadius float64, segments int, g *GradientColors) ([]engine.Vertex, []uint16)
- func RoundedRectGradientMeshPerCorner(w, h float64, rTL, rTR, rBR, rBL float64, segments int, g *GradientColors) ([]engine.Vertex, []uint16)
- func RoundedRectPoints(w, h, r float64, segments int) []sg.Vec2
- func RoundedRectPointsPerCorner(w, h float64, rTL, rTR, rBR, rBL float64, segments int) []sg.Vec2
- func SubRegion(base sg.TextureRegion, x, y, w, h uint16) sg.TextureRegion
- type Gradient
- type GradientColors
- type GradientMode
- type Insets
- type NineSlice
- type NineSliceNodes
- type Rect
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BilinearColor ¶
func BilinearColor(g *GradientColors, u, v float64) sg.Color
BilinearColor computes the bilinearly interpolated color at normalized coordinates (u, v) given the four corner colors of a GradientColors.
func LayoutNineSlice ¶
func LayoutNineSlice(nodes *NineSliceNodes, ns *NineSlice, w, h float64)
LayoutNineSlice positions and scales the 9 sprites to fill the given dimensions (w, h). Corners keep their natural pixel size; edges stretch along one axis; center stretches both.
func RoundedRectBorderMesh ¶
RoundedRectBorderMesh generates a triangle-strip ring between an outer rounded rect and an inner rounded rect (inset by bw on all sides). Returns raw vertices and indices for use with willow.NewMesh. All vertices use white pixel UV (SrcX=0.5, SrcY=0.5) and full white color (tinted by node.Color at render time).
func RoundedRectGradientMesh ¶
func RoundedRectGradientMesh(w, h, cornerRadius float64, segments int, g *GradientColors) ([]engine.Vertex, []uint16)
RoundedRectGradientMesh creates a mesh of vertices and indices for a gradient-filled rounded rectangle. cornerRadius can be 0 for sharp corners. The gradient colors are bilinearly interpolated across the rectangle using per-vertex coloring. The mesh uses fan triangulation from the centroid.
func RoundedRectGradientMeshPerCorner ¶
func RoundedRectGradientMeshPerCorner(w, h float64, rTL, rTR, rBR, rBL float64, segments int, g *GradientColors) ([]engine.Vertex, []uint16)
RoundedRectGradientMeshPerCorner creates a gradient-filled mesh with independent corner radii (top-left, top-right, bottom-right, bottom-left).
func RoundedRectPoints ¶
RoundedRectPoints generates the outline of a rounded rectangle as a closed polygon. Each corner is an arc of segments line segments. The radius r is clamped to min(w/2, h/2) to prevent overlap. Corners are generated clockwise: top-right, bottom-right, bottom-left, top-left.
func RoundedRectPointsPerCorner ¶
RoundedRectPointsPerCorner generates a rounded rectangle outline with independent radii for each corner: top-left, top-right, bottom-right, bottom-left. A radius of 0 produces a sharp corner.
func SubRegion ¶
func SubRegion(base sg.TextureRegion, x, y, w, h uint16) sg.TextureRegion
SubRegion computes a sub-region within a base TextureRegion. x, y, w, h are in pixel coordinates relative to the base region's origin.
Types ¶
type Gradient ¶
type Gradient struct {
Mode GradientMode
Colors GradientColors
}
Gradient is the value type produced by GradientEditor. Colors always carries all four corners; H and V modes keep linked corners in sync.
type GradientColors ¶
GradientColors defines per-corner colors for gradient backgrounds. Colors are interpolated bilinearly across the rectangle.
type GradientMode ¶
type GradientMode int
GradientMode selects which corners are independently editable.
const ( GradientModeH GradientMode = iota // horizontal: TL=BL, TR=BR GradientModeV // vertical: TL=TR, BL=BR GradientModeFourCorner // all 4 corners independent )
type Insets ¶
type Insets struct {
Top, Right, Bottom, Left float64
}
Insets represents spacing on four sides (top, right, bottom, left).
type NineSlice ¶
type NineSlice struct {
Region sg.TextureRegion
Insets Insets
InnerRegion Rect
CenterFill *GradientColors
}
NineSlice describes a nine-slice image for use as a component background. Region is the base texture region; Insets define the non-stretched border widths (top, right, bottom, left) in pixels. InnerRegion defines the content area within the grid, in local coordinates relative to Region. Components use this for padding reference point. CenterFill, when non-nil, replaces the center cell's texture with a gradient fill.
type NineSliceNodes ¶
NineSliceNodes holds the 9 sprite nodes that make up a nine-slice background. The naming convention follows CSS-style corners and edges:
TL T TR L C R BL B BR
func CreateNineSliceNodes ¶
func CreateNineSliceNodes(name string, container *sg.Node, ns *NineSlice) *NineSliceNodes
CreateNineSliceNodes creates 9 sprite nodes as children of the given container, each using the correct sub-region of the nine-slice image.