mdicons

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: May 17, 2023 License: BSD-3-Clause Imports: 15 Imported by: 0

README

Parse Library for Material Icons

This library provides a specific parser for Material Icons as published by Google. The library is used by the cmd/mdicons command line utility to generate ivg icons in a .go file from the svg files found in a material icons folder structure.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrSkip = errors.New("skipping SVG to IconVG conversion")

ErrSkip is returned to deliberately skip generating an icon.

When manually debugging one particular icon, it can be useful to add something like:

if baseName != "check_box" { return errSkip }

at the top of func ParseFile.

Functions

func Parse

func Parse(mdicons string, pkg string, genData, genDataTest bool, outSize float32) error

func ParsePath

func ParsePath(enc ivg.Destination, p *Path, adjs map[float32]uint8, size float32, offset f32.Vec2, outSize float32, circles []Circle) error

func ParsePathData

func ParsePathData(enc ivg.Destination, pathData string, adj uint8, size float32, offset f32.Vec2, outSize float32) error

Types

type Circle

type Circle struct {
	Cx float32 `xml:"cx,attr"`
	Cy float32 `xml:"cy,attr"`
	R  float32 `xml:"r,attr"`
}

type Path

type Path struct {
	D           string   `xml:"d,attr"`
	Fill        string   `xml:"fill,attr"`
	FillOpacity *float32 `xml:"fill-opacity,attr"`
	Opacity     *float32 `xml:"opacity,attr"`
}

type SVG

type SVG struct {
	Width   float32 `xml:"width,attr"`
	Height  float32 `xml:"height,attr"`
	ViewBox string  `xml:"viewBox,attr"`
	Paths   []Path  `xml:"path"`
	// Some of the SVG files contain <circle> elements, not just <path>
	// elements. IconVG doesn't have circles per se. Instead, we convert such
	// circles to be paired arcTo commands, tacked on to the first path.
	//
	// In general, this isn't correct if the circles and the path overlap, but
	// that doesn't happen in the specific case of the Material Design icons.
	Circles []Circle `xml:"circle"`
}

type Statistics

type Statistics struct {
	VarNames        []string
	Failures        []string
	TotalFiles      int
	TotalIVGBytes   int
	TotalPNG24Bytes int
	TotalPNG48Bytes int
	TotalSVGBytes   int
}

func ParseDir

func ParseDir(mdicons, dirName string, outSize float32, out *bytes.Buffer) (Statistics, error)

func ParseFile

func ParseFile(fqSVGName, dirName, baseName string, size float32, outSize float32, out *bytes.Buffer) (Statistics, error)

func (Statistics) Add

func (s Statistics) Add(other Statistics) Statistics

Jump to

Keyboard shortcuts

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