icon

package
v0.1.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

Package icon provides a vector path icon system for the gogpu/ui toolkit.

Icons are defined as sequences of path commands (MoveTo, LineTo, CubicTo, Close) within a square viewbox (typically 24x24). The system scales icons to fit any display size while maintaining crisp stroked lines.

Single-Color Icons

Use IconData and Draw for icons rendered in a single color:

icon.Draw(canvas, icon.Check, bounds, widget.ColorBlack)

Multi-Color Icons

Use MultiColorIcon and DrawMulti for icons with multiple color groups. Each PathGroup maps to a color key in a Palette:

palette := icon.DefaultDarkPalette()
icon.DrawMulti(canvas, icon.FileGo, bounds, palette)

Built-in Icons

The package includes common Material-style icons as package-level variables:

Action icons (single-color):

File type icons (multi-color):

VCS icons (multi-color):

SVG Path Data

Use FromSVG to create icons from SVG path data strings. This parses the d attribute from SVG <path> elements using gg.ParseSVGPath:

var MyIcon = icon.FromSVG("my_icon", 16, "M8 2L14 8L8 14L2 8Z")

For runtime-loaded data that may be invalid, use TryFromSVG which returns an error instead of panicking.

Custom Icons

Define custom single-color icons by constructing IconData:

star := icon.IconData{
    Name:    "star",
    ViewBox: 24,
    Ops: []icon.PathOp{
        icon.Move(12, 2),
        icon.Line(15, 9),
        icon.Line(22, 9),
        // ... more ops
        icon.ClosePath(),
    },
}

Define custom multi-color icons by constructing MultiColorIcon:

myIcon := icon.MultiColorIcon{
    Name:    "my_icon",
    ViewBox: 24,
    Groups: []icon.PathGroup{
        {ColorKey: "primary", Ops: []icon.PathOp{icon.Move(0, 0), icon.Line(24, 24)}},
        {ColorKey: "accent",  Ops: []icon.PathOp{icon.Move(24, 0), icon.Line(0, 24)}},
    },
}

Widget

Use NewIcon to create a display widget for single-color icons:

w := icon.NewIcon(icon.Check, icon.Size(32), icon.Color(widget.ColorGreen))

Palettes

Use DefaultDarkPalette or DefaultLightPalette for theme-appropriate multi-color icon rendering. Custom palettes can be created as Palette maps.

Registries

Use DefaultRegistry for single-color icons and DefaultMultiColorRegistry for multi-color icons. Both are pre-populated with all built-in icons.

Index

Constants

View Source
const (
	// KeyPrimary is the default foreground color key (outlines, text).
	KeyPrimary = "primary"

	// KeyAccent is the primary accent color key (highlights, indicators).
	KeyAccent = "accent"

	// KeySecondary is a secondary/muted foreground color key.
	KeySecondary = "secondary"

	// KeySuccess is the success/positive color key (green tones).
	KeySuccess = "success"

	// KeyError is the error/negative color key (red tones).
	KeyError = "error"

	// KeyWarning is the warning/caution color key (yellow/orange tones).
	KeyWarning = "warning"

	// KeyGo is the Go language brand color key (cyan).
	KeyGo = "go"

	// KeyJSON is the JSON file type color key (gold).
	KeyJSON = "json"

	// KeyYAML is the YAML file type color key (green).
	KeyYAML = "yaml"

	// KeyRust is the Rust language brand color key (orange).
	KeyRust = "rust"

	// KeyPython is the Python language brand color key (blue).
	KeyPython = "python"

	// KeyMarkdown is the Markdown file type color key (gray).
	KeyMarkdown = "markdown"
)

Color key constants used by built-in multi-color icons.

Variables

View Source
var Add = IconData{
	Name:    "add",
	ViewBox: defaultViewBox,
	Ops: []PathOp{
		Move(12, 5), Line(12, 19),
		Move(5, 12), Line(19, 12),
	},
}

Add is a plus icon.

View Source
var ArrowBack = IconData{
	Name:    "arrow_back",
	ViewBox: defaultViewBox,
	Ops: []PathOp{
		Move(20, 12), Line(4, 12),
		Move(4, 12), Line(10, 6),
		Move(4, 12), Line(10, 18),
	},
}

ArrowBack is a left-pointing arrow.

View Source
var Check = FromSVG("check", 12,
	"M5.27908728,11 L4.8977527,11 L1.01339746,4.39807621 L2.48564065,3.54807621 L5.2408588,8.32025404 L9.51339746,0.92 L10.9856406,1.77 L5.65058539,11 L5.27908728,11 Z")

Check is a checkmark icon. Based on JetBrains IntelliJ checked.svg (Apache 2.0, 12x12 viewBox).

View Source
var ChevronDown = FromSVG("chevron_down", 16,
	"M8.00004 11.91L2.29004 6.20998L3.71004 4.78998L8.00004 9.08998L12.29 4.78998L13.71 6.20998L8.00004 11.91Z")

ChevronDown is a downward-pointing chevron. Based on JetBrains IntelliJ chevron-down.svg (Apache 2.0, 16x16 viewBox).

View Source
var ChevronRight = FromSVG("chevron_right", 16,
	"M6.21004 13.71L4.79004 12.29L9.09004 7.99998L4.79004 3.70998L6.21004 2.28998L11.91 7.99998L6.21004 13.71Z")

ChevronRight is a right-pointing chevron. Based on JetBrains IntelliJ chevron-right.svg (Apache 2.0, 16x16 viewBox).

View Source
var Close = FromSVG("close", 16,
	"M8 9.41421L4.20711 13.2071L2.79289 11.7929L6.58579 8L2.79289 4.20711L4.20711 2.79289L8 6.58579L11.7929 2.79289L13.2071 4.20711L9.41421 8L13.2071 11.7929L11.7929 13.2071L8 9.41421Z")

Close is an X mark icon. Based on JetBrains IntelliJ cancel.svg (Apache 2.0, 16x16 viewBox).

View Source
var Debug = IconData{
	Name:    "debug",
	ViewBox: defaultViewBox,
	Ops: []PathOp{

		Move(9, 8), Line(9, 16), Line(12, 18), Line(15, 16), Line(15, 8),
		Line(12, 6), ClosePath(),

		Move(10, 6), Line(12, 4), Line(14, 6),

		Move(9, 10), Line(5, 8),
		Move(9, 14), Line(5, 16),

		Move(15, 10), Line(19, 8),
		Move(15, 14), Line(19, 16),

		Move(10, 5), Line(8, 3),
		Move(14, 5), Line(16, 3),
	},
}

Debug is a simplified bug icon.

View Source
var Delete = IconData{
	Name:    "delete",
	ViewBox: defaultViewBox,
	Ops: []PathOp{

		Move(5, 7), Line(19, 7),
		Move(9, 7), Line(9, 5), Line(15, 5), Line(15, 7),

		Move(7, 7), Line(8, 19), Line(16, 19), Line(17, 7),

		Move(10, 9), Line(10, 17),
		Move(12, 9), Line(12, 17),
		Move(14, 9), Line(14, 17),
	},
}

Delete is a simplified trash can icon.

