Documentation
¶
Overview ¶
Package fyne_iconkit provides the shared runtime behind the fyne_* icon packages: loading SVG icons from an fs.FS, caching them as fyne.Resource, staining monochrome icons with an arbitrary color and rasterizing them to PNG.
Icon packages usually wrap a single package-level Set around an embedded directory and generate name constants with cmd/iconconst.
Index ¶
- func Stain(src []byte, c color.Color) []byte
- type Set
- func (s *Set) Has(name string) bool
- func (s *Set) Icon(name string, stainColor ...color.Color) (fyne.Resource, error)
- func (s *Set) MustIcon(name string, stainColor ...color.Color) fyne.Resource
- func (s *Set) Names() []string
- func (s *Set) PNG(name string, size int, stainColor ...color.Color) ([]byte, error)
- func (s *Set) Source(name string) ([]byte, error)
- func (s *Set) StainedSource(name string, c color.Color) ([]byte, error)
- type StainableResource
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Set ¶
type Set struct {
// contains filtered or unexported fields
}
Set is a collection of SVG icons stored in a directory of an fs.FS. All methods are safe for concurrent use.
func NewSet ¶
NewSet returns a Set of multi-colored icons (e.g. flags). Icons are served as they are; stain colors passed to Icon are ignored.
func NewStainableSet ¶
NewStainableSet returns a Set of monochrome icons that use "currentColor". Icons are always stained before use; without an explicit color the theme's foreground color at the time of the call is used.
func (*Set) Icon ¶
Icon returns the named icon as a cached fyne.Resource.
For stainable sets the result is a StainableResource colored with the first stain color, or with the current theme foreground color if none is given. For other sets stain colors are ignored.
func (*Set) MustIcon ¶
MustIcon is like Icon but logs the error via fyne.LogError and returns theme.ErrorIcon() if the icon cannot be loaded.
func (*Set) PNG ¶
PNG rasterizes the named icon to PNG. size is the length of the longer edge in pixels; the aspect ratio of the SVG view box is preserved.
Icons of stainable sets are stained with the first stain color, or black if none is given. For other sets stain colors are ignored.
type StainableResource ¶
type StainableResource interface {
fyne.Resource
// StainColor returns the color the resource is currently stained with.
StainColor() color.Color
// Stain returns the same icon stained with c.
Stain(c color.Color) (fyne.Resource, error)
// MustStain is like Stain but returns theme.ErrorIcon() on failure.
MustStain(c color.Color) fyne.Resource
}
StainableResource is a monochrome icon resource that can be re-colored.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
iconconst
command
Command iconconst generates one Go variable per *.svg icon in a directory.
|
Command iconconst generates one Go variable per *.svg icon in a directory. |
|
internal
|
|
|
constgen
Package constgen generates Go variables for the icons in a directory.
|
Package constgen generates Go variables for the icons in a directory. |