icon/icon.go

Functions Structs

Functions

func ClosePath

ClosePath creates a Close path operation.

func ClosePath() PathOp {
	return PathOp{Cmd: CmdClose}
}

func Cubic

Cubic creates a CubicTo path operation with control points (cx1, cy1),

(cx2, cy2) and endpoint (x, y).

func Cubic(cx1, cy1, cx2, cy2, x, y float32) PathOp {
	return PathOp{Cmd: CmdCubicTo, Params: [maxParams]float32{cx1, cy1, cx2, cy2, x, y}}
}

func Line

Line creates a LineTo path operation.

func Line(x, y float32) PathOp {
	return PathOp{Cmd: CmdLineTo, Params: [maxParams]float32{x, y}}
}

func Move

Move creates a MoveTo path operation.

func Move(x, y float32) PathOp {
	return PathOp{Cmd: CmdMoveTo, Params: [maxParams]float32{x, y}}
}

func Quad

Quad creates a QuadraticTo path operation with control point (cx, cy)

and endpoint (x, y).

func Quad(cx, cy, x, y float32) PathOp {
	return PathOp{Cmd: CmdQuadraticTo, Params: [maxParams]float32{cx, cy, x, y}}
}

func String

String returns a human-readable name for the command.

func (c Command) String() string {
	if int(c) < len(commandNames) {
		return commandNames[c]
	}
	return unknownStr
}

Structs

type PathOp struct

PathOp is a single drawing operation in an icon's path definition.

 

The number of significant parameters depends on the command:

- [CmdMoveTo]: 2 (x, y)

- [CmdLineTo]: 2 (x, y)

- [CmdCubicTo]: 6 (cx1, cy1, cx2, cy2, x, y)

- [CmdQuadraticTo]: 4 (cx, cy, x, y)

- [CmdClose]: 0

type PathOp struct {
	Cmd	Command
	Params	[maxParams]float32
}

type IconData struct

IconData defines a vector icon as a sequence of path operations within a

square viewbox.

 

IconData is a value type: it is safe to copy, compare by name, and store

in maps. The Ops slice is shared between copies; callers must not mutate

the slice after constructing the IconData.

type IconData struct {
	// Name is a human-readable identifier for the icon (e.g. "close", "check").
	Name	string

	// ViewBox is the side length of the square coordinate space in which the
	// path operations are defined. Typical value is 24 (Material Design).
	ViewBox	float32

	// Ops is the ordered sequence of path operations that define the icon shape.
	Ops	[]PathOp

	// StrokeWidth overrides the default stroke width in viewbox units.
	// Zero uses defaultStrokeWidth (1.5). SVG-sourced icons use thinner
	// strokes (e.g., 0.4) since their paths define filled shape outlines.
	StrokeWidth	float32

	// SVGData holds the original SVG path data string for fill rendering.
	// When non-empty and the canvas supports SVGFiller, the icon is rendered
	// as a filled path instead of stroked lines for higher quality.
	SVGData	string

	// SVGXML holds full SVG XML data for bitmap rasterization.
	// When non-empty, the icon is rendered via gg/svg.RenderWithColor
	// into a cached bitmap at the target size, matching JetBrains pipeline.
	// This produces pixel-perfect icons with proper fill, stroke, circles,
	// fill-rule, stroke-linecap, etc.
	SVGXML	[]byte
}

type PathGroup struct

PathGroup is a named group of path operations that share a color role.

Multi-color icons contain multiple groups, each rendered with a different

color from a [Palette].

type PathGroup struct {
	// ColorKey identifies which color from the Palette to use (e.g. "primary", "accent").
	ColorKey	string
	// Ops is the sequence of path operations for this group.
	Ops	[]PathOp
}

type MultiColorIcon struct

MultiColorIcon defines a vector icon with multiple color groups.

Each group is rendered with a different color from the provided [Palette].

 

MultiColorIcon is a value type: it is safe to copy and compare by name.

The Groups and their Ops slices are shared between copies; callers must

not mutate them after construction.

type MultiColorIcon struct {
	// Name is a human-readable identifier for the icon (e.g. "file_go", "git_branch").
	Name	string
	// ViewBox is the side length of the square coordinate space.
	ViewBox	float32
	// Groups is the ordered sequence of path groups, each drawn with its own color.
	Groups	[]PathGroup
}