类型 Icon

API 文档由 Go 源码生成,内容为英文。

type Icon struct {
	// ViewBox is the source coordinate width, and the height too unless ViewHeight
	// says otherwise (Lucide's square icons use 24).
	ViewBox float32
	// ViewHeight is the source coordinate height of an icon that is not square,
	// such as a horizontal logo. Zero means the icon is square, ViewBox high.
	ViewHeight float32
	// Stroke is the source stroke width in view-box units (Lucide uses 2).
	Stroke float32
	// Cap and Join describe the source stroke geometry.
	Cap  StrokeCap
	Join StrokeJoin
	// Commands is the compiled path vocabulary, stroked (or filled when Stroke
	// is zero) in the tint DrawIcon is given.
	Commands []PathCommand
	// Layers are filled shapes with colors of their own, drawn after Commands
	// in order. They are what a multi-color glyph (a file-type icon, a brand
	// mark) is made of; the tint contributes only its alpha to them.
	Layers []IconLayer
}

Icon is one compiled vector glyph: immutable Path commands plus stroke metadata, produced ahead of time by the `viva icons` compiler from SVG sources. Icons carry no parser at runtime; an application embeds the generated Go values and paints them at any size in any tint.

var chevron = ui.Icon{
    ViewBox: 24,
    Stroke:  2,
    Cap:     ui.CapRound,
    Join:    ui.JoinRound,
    Commands: []ui.PathCommand{
        ui.MoveTo(6, 9), ui.QuadTo(12, 15, 18, 9),
    },
}
canvas.DrawIcon(chevron, bounds, theme.Foreground)