glyph

package module
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 17 Imported by: 1

README

glyph build

glyph

glyph is a embedded icon framework.

Concept

glyph generates icons by connecting predefined coordinates with lines.

imgimg

package main

import (
	"os"
	"strings"

	"github.com/k1LoW/glyph"
)

func main() {
	g, _ := glyph.New()
	_ = g.Line(strings.Split("b0 d0 h0 j0 j6 h8 d8 b6 b0", " "))
	_ = g.Line(strings.Split("b0 d2 h2 j0", " "))
	_ = g.Line(strings.Split("b2 d4 h4 j2", " "))
	_ = g.Line(strings.Split("b4 d6 h6 j4", " "))
	_ = g.Write(os.Stdout)
}

Included Icon Set

glyph has included icon set.

package main

import (
	"os"
	"strings"

	"github.com/k1LoW/glyph"
)

func main() {
	g, _ := glyph.Included().Get("browser")
	_ = g.Write(os.Stdout)
}

Documentation

Index

Constants

View Source
const BaseColorKey = "baseColor"
View Source
const BaseFillColorKey = "baseFillColor"

Variables

This section is empty.

Functions

func IncludedAliases added in v0.3.0

func IncludedAliases() map[string][]string

IncludedAliases return included icon aliases.

Types

type Blueprint added in v0.4.1

type Blueprint struct {
	Key      string        `json:"key,omitempty" yaml:"key,omitempty" toml:"key,omitempty"`
	RawLines []LineAndOpts `json:"lines,omitempty" yaml:"lines,omitempty" toml:"lines,omitempty"`
	RawTexts []TextAndOpts `json:"texts,omitempty" yaml:"texts,omitempty" toml:"texts,omitempty"`
}

func NewBlueprint added in v0.4.1

func NewBlueprint() *Blueprint

NewBlueprint create new Blueprint.

func (*Blueprint) Lines added in v0.4.1

func (b *Blueprint) Lines(lines []LineAndOpts) *Blueprint

func (*Blueprint) Texts added in v0.4.1

func (b *Blueprint) Texts(texts []TextAndOpts) *Blueprint

func (Blueprint) ToGlyph added in v0.4.1

func (b Blueprint) ToGlyph() (*Glyph, error)

func (Blueprint) ToGlyphAndKey added in v0.5.0

func (b Blueprint) ToGlyphAndKey() (*Glyph, string, error)

type Glyph

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

func New

func New(opts ...Option) (*Glyph, error)

New return *Glyph.

func (*Glyph) HideCoordinates

func (g *Glyph) HideCoordinates() error

func (*Glyph) Line added in v0.2.0

func (g *Glyph) Line(points []string, opts ...string) error

Line draw line.

func (*Glyph) ShowCoordinates

func (g *Glyph) ShowCoordinates() error

func (*Glyph) Text added in v0.2.0

func (g *Glyph) Text(text, point string, opts ...string) error

Text draw text.

func (*Glyph) Write

func (g *Glyph) Write(w io.Writer) error

func (*Glyph) WriteImage

func (g *Glyph) WriteImage(w io.Writer) error

type Line

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

type LineAndOpts

type LineAndOpts string

func (LineAndOpts) Parse

func (l LineAndOpts) Parse() ([]string, []string, error)

type Map

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

Map is icon (glyph) map.

func NewMap

func NewMap(opts ...Option) *Map

NewMap return *Map.

func NewMapWithIncluded

func NewMapWithIncluded(opts ...Option) *Map

NewMapWithIncluded return *Map with Included icons.

func (*Map) Delete added in v0.4.0

func (m *Map) Delete(k string)

func (*Map) Get

func (m *Map) Get(k string) (*Glyph, error)

func (*Map) Keys

func (m *Map) Keys() []string

func (*Map) Set added in v0.4.0

func (m *Map) Set(k string, g *Glyph)

type Option

type Option func(*Glyph) error

func Color

func Color(c string) Option

Color set SVG line 'stroke'.

func FillColor

func FillColor(c string) Option

FillColor set SVG line 'fill'.

func Height

func Height(h float64) Option

Height set SVG height.

func LineOpt added in v0.3.0

func LineOpt(opt string) Option

LineOpt set SVG line option.

func LineOpts added in v0.3.0

func LineOpts(opts []string) Option

LineOpts set SVG line options.

func TextColor added in v0.3.0

func TextColor(c string) Option

TextColor set SVG text 'fill'.

func TextOpt added in v0.3.0

func TextOpt(opt string) Option

TextOpt set SVG text option.

func TextOpts added in v0.3.0

func TextOpts(opts []string) Option

TextOpts set SVG text options.

func Width added in v0.4.0

func Width(w float64) Option

Width set SVG width.

type Point

type Point struct {
	X float64
	Y float64
}

type Points

type Points map[string]*Point

func GetPoints

func GetPoints() Points

func (Points) Get

func (p Points) Get(key string) (*Point, error)

func (Points) Keys

func (p Points) Keys() []string

type Set

type Set map[string]*Blueprint

func Included

func Included() Set

Included return included icon set.

func (Set) Get

func (s Set) Get(k string) (*Glyph, error)

func (Set) Keys

func (s Set) Keys() []string

type Text

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

type TextAndOpts added in v0.2.0

type TextAndOpts string

func (TextAndOpts) Parse added in v0.2.0

func (t TextAndOpts) Parse() (string, string, []string, error)

Jump to

Keyboard shortcuts

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