View Source
var ExpArrowLeft = FromSVGXML("exp_arrow_left", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.8516 3.14742C7.04686 3.34269 7.04686 3.65927 6.8516 3.85453L3.70539 7.00074L13.4989 7.00074C13.775 7.00074 13.9989 7.2246 13.9989 7.50074C13.9989 7.77688 13.775 8.00074 13.4989 8.00074L3.70491 8.00074L6.8516 11.1474C7.04686 11.3427 7.04686 11.6593 6.8516 11.8545C6.65634 12.0498 6.33976 12.0498 6.1445 11.8545L2.14449 7.85453C2.05073 7.76076 1.99805 7.63359 1.99805 7.50098C1.99805 7.36837 2.05073 7.24119 2.14449 7.14742L6.1445 3.14742C6.33976 2.95216 6.65634 2.95216 6.8516 3.14742Z" fill="#6C707E"/>
</svg>`))

ExpArrowLeft is the left arrow icon.

View Source
var ExpArrowRight = FromSVGXML("exp_arrow_right", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M9.14535 3.14742C8.95009 3.34269 8.95009 3.65927 9.14535 3.85453L12.2916 7.00074L2.49805 7.00074C2.2219 7.00074 1.99805 7.2246 1.99805 7.50074C1.99805 7.77688 2.2219 8.00074 2.49805 8.00074L12.292 8.00074L9.14535 11.1474C8.95008 11.3427 8.95008 11.6593 9.14535 11.8545C9.34061 12.0498 9.65719 12.0498 9.85245 11.8545L13.8525 7.85453C13.9462 7.76076 13.9989 7.63359 13.9989 7.50098C13.9989 7.36837 13.9462 7.24119 13.8525 7.14742L9.85245 3.14742C9.65719 2.95216 9.34061 2.95216 9.14535 3.14742Z" fill="#6C707E"/>
</svg>`))

ExpArrowRight is the right arrow icon.

View Source
var ExpChevronDown = FromSVGXML("exp_chevron_down", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11.5 6.25L8 9.75L4.5 6.25" stroke="#818594" stroke-linecap="round"/>
</svg>`))

ExpChevronDown is a downward-pointing chevron.

View Source
var ExpChevronRight = FromSVGXML("exp_chevron_right", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6 11.5L9.5 8L6 4.5" stroke="#818594" stroke-linecap="round"/>
</svg>`))

ExpChevronRight is a right-pointing chevron.

View Source
var ExpClose = FromSVGXML("exp_close", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M3.5 12.5L12.5 3.5M12.5 12.5L3.5 3.5" stroke="#6C707E" stroke-linecap="round"/>
</svg>`))

ExpClose is the close/X icon (two crossed lines).

View Source
var ExpDebug = FromSVGXML("exp_debug", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M10.6907 4.4347C10.6974 4.35728 10.7008 4.27899 10.7008 4.2C10.7008 2.70883 9.49195 1.5 8.00078 1.5C6.50961 1.5 5.30078 2.70883 5.30078 4.2C5.30078 4.27871 5.30416 4.35672 5.3108 4.43387C4.83909 4.6943 4.43389 5.06042 4.12714 5.5003L2.0178 4.36019C1.77487 4.22888 1.4715 4.31937 1.34019 4.5623C1.20889 4.80523 1.29938 5.1086 1.5423 5.2399L3.67822 6.39438C3.5626 6.74191 3.5 7.11364 3.5 7.5V8.50006H1C0.723858 8.50006 0.5 8.72392 0.5 9.00006C0.5 9.2762 0.723858 9.50006 1 9.50006H3.5V10C3.5 10.4892 3.57807 10.9602 3.72243 11.4012L1.52989 12.667C1.29075 12.8051 1.20881 13.1109 1.34688 13.3501C1.48495 13.5892 1.79075 13.6711 2.02989 13.5331L4.14017 12.3147C4.92703 13.624 6.36122 14.5 8 14.5C9.63821 14.5 11.072 13.6246 11.859 12.3161L13.967 13.5331C14.2061 13.6712 14.5119 13.5893 14.65 13.3501C14.7881 13.111 14.7061 12.8052 14.467 12.6671L12.2771 11.4028C12.4217 10.9613 12.5 10.4898 12.5 10V9.49982H15C15.2761 9.49982 15.5 9.27596 15.5 8.99982C15.5 8.72367 15.2761 8.49982 15 8.49982H12.5V7.5C12.5 7.11367 12.4374 6.74197 12.3218 6.39447L14.4551 5.23979C14.698 5.10835 14.7883 4.80492 14.6569 4.56207C14.5254 4.31922 14.222 4.2289 13.9791 4.36035L11.8729 5.50036C11.5665 5.06092 11.1618 4.69509 10.6907 4.4347ZM6.30577 4.06885C6.53015 4.02369 6.76231 4 7 4H9C9.23825 4 9.47094 4.02381 9.69582 4.06917C9.62902 3.19142 8.89564 2.5 8.00078 2.5C7.10603 2.5 6.37272 3.19125 6.30577 4.06885ZM4.5 7.5C4.5 6.11929 5.61929 5 7 5H9C10.3807 5 11.5 6.11929 11.5 7.5V10C11.5 11.933 9.933 13.5 8 13.5C6.067 13.5 4.5 11.933 4.5 10V7.5Z" fill="#208A3C"/>
<path d="M7 4C6.76231 4 6.53015 4.02369 6.30577 4.06885C6.37272 3.19125 7.10603 2.5 8.00078 2.5C8.89564 2.5 9.62902 3.19142 9.69582 4.06917C9.47094 4.02381 9.23825 4 9 4H7Z" fill="#F2FCF3"/>
<path d="M7 5C5.61929 5 4.5 6.11929 4.5 7.5V10C4.5 11.933 6.067 13.5 8 13.5C9.933 13.5 11.5 11.933 11.5 10V7.5C11.5 6.11929 10.3807 5 9 5H7Z" fill="#F2FCF3"/>
</svg>`))

ExpDebug is the debug/bug icon (green bug).

View Source
var ExpFolder = FromSVGXML("exp_folder", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8.10584 4.34613L8.25344 4.5H8.46667H13C13.8284 4.5 14.5 5.17157 14.5 6V12.1333C14.5 12.9529 13.932 13.5 13.3667 13.5H2.63333C2.06804 13.5 1.5 12.9529 1.5 12.1333V3.86667C1.5 3.04707 2.06804 2.5 2.63333 2.5H6.1217C6.25792 2.5 6.38824 2.55557 6.48253 2.65387L8.10584 4.34613Z" fill="#EBECF0" stroke="#6C707E"/>
</svg>`))

ExpFolder is the folder icon (expui project style).

View Source
var ExpMenu = FromSVGXML("exp_menu", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2 3.5C2 3.22386 2.22386 3 2.5 3H13.5C13.7761 3 14 3.22386 14 3.5C14 3.77614 13.7761 4 13.5 4H2.5C2.22386 4 2 3.77614 2 3.5Z" fill="#6C707E"/>
<path d="M2 7.5C2 7.22386 2.22386 7 2.5 7H13.5C13.7761 7 14 7.22386 14 7.5C14 7.77614 13.7761 8 13.5 8H2.5C2.22386 8 2 7.77614 2 7.5Z" fill="#6C707E"/>
<path d="M2.5 11C2.22386 11 2 11.2239 2 11.5C2 11.7761 2.22386 12 2.5 12H13.5C13.7761 12 14 11.7761 14 11.5C14 11.2239 13.7761 11 13.5 11H2.5Z" fill="#6C707E"/>
</svg>`))

ExpMenu is the hamburger menu icon (three rounded lines).

View Source
var ExpRefresh = FromSVGXML("exp_refresh", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M2.5 9V8C2.5 4.96243 4.96243 2.5 8 2.5C9.10679 2.5 10.1372 2.82692 11 3.38947" stroke="#6C707E" stroke-linecap="round"/>
<path d="M5 12.6105C5.86278 13.1731 6.89321 13.5 8 13.5C11.0376 13.5 13.5 11.0376 13.5 8V7" stroke="#6C707E" stroke-linecap="round"/>
<path d="M0.49997 7.50027L2.5 9.5L4.49998 7.50023" stroke="#6C707E" stroke-linecap="round"/>
<path d="M11.5 8.49982L13.5 6.5L15.5 8.49982" stroke="#6C707E" stroke-linecap="round"/>
</svg>`))

ExpRefresh is the refresh/sync icon (two curved arrows).

View Source
var ExpRun = FromSVGXML("exp_run", []byte(`<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M12 6.13399C12.6667 6.51889 12.6667 7.48114 12 7.86604L3 13.0622C2.33333 13.4471 1.5 12.966 1.5 12.1962L1.5 1.80386C1.5 1.03406 2.33333 0.552935 3 0.937835L12 6.13399Z" fill="#F2FCF3" stroke="#208A3C"/>
</svg>`))

ExpRun is the run/play icon (green play triangle).

View Source
var ExpSave = FromSVGXML("exp_save", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M5.5 3V5.5H10.5V3M4.5 13V9.5H11.5V13M2.5 13.5V2.5H11.5L13.5 4.5V13.5H2.5Z" stroke="#6C707E" stroke-linejoin="round"/>
</svg>`))

ExpSave is the save/floppy disk icon.

View Source
var ExpSearch = FromSVGXML("exp_search", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="7" cy="7" r="4.5" stroke="#6C707E"/>
<path d="M10.1992 10.2002L13.4992 13.4961" stroke="#6C707E" stroke-linecap="round"/>
</svg>`))

ExpSearch is the search/magnifying glass icon (circle + handle).

View Source
var ExpSettings = FromSVGXML("exp_settings", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M3.22655 4.36961C2.92233 4.76924 2.66735 5.20781 2.47037 5.67626L3.30992 7.0943C3.6406 7.65283 3.6406 8.34718 3.30992 8.9057L2.47037 10.3237C2.66736 10.7922 2.92233 11.2308 3.22656 11.6304L4.87261 11.6124C5.52165 11.6053 6.12297 11.9524 6.44133 12.5181L7.24899 13.953C7.49593 13.984 7.74792 14 8.00408 14C8.2602 14 8.51214 13.984 8.75904 13.9531L9.56671 12.5181C9.88507 11.9524 10.4864 11.6053 11.1354 11.6124L12.7816 11.6304C13.0858 11.2308 13.3408 10.7923 13.5377 10.3239L12.6981 8.9057C12.3674 8.34718 12.3674 7.65283 12.6981 7.0943L13.5377 5.67613C13.3408 5.20773 13.0858 4.76921 12.7816 4.36961L11.1354 4.38764C10.4864 4.39475 9.88507 4.04758 9.56671 3.48194L8.75904 2.04693C8.51214 2.01599 8.2602 2 8.00408 2C7.74792 2 7.49594 2.016 7.24899 2.04695L6.44133 3.48194C6.12297 4.04758 5.52165 4.39475 4.87261 4.38764L3.22655 4.36961ZM10.655 8.00001C10.655 9.46412 9.46811 10.651 8.004 10.651C6.5399 10.651 5.353 9.46412 5.353 8.00001C5.353 6.53591 6.5399 5.34902 8.004 5.34902C9.46811 5.34902 10.655 6.53591 10.655 8.00001ZM4.88356 3.3877C5.16752 3.39081 5.4306 3.23892 5.56988 2.99146L6.43817 1.44875C6.54914 1.25159 6.7401 1.1101 6.96387 1.07676C7.30327 1.0262 7.65062 1 8.00408 1C8.3575 1 8.7048 1.02619 9.04414 1.07674C9.26792 1.11007 9.45889 1.25157 9.56986 1.44873L10.4382 2.99146C10.5774 3.23892 10.8405 3.39081 11.1245 3.3877L12.8938 3.36832C13.1196 3.36585 13.3372 3.46012 13.4781 3.63661C13.9099 4.17766 14.2632 4.78416 14.5207 5.43884C14.6034 5.6491 14.5763 5.88489 14.4612 6.07931L13.5586 7.60376C13.4139 7.84811 13.4139 8.15189 13.5586 8.39625L14.4612 9.92069C14.5763 10.1151 14.6034 10.3509 14.5207 10.5612C14.2632 11.2158 13.9099 11.8223 13.4781 12.3634C13.3372 12.5399 13.1196 12.6342 12.8938 12.6317L11.1245 12.6123C10.8405 12.6092 10.5774 12.7611 10.4382 13.0085L9.56986 14.5513C9.45889 14.7484 9.26792 14.8899 9.04414 14.9233C8.7048 14.9738 8.3575 15 8.00408 15C7.65062 15 7.30327 14.9738 6.96387 14.9232C6.7401 14.8899 6.54914 14.7484 6.43817 14.5512L5.56988 13.0085C5.4306 12.7611 5.16752 12.6092 4.88356 12.6123L3.1144 12.6317C2.8886 12.6342 2.67096 12.5399 2.5301 12.3634C2.09822 11.8223 1.74489 11.2158 1.48738 10.561C1.40469 10.3508 1.43184 10.115 1.54695 9.92057L2.44942 8.39625C2.5941 8.15189 2.5941 7.84811 2.44942 7.60376L1.54695 6.07944C1.43184 5.88502 1.40469 5.64924 1.48738 5.43898C1.74489 4.78425 2.09822 4.1777 2.53009 3.63661C2.67096 3.46012 2.8886 3.36585 3.1144 3.36832L4.88356 3.3877ZM9.655 8.00001C9.655 8.91183 8.91582 9.65101 8.004 9.65101C7.09218 9.65101 6.353 8.91183 6.353 8.00001C6.353 7.08819 7.09218 6.34902 8.004 6.34902C8.91582 6.34902 9.655 7.08819 9.655 8.00001Z" fill="#6C707E"/>
</svg>`))

ExpSettings is the gear/settings icon (detailed gear with center hole).

View Source
var FileConfig = MultiColorIcon{
	Name:    "file_config",
	ViewBox: defaultViewBox,
	Groups: []PathGroup{
		{ColorKey: KeyPrimary, Ops: docOutlineOps()},
		{ColorKey: KeySecondary, Ops: []PathOp{

			Move(12, 9), Line(13, 10), Line(14, 10), Line(15, 11),
			Line(14, 12), Line(15, 13), Line(14, 14), Line(13, 14),
			Line(12, 15), Line(11, 14), Line(10, 14), Line(9, 13),
			Line(10, 12), Line(9, 11), Line(10, 10), Line(11, 10),
			ClosePath(),
		}},
	},
}

FileConfig is a configuration file icon with gear indicator.

View Source
var FileGeneric = MultiColorIcon{
	Name:    "file_generic",
	ViewBox: defaultViewBox,
	Groups: []PathGroup{
		{ColorKey: KeyPrimary, Ops: docOutlineOps()},
		{ColorKey: KeySecondary, Ops: []PathOp{

			Move(8, 11), Line(16, 11),
			Move(8, 14), Line(16, 14),
			Move(8, 17), Line(13, 17),
		}},
	},
}

FileGeneric is a plain document outline with no type indicator.

View Source
var FileGo = MultiColorIcon{
	Name:    "file_go",
	ViewBox: defaultViewBox,
	Groups: []PathGroup{
		{ColorKey: KeyPrimary, Ops: docOutlineOps()},
		{ColorKey: KeyGo, Ops: []PathOp{

			Move(8, 13), Line(12, 13), Line(12, 11), Line(10, 11),
			Move(11, 12), Line(12, 12),

			Move(13, 13), Line(13, 11), Line(16, 11), Line(16, 13), ClosePath(),
		}},
	},
}

FileGo is a Go source file icon with "Go" text indicator.

View Source
var FileImage = MultiColorIcon{
	Name:    "file_image",
	ViewBox: defaultViewBox,
	Groups: []PathGroup{
		{ColorKey: KeyPrimary, Ops: docOutlineOps()},
		{ColorKey: KeyAccent, Ops: []PathOp{

			Move(8, 16), Line(11, 11), Line(13, 14), Line(15, 12), Line(17, 16),
			ClosePath(),

			Move(15, 10), Line(16, 10), Line(16, 11), Line(15, 11), ClosePath(),
		}},
	},
}

FileImage is an image file icon with landscape indicator.

View Source
var FileJSON = MultiColorIcon{
	Name:    "file_json",
	ViewBox: defaultViewBox,
	Groups: []PathGroup{
		{ColorKey: KeyPrimary, Ops: docOutlineOps()},
		{ColorKey: KeyJSON, Ops: []PathOp{

			Move(10, 10), Line(9, 10), Line(9, 12), Line(8, 12),
			Line(9, 12), Line(9, 14), Line(10, 14),

			Move(14, 10), Line(15, 10), Line(15, 12), Line(16, 12),
			Line(15, 12), Line(15, 14), Line(14, 14),
		}},
	},
}

FileJSON is a JSON file icon with curly braces indicator.

View Source
var FileMD = MultiColorIcon{
	Name:    "file_md",
	ViewBox: defaultViewBox,
	Groups: []PathGroup{
		{ColorKey: KeyPrimary, Ops: docOutlineOps()},
		{ColorKey: KeyMarkdown, Ops: []PathOp{

			Move(8, 16), Line(8, 10), Line(10, 13), Line(12, 10), Line(12, 16),

			Move(15, 11), Line(15, 15),
			Move(13, 13), Line(15, 15), Line(17, 13),
		}},
	},
}

FileMD is a Markdown file icon with "M" and down-arrow indicator.

View Source
var FileTest = MultiColorIcon{
	Name:    "file_test",
	ViewBox: defaultViewBox,
	Groups: []PathGroup{
		{ColorKey: KeyPrimary, Ops: docOutlineOps()},
		{ColorKey: KeySuccess, Ops: []PathOp{

			Move(9, 13), Line(11, 15), Line(15, 10),
		}},
	},
}

FileTest is a test file icon with checkmark indicator.

View Source
var FileYAML = MultiColorIcon{
	Name:    "file_yaml",
	ViewBox: defaultViewBox,
	Groups: []PathGroup{
		{ColorKey: KeyPrimary, Ops: docOutlineOps()},
		{ColorKey: KeyYAML, Ops: []PathOp{

			Move(9, 10), Line(12, 13),
			Move(15, 10), Line(12, 13),
			Move(12, 13), Line(12, 17),
		}},
	},
}

FileYAML is a YAML file icon with "Y" indicator.

View Source
var Filter = IconData{
	Name:    "filter",
	ViewBox: defaultViewBox,
	Ops: []PathOp{
		Move(4, 5), Line(20, 5), Line(14, 12), Line(14, 19), Line(10, 17),
		Line(10, 12), ClosePath(),
	},
}

Filter is a funnel icon.

View Source
var FolderClosed = FromSVG("folder_closed", 16,
	"M1,13 L15,13 L15,4 L7.98457,4 L6.69633,2.71149 "+
		"C6.22161957,2.28559443 5.61570121,2.03457993 4.97888,2 L1.05128,2 "+
		"C1.02295884,2 1,2.02295884 1,2.05128 L1,13 Z")

FolderClosed is a closed folder outline. Based on JetBrains IntelliJ folder.svg (Apache 2.0, 16x16 viewBox).

View Source
var FolderOpen = FromSVG("folder_open", 16,
	"M4.32342122,7 L2,11.0147552 L2,7 L2,5 L2,3 L6.60006714,3 L7.75640322,5 L14,5 L14,7 L4.32342122,7 Z "+
		"M4.89129639,8 L16,8 L13.1082845,13 L2.00248718,13 L4.89129639,8 Z")

FolderOpen is an open folder outline. Based on JetBrains IntelliJ menu-open.svg (Apache 2.0, 16x16 viewBox).

View Source
var Gear = FromSVG("gear", 16,
	"M12.7078144,8.94092644 L14.1860171,10.0014962 "+
		"C13.9015285,10.8814083 13.4345167,11.6792367 12.8296171,12.3503459 "+
		"L11.1720587,11.6025852 C10.7002906,12.0182974 10.1462196,12.3427961 9.53742767,12.5484995 "+
		"L9.35682478,14.3581758 C8.91920787,14.4511061 8.46531382,14.5 8,14.5 "+
		"C7.53468618,14.5 7.08079213,14.4511061 6.64317522,14.3581758 "+
		"L6.46257231,12.5484994 C5.85378047,12.3427959 5.29970962,12.0182972 4.82794166,11.6025851 "+
		"L3.1703829,12.3503459 C2.5654833,11.6792367 2.0984715,10.8814083 1.8139829,10.0014962 "+
		"L3.29218604,8.94092614 C3.23171292,8.63665953 3.20000005,8.32203335 3.20000005,8.00000024 "+
		"C3.20000005,7.67796698 3.23171295,7.36334066 3.29218612,7.05907392 "+
		"L1.8139829,5.99850385 C2.0984715,5.11859166 2.5654833,4.32076327 3.1703829,3.64965409 "+
		"L4.82794202,4.39741509 C5.29970989,3.98170311 5.85378059,3.65720451 6.46257226,3.45150114 "+
		"L6.64317522,1.64182422 C7.08079213,1.54889386 7.53468618,1.5 8,1.5 "+
		"C8.46531382,1.5 8.91920787,1.54889386 9.35682478,1.64182422 "+
		"L9.53742772,3.45150097 C10.1462195,3.65720431 10.7002903,3.98170292 11.1720583,4.39741495 "+
		"L12.8296171,3.64965409 C13.4345167,4.32076327 13.9015285,5.11859166 14.1860171,5.99850385 "+
		"L12.7078143,7.05907362 C12.7682875,7.36334046 12.8000004,7.67796687 12.8000004,8.00000024 "+
		"C12.8000004,8.32203346 12.7682875,8.63665973 12.7078144,8.94092644 Z "+
		"M7.99999976,10.3003956 C9.27025466,10.3003956 10.2999997,9.27056196 10.2999997,8.00019773 "+
		"C10.2999997,6.72983349 9.27025466,5.69999981 7.99999976,5.69999981 "+
		"C6.72974486,5.69999981 5.69999981,6.72983349 5.69999981,8.00019773 "+
		"C5.69999981,9.27056196 6.72974486,10.3003956 7.99999976,10.3003956 Z")

Gear is a gear/cog icon for settings. Based on JetBrains IntelliJ gearPlain.svg (Apache 2.0, 16x16 viewBox). This is an alias-style variant distinct from Settings with a different visual weight.

View Source
var GitBranch = MultiColorIcon{
	Name:    "git_branch",
	ViewBox: defaultViewBox,
	Groups: []PathGroup{
		{ColorKey: KeyPrimary, Ops: []PathOp{

			Move(8, 6), Line(8, 14),

			Move(8, 10), Line(14, 6),
		}},
		{ColorKey: KeyAccent, Ops: []PathOp{

			Move(7, 5), Line(9, 5), Line(9, 7), Line(7, 7), ClosePath(),

			Move(7, 14), Line(9, 14), Line(9, 16), Line(7, 16), ClosePath(),

			Move(13, 5), Line(15, 5), Line(15, 7), Line(13, 7), ClosePath(),
		}},
	},
}

GitBranch is a branch icon with a line forking into two.

View Source
var GitCommit = MultiColorIcon{
	Name:    "git_commit",
	ViewBox: defaultViewBox,
	Groups: []PathGroup{
		{ColorKey: KeyPrimary, Ops: []PathOp{

			Move(12, 4), Line(12, 9),

			Move(12, 15), Line(12, 20),
		}},
		{ColorKey: KeyAccent, Ops: []PathOp{

			Move(14, 9), Line(15, 10), Line(15, 14), Line(14, 15),
			Line(10, 15), Line(9, 14), Line(9, 10), Line(10, 9),
			ClosePath(),
		}},
	},
}

GitCommit is a commit icon — a circle on a vertical line.

View Source
var GitMerge = MultiColorIcon{
	Name:    "git_merge",
	ViewBox: defaultViewBox,
	Groups: []PathGroup{
		{ColorKey: KeyPrimary, Ops: []PathOp{

			Move(8, 6), Line(8, 18),

			Move(16, 8), Line(12, 12), Line(8, 14),
		}},
		{ColorKey: KeyAccent, Ops: []PathOp{

			Move(7, 5), Line(9, 5), Line(9, 7), Line(7, 7), ClosePath(),

			Move(7, 17), Line(9, 17), Line(9, 19), Line(7, 19), ClosePath(),

			Move(15, 6), Line(17, 6), Line(17, 8), Line(15, 8), ClosePath(),
		}},
	},
}

GitMerge is a merge icon — two branches converging.

View Source
var GitModified = MultiColorIcon{
	Name:    "git_modified",
	ViewBox: defaultViewBox,
	Groups: []PathGroup{
		{ColorKey: KeyPrimary, Ops: []PathOp{

			Move(14, 7), Line(17, 10), Line(17, 14), Line(14, 17),
			Line(10, 17), Line(7, 14), Line(7, 10), Line(10, 7),
			ClosePath(),
		}},
		{ColorKey: KeyWarning, Ops: []PathOp{

			Move(13, 10), Line(14, 11), Line(14, 13), Line(13, 14),
			Line(11, 14), Line(10, 13), Line(10, 11), Line(11, 10),
			ClosePath(),
		}},
	},
}

GitModified is a modified file indicator — a filled dot.

View Source
var GitPR = MultiColorIcon{
	Name:    "git_pr",
	ViewBox: defaultViewBox,
	Groups: []PathGroup{
		{ColorKey: KeyPrimary, Ops: []PathOp{

			Move(8, 6), Line(8, 18),

			Move(16, 6), Line(16, 18),

			Move(16, 8), Line(12, 8),
			Move(14, 6), Line(12, 8), Line(14, 10),
		}},
		{ColorKey: KeyAccent, Ops: []PathOp{

			Move(7, 4), Line(9, 4), Line(9, 6), Line(7, 6), ClosePath(),

			Move(7, 18), Line(9, 18), Line(9, 20), Line(7, 20), ClosePath(),

			Move(15, 4), Line(17, 4), Line(17, 6), Line(15, 6), ClosePath(),

			Move(15, 18), Line(17, 18), Line(17, 20), Line(15, 20), ClosePath(),
		}},
	},
}

GitPR is a pull request icon — two dots with arrows indicating direction.

View Source
var Menu = IconData{
	Name:    "menu",
	ViewBox: defaultViewBox,
	Ops: []PathOp{
		Move(4, 7), Line(20, 7),
		Move(4, 12), Line(20, 12),
		Move(4, 17), Line(20, 17),
	},
}

Menu is a hamburger menu icon (three horizontal lines).

View Source
var Minus = IconData{
	Name:    "minus",
	ViewBox: defaultViewBox,
	Ops: []PathOp{
		Move(5, 12), Line(19, 12),
	},
}

Minus is a minus/dash sign icon.

View Source
var MustFromSVG = FromSVG

MustFromSVG is an alias for FromSVG provided for clarity. It creates an IconData from SVG path data, panicking on invalid input.

Deprecated: Use FromSVG directly; it already panics on error.

View Source
var Pause = IconData{
	Name:    "pause",
	ViewBox: defaultViewBox,
	Ops: []PathOp{
		Move(7, 5), Line(7, 19),
		Move(17, 5), Line(17, 19),
	},
}

Pause is two vertical bars (pause execution).

View Source
var Play = IconData{
	Name:    "play",
	ViewBox: defaultViewBox,
	Ops: []PathOp{
		Move(7, 5), Line(19, 12), Line(7, 19), ClosePath(),
	},
}

Play is a right-pointing triangle (run/execute).

View Source
var Plus = IconData{
	Name:    "plus",
	ViewBox: defaultViewBox,
	Ops: []PathOp{
		Move(12, 5), Line(12, 19),
		Move(5, 12), Line(19, 12),
	},
}

Plus is a plus sign icon. Same shape as Add with a different name for DevTools contexts where "plus" is more descriptive than "add".

View Source
var Refresh = FromSVG("refresh", 16,
	"M12.5747152,11.8852806 C11.4741474,13.1817355 9.83247882,14.0044386 7.99865879,14.0044386 "+
		"C5.03907292,14.0044386 2.57997332,11.8615894 2.08820756,9.0427473 "+
		"L3.94774327,9.10768372 C4.43372186,10.8898575 6.06393114,12.2000519 8.00015362,12.2000519 "+
		"C9.30149237,12.2000519 10.4645985,11.6082097 11.2349873,10.6790094 "+
		"L9.05000019,8.71167959 L14.0431479,8.44999981 L14.3048222,13.4430431 "+
		"L12.5747152,11.8852806 Z "+
		"M3.42785637,4.11741586 C4.52839138,2.82452748 6.16775464,2.00443857 7.99865879,2.00443857 "+
		"C10.918604,2.00443857 13.3513802,4.09026967 13.8882946,6.8532307 "+
		"L12.0226389,6.78808057 C11.5024872,5.05935553 9.89838095,3.8000774 8.00015362,3.8000774 "+
		"C6.69867367,3.8000774 5.53545628,4.39204806 4.76506921,5.32142241 "+
		"L6.95482203,7.29304326 L1.96167436,7.55472304 L1.70000005,2.56167973 "+
		"L3.42785637,4.11741586 Z")

Refresh is circular arrows icon. Based on JetBrains IntelliJ refresh.svg (Apache 2.0, 16x16 viewBox).

View Source
var Search = FromSVG("search", 16,
	"M11.038136,9.94904865 L13.9980971,12.9090097 L12.9374369,13.9696699 L9.98176525,11.0139983 "+
		"C9.14925083,11.6334368 8.11743313,12 7,12 C4.23857625,12 2,9.76142375 2,7 "+
		"C2,4.23857625 4.23857625,2 7,2 C9.76142375,2 12,4.23857625 12,7 "+
		"C12,8.1028408 11.642948,9.12228765 11.038136,9.94904865 Z "+
		"M7,11 C9.209139,11 11,9.209139 11,7 C11,4.790861 9.209139,3 7,3 "+
		"C4.790861,3 3,4.790861 3,7 C3,9.209139 4.790861,11 7,11 Z")

Search is a magnifying glass icon. Based on JetBrains IntelliJ search.svg (Apache 2.0, 16x16 viewBox).

View Source
var Settings = FromSVG("settings", 16,
	"M12.7078144,8.94092644 L14.1860171,10.0014962 "+
		"C13.9015285,10.8814083 13.4345167,11.6792367 12.8296171,12.3503459 "+
		"L11.1720587,11.6025852 C10.7002906,12.0182974 10.1462196,12.3427961 9.53742767,12.5484995 "+
		"L9.35682478,14.3581758 C8.91920787,14.4511061 8.46531382,14.5 8,14.5 "+
		"C7.53468618,14.5 7.08079213,14.4511061 6.64317522,14.3581758 "+
		"L6.46257231,12.5484994 C5.85378047,12.3427959 5.29970962,12.0182972 4.82794166,11.6025851 "+
		"L3.1703829,12.3503459 C2.5654833,11.6792367 2.0984715,10.8814083 1.8139829,10.0014962 "+
		"L3.29218604,8.94092614 C3.23171292,8.63665953 3.20000005,8.32203335 3.20000005,8.00000024 "+
		"C3.20000005,7.67796698 3.23171295,7.36334066 3.29218612,7.05907392 "+
		"L1.8139829,5.99850385 C2.0984715,5.11859166 2.5654833,4.32076327 3.1703829,3.64965409 "+
		"L4.82794202,4.39741509 C5.29970989,3.98170311 5.85378059,3.65720451 6.46257226,3.45150114 "+
		"L6.64317522,1.64182422 C7.08079213,1.54889386 7.53468618,1.5 8,1.5 "+
		"C8.46531382,1.5 8.91920787,1.54889386 9.35682478,1.64182422 "+
		"L9.53742772,3.45150097 C10.1462195,3.65720431 10.7002903,3.98170292 11.1720583,4.39741495 "+
		"L12.8296171,3.64965409 C13.4345167,4.32076327 13.9015285,5.11859166 14.1860171,5.99850385 "+
		"L12.7078143,7.05907362 C12.7682875,7.36334046 12.8000004,7.67796687 12.8000004,8.00000024 "+
		"C12.8000004,8.32203346 12.7682875,8.63665973 12.7078144,8.94092644 Z "+
		"M7.99999976,10.3003956 C9.27025466,10.3003956 10.2999997,9.27056196 10.2999997,8.00019773 "+
		"C10.2999997,6.72983349 9.27025466,5.69999981 7.99999976,5.69999981 "+
		"C6.72974486,5.69999981 5.69999981,6.72983349 5.69999981,8.00019773 "+
		"C5.69999981,9.27056196 6.72974486,10.3003956 7.99999976,10.3003956 Z")

Settings is a gear icon for settings. Based on JetBrains IntelliJ gearPlain.svg (Apache 2.0, 16x16 viewBox).

View Source
var Stop = IconData{
	Name:    "stop",
	ViewBox: defaultViewBox,
	Ops: []PathOp{
		Move(6, 6), Line(18, 6), Line(18, 18), Line(6, 18), ClosePath(),
	},
}

Stop is a square (stop execution).

View Source
var Terminal = IconData{
	Name:    "terminal",
	ViewBox: defaultViewBox,
	Ops: []PathOp{

		Move(5, 8), Line(11, 12), Line(5, 16),

		Move(13, 16), Line(19, 16),
	},
}

Terminal is a terminal/console prompt icon (>_).

View Source
var ToolCommit = FromSVGXML("tool_commit", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M8 10C9.10457 10 10 9.10457 10 8C10 6.89543 9.10457 6 8 6C6.89543 6 6 6.89543 6 8C6 9.10457 6.89543 10 8 10ZM10.9585 7.5C10.7205 6.08114 9.4865 5 8 5C6.5135 5 5.27952 6.08114 5.04148 7.5H0.5C0.223858 7.5 0 7.72386 0 8C0 8.27614 0.223858 8.5 0.5 8.5H5.04148C5.27952 9.91886 6.5135 11 8 11C9.4865 11 10.7205 9.91886 10.9585 8.5H15.5C15.7761 8.5 16 8.27614 16 8C16 7.72386 15.7761 7.5 15.5 7.5H10.9585Z" fill="#6C707E"/>
</svg>`))

ToolCommit is the Commit tool window icon (circle on horizontal line).

View Source
var ToolGit = FromSVGXML("tool_git", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="4.5" cy="4" r="2" stroke="#6C707E"/>
<path d="M4.5 11.5H8.5C9.60457 11.5 10.5 10.6046 10.5 9.5V9.5V8" stroke="#6C707E"/>
<path d="M4.5 6.5L4.5 14.5" stroke="#6C707E" stroke-linecap="round" stroke-linejoin="round"/>
<circle cx="10.5" cy="6" r="2" stroke="#6C707E"/>
</svg>`))

ToolGit is the Git/VCS tool window icon (branch with circles).

View Source
var ToolNotifications = FromSVGXML("tool_notifications", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M6.95674 14.4579H9.04941C8.99287 14.5871 8.91235 14.7059 8.81068 14.8076C8.59649 15.0218 8.30599 15.1421 8.00308 15.1421C7.70016 15.1421 7.40966 15.0218 7.19547 14.8076C7.0938 14.7059 7.01329 14.5871 6.95674 14.4579Z" stroke="#6C707E" stroke-width="0.915741"/>
<path d="M3.9472 8.2236C3.98191 8.15418 3.99999 8.07762 3.99999 8V6C3.99999 4.29256 4.57108 3.18513 5.32407 2.50006C6.0881 1.80496 7.08663 1.50196 8.00113 1.50001L8.00388 1.5L8.00449 1.5L8.00462 1.5H8.00543L8.00617 1.5L8.00892 1.50001C8.92327 1.50196 9.91901 1.80486 10.6804 2.49958C11.431 3.1844 12 4.2919 12 6V8C12 8.07762 12.0181 8.15418 12.0528 8.2236L13.8492 11.8164C14.0062 12.1305 13.7779 12.5 13.4267 12.5H2.57326C2.22214 12.5 1.99376 12.1305 2.15079 11.8164L3.9472 8.2236Z" stroke="#6C707E" stroke-linejoin="round"/>
</svg>`))

ToolNotifications is the Notifications tool window icon (bell).

View Source
var ToolProblems = FromSVGXML("tool_problems", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<circle cx="8" cy="8" r="6.5" stroke="#6C707E"/>
<path d="M8 4.59998L8 8.39998" stroke="#6C707E" stroke-width="1.2" stroke-linecap="round"/>
<circle cx="8.00078" cy="10.7" r="0.5" fill="#6C707E" stroke="#6C707E" stroke-width="0.4"/>
</svg>`))

ToolProblems is the Problems tool window icon (circle with exclamation).

View Source
var ToolProject = FromSVGXML("tool_project", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M8.15132 4.35836L8.29689 4.5H8.5H13C13.8284 4.5 14.5 5.17157 14.5 6V12.1333C14.5 12.919 13.9104 13.5 13.25 13.5H2.75C2.08955 13.5 1.5 12.919 1.5 12.1333V3.86667C1.5 3.08099 2.08955 2.5 2.75 2.5H6.03823C6.16847 2.5 6.29357 2.55082 6.38691 2.64164L8.15132 4.35836Z" stroke="#6C707E"/>
</svg>`))

ToolProject is the Project tool window icon (folder outline).

View Source
var ToolServices = FromSVGXML("tool_services", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M15.2117 7.50028C15.3901 7.80954 15.3901 8.19046 15.2117 8.49972L12.0386 13.9997C11.86 14.3093 11.5298 14.5 11.1724 14.5L4.82756 14.5C4.47018 14.5 4.13997 14.3093 3.96138 13.9997L0.788301 8.49972C0.609882 8.19046 0.609882 7.80954 0.788301 7.50028L3.96138 2.00028C4.13997 1.69072 4.47018 1.5 4.82756 1.5L11.1724 1.5C11.5298 1.5 11.86 1.69072 12.0386 2.00028L15.2117 7.50028Z" stroke="#6C707E"/>
<path d="M10.5 8.43301L6.75 10.5981C6.41667 10.7905 6 10.55 6 10.1651L6 5.83493C6 5.45004 6.41667 5.20947 6.75 5.40192L10.5 7.56699C10.8333 7.75944 10.8333 8.24056 10.5 8.43301Z" stroke="#6C707E"/>
</svg>`))

ToolServices is the Services tool window icon (hexagon with play).

View Source
var ToolStructure = FromSVGXML("tool_structure", []byte(`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<path fill-rule="evenodd" clip-rule="evenodd" d="M3 1.5C3 1.22386 2.77614 1 2.5 1C2.22386 1 2 1.22386 2 1.5V14.5C2 14.7761 2.22386 15 2.5 15C2.77614 15 3 14.7761 3 14.5V12H5V13C5 14.1046 5.89543 15 7 15H12C13.1046 15 14 14.1046 14 13V11C14 9.89543 13.1046 9 12 9H7C5.89543 9 5 9.89543 5 11H3V4H5V5C5 6.10457 5.89543 7 7 7H12C13.1046 7 14 6.10457 14 5V3C14 1.89543 13.1046 1 12 1H7C5.89543 1 5 1.89543 5 3L3 3V1.5ZM6 5C6 5.55228 6.44772 6 7 6H12C12.5523 6 13 5.55228 13 5V3C13 2.44772 12.5523 2 12 2H7C6.44772 2 6 2.44772 6 3V5ZM6 13C6 13.5523 6.44772 14 7 14H12C12.5523 14 13 13.5523 13 13V11C13 10.4477 12.5523 10 12 10H7C6.44772 10 6 10.4477 6 11V13Z" fill="#6C707E"/>
</svg>`))

ToolStructure is the Structure tool window icon (tree with two blocks).

View Source
var ToolTerminal = Terminal

ToolTerminal is the Terminal tool window icon.

Functions

func Draw

func Draw(canvas widget.Canvas, data IconData, bounds geometry.Rect, color widget.Color)

Draw renders an icon's path operations onto the canvas within the given bounds, using the specified color.

The icon is uniformly scaled to fit the bounds while preserving aspect ratio (the viewbox is square). The stroke width scales proportionally.

Draw can be called directly for custom rendering, or is used internally by IconWidget.

func DrawMulti added in v0.1.4

func DrawMulti(canvas widget.Canvas, data MultiColorIcon, bounds geometry.Rect, palette Palette)

DrawMulti renders a multi-color icon onto the canvas within the given bounds.

Each PathGroup in the icon is drawn with the color mapped by its ColorKey in the palette. If a key is not found in the palette, the group is drawn with widget.ColorGray as a fallback.

Types

type Command

type Command uint8

Command identifies a path drawing operation within an icon definition.

const (
	// CmdMoveTo moves the current point without drawing. Params: [x, y].
	CmdMoveTo Command = iota

	// CmdLineTo draws a straight line from the current point. Params: [x, y].
	CmdLineTo

	// CmdCubicTo draws a cubic Bezier curve. Params: [cx1, cy1, cx2, cy2, x, y].
	CmdCubicTo

	// CmdQuadraticTo draws a quadratic Bezier curve. Params: [cx, cy, x, y].
	CmdQuadraticTo

	// CmdClose closes the current sub-path by drawing a line back to the
	// starting point of the sub-path. Params: unused.
	CmdClose
)

func (Command) String

func (c Command) String() string

String returns a human-readable name for the command.

type 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
}

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.

func FromSVG added in v0.1.4

func FromSVG(name string, viewBox float32, svgPathData string) IconData

FromSVG creates an IconData from an SVG path data string.

The viewBox specifies the SVG coordinate space side length (e.g., 16 for a 16x16 viewBox, 24 for Material Design's 24x24). SVG path commands are parsed using gg.ParseSVGPath and converted to PathOp operations.

FromSVG panics if the SVG path data is invalid. This is intentional because icon definitions are typically package-level variables initialized at startup; a malformed path indicates a programming error that should fail fast.

Example:

var MyIcon = icon.FromSVG("my_icon", 16, "M8 2L14 8L8 14L2 8Z")

func FromSVGStroke added in v0.1.4

func FromSVGStroke(name string, viewBox float32, svgPathData string) IconData

FromSVGStroke creates an IconData for stroke-based SVG icons. These are rendered via stroke (DrawLine) not fill, matching expui outline style.

func FromSVGXML added in v0.1.4

func FromSVGXML(name string, svgXML []byte) IconData

FromSVGXML creates an IconData from full SVG XML data. The SVG is rendered via gg/svg.RenderWithColor into a bitmap at the target size, matching JetBrains icon rendering pipeline. This handles all SVG elements: path, circle, rect, with proper fill, stroke, fill-rule, stroke-linecap, etc.

func TryFromSVG added in v0.1.4

func TryFromSVG(name string, viewBox float32, svgPathData string) (IconData, error)

TryFromSVG creates an IconData from SVG path data, returning an error instead of panicking if the data is invalid. This is useful for user-supplied or runtime-loaded icon data.

type IconOption

type IconOption func(*iconConfig)

IconOption configures an IconWidget.

func Color

func Color(color widget.Color) IconOption

Color sets the icon stroke color.

func ColorSignal

func ColorSignal(sig state.ReadonlySignal[widget.Color]) IconOption

ColorSignal binds the icon color to a reactive signal. When set, the signal value takes precedence over Color.

func Label

func Label(text string) IconOption

Label sets the accessibility label for the icon.

func Size

func Size(s float32) IconOption

Size sets the display size of the icon in logical pixels. The icon is rendered as a square of side length s.

type IconWidget

type IconWidget struct {
	widget.WidgetBase
	// contains filtered or unexported fields
}

IconWidget is a display widget that renders a vector icon.

IconWidget implements widget.Widget and a11y.Accessible.

Create an IconWidget with NewIcon.

func NewIcon

func NewIcon(data IconData, opts ...IconOption) *IconWidget

NewIcon creates a new icon widget displaying the given icon data.

w := icon.NewIcon(icon.Check, icon.Size(32), icon.Color(widget.ColorGreen))

func (*IconWidget) AccessibilityActions

func (w *IconWidget) AccessibilityActions() []a11y.Action

AccessibilityActions returns nil. Icons have no actions.

func (*IconWidget) AccessibilityHint

func (w *IconWidget) AccessibilityHint() string

AccessibilityHint returns an empty string.

func (*IconWidget) AccessibilityLabel

func (w *IconWidget) AccessibilityLabel() string

AccessibilityLabel returns the icon's accessibility label. Falls back to the icon name if no label was set.

func (*IconWidget) AccessibilityRole

func (w *IconWidget) AccessibilityRole() a11y.Role

AccessibilityRole returns a11y.RoleImage.

func (*IconWidget) AccessibilityState

func (w *IconWidget) AccessibilityState() a11y.State

AccessibilityState returns the default accessibility state.

func (*IconWidget) AccessibilityValue

func (w *IconWidget) AccessibilityValue() string

AccessibilityValue returns an empty string.

func (*IconWidget) Children

func (w *IconWidget) Children() []widget.Widget

Children returns nil. Icon is a leaf widget.

func (*IconWidget) Data

func (w *IconWidget) Data() IconData

Data returns the icon data being displayed.

func (*IconWidget) Draw

func (w *IconWidget) Draw(_ widget.Context, canvas widget.Canvas)

Draw renders the icon to the canvas.

func (*IconWidget) Event

func (w *IconWidget) Event(_ widget.Context, _ event.Event) bool

Event returns false. Icon widgets do not consume events.

func (*IconWidget) IconColor

func (w *IconWidget) IconColor() widget.Color

IconColor returns the resolved icon color.

Resolution priority: ColorSignal > Color.

func (*IconWidget) IconLabel

func (w *IconWidget) IconLabel() string

IconLabel returns the accessibility label.

func (*IconWidget) IconSize

func (w *IconWidget) IconSize() float32

IconSize returns the display size in logical pixels.

func (*IconWidget) Layout

func (w *IconWidget) Layout(_ widget.Context, constraints geometry.Constraints) geometry.Size

Layout returns the icon's preferred size (a square of side [IconSize]).

func (*IconWidget) Mount

func (w *IconWidget) Mount(ctx widget.Context)

Mount creates signal bindings for push-based invalidation.

func (*IconWidget) Unmount

func (w *IconWidget) Unmount()

Unmount is called when the icon widget is removed from the widget tree.

type MultiColorIcon added in v0.1.4

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
}

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 MultiColorRegistry added in v0.1.4

type MultiColorRegistry struct {
	// contains filtered or unexported fields
}

MultiColorRegistry is a thread-safe named registry for multi-color icons.

Use DefaultMultiColorRegistry to access the global registry, which is pre-populated with all built-in multi-color icons. Create a custom registry with NewMultiColorRegistry for isolated icon sets.

func DefaultMultiColorRegistry added in v0.1.4

func DefaultMultiColorRegistry() *MultiColorRegistry

DefaultMultiColorRegistry returns the global multi-color icon registry.

The default registry is pre-populated with all built-in multi-color icons (file type icons and VCS icons). Additional icons can be registered at any time using MultiColorRegistry.Register.

func NewMultiColorRegistry added in v0.1.4

func NewMultiColorRegistry() *MultiColorRegistry

NewMultiColorRegistry creates an empty multi-color icon registry.

func (*MultiColorRegistry) Get added in v0.1.4

func (r *MultiColorRegistry) Get(name string) (MultiColorIcon, bool)

Get returns the multi-color icon with the given name and true if found, or a zero MultiColorIcon and false otherwise.

func (*MultiColorRegistry) Len added in v0.1.4

func (r *MultiColorRegistry) Len() int

Len returns the number of multi-color icons in the registry.

func (*MultiColorRegistry) Names added in v0.1.4

func (r *MultiColorRegistry) Names() []string

Names returns all registered multi-color icon names in no particular order.

func (*MultiColorRegistry) Register added in v0.1.4

func (r *MultiColorRegistry) Register(icon MultiColorIcon)

Register adds a multi-color icon to the registry, keyed by its Name field.

If an icon with the same name already exists, it is replaced.

type Palette added in v0.1.4

type Palette map[string]widget.Color

Palette maps color keys to actual colors. Used with DrawMulti to provide theme-appropriate colors for each PathGroup in a MultiColorIcon.

func DefaultDarkPalette added in v0.1.4

func DefaultDarkPalette() Palette

DefaultDarkPalette returns a palette suitable for dark themes.

The color values are inspired by JetBrains IDE dark themes and provide good contrast on dark backgrounds.

func DefaultLightPalette added in v0.1.4

func DefaultLightPalette() Palette

DefaultLightPalette returns a palette suitable for light themes.

The color values provide good contrast on light backgrounds with slightly darker tones than the dark palette counterparts.

type PathGroup added in v0.1.4

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
}

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 PathOp

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

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

The number of significant parameters depends on the command:

func ClosePath

func ClosePath() PathOp

ClosePath creates a Close path operation.

func Cubic

func Cubic(cx1, cy1, cx2, cy2, x, y float32) PathOp

Cubic creates a CubicTo path operation with control points (cx1, cy1), (cx2, cy2) and endpoint (x, y).

func Line

func Line(x, y float32) PathOp

Line creates a LineTo path operation.

func Move

func Move(x, y float32) PathOp

Move creates a MoveTo path operation.

func Quad added in v0.1.4

func Quad(cx, cy, x, y float32) PathOp

Quad creates a QuadraticTo path operation with control point (cx, cy) and endpoint (x, y).

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry is a thread-safe named icon registry.

Use DefaultRegistry to access the global registry, which is pre-populated with all built-in icons. Create a custom registry with NewRegistry for isolated icon sets.

func DefaultRegistry

func DefaultRegistry() *Registry

DefaultRegistry returns the global icon registry.

The default registry is pre-populated with all built-in icons. Additional icons can be registered at any time using Registry.Register.

func NewRegistry

func NewRegistry() *Registry

NewRegistry creates an empty icon registry.

func (*Registry) Get

func (r *Registry) Get(name string) (IconData, bool)

Get returns the icon with the given name and true if found, or a zero IconData and false otherwise.

func (*Registry) Len

func (r *Registry) Len() int

Len returns the number of icons in the registry.

func (*Registry) Names

func (r *Registry) Names() []string

Names returns all registered icon names in no particular order.

func (*Registry) Register

func (r *Registry) Register(icon IconData)

Register adds an icon to the registry, keyed by its Name field.

If an icon with the same name already exists, it is replaced.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL