usvg

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 11 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package usvg is a port of the subset of usvg 0.46 (with svgtypes, simplecss and kurbo's arc code) that turns an SVG document into the tree of groups and paths the icon transform walks: element and attribute resolution (presentation attributes, CSS, style, inherit), use/switch/nested svg expansion, markers, shapes to paths, and fill/stroke resolution. Rendering-only features (text, images, filters, masks, clip geometry) are resolved only as far as they decide whether an element is kept.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSize = errors.New("SVG has an invalid size")
)

Error kinds, with usvg's messages.

Functions

This section is empty.

Types

type Group

type Group struct {
	Transform skpath.Transform
	Children  []any // *Group or *Path
}

Group is a container with a transform relative to its parent.

type ParseError

type ParseError struct{ Cause error }

ParseError is usvg's Error::ParsingFailed.

func (*ParseError) Error

func (e *ParseError) Error() string

func (*ParseError) Unwrap

func (e *ParseError) Unwrap() error

type Path

type Path struct {
	Data    *skpath.Path
	HasFill bool
	Stroke  *Stroke
}

Path is one shape: its local geometry and how it is painted.

type Stroke

type Stroke struct {
	Width      float32
	MiterLimit float32
	LineCap    skpath.LineCap
	LineJoin   skpath.LineJoin
	DashArray  []float32 // nil for a solid stroke
	DashOffset float32
}

Stroke is a resolved stroke.

func (*Stroke) ToSkia

func (s *Stroke) ToSkia() skpath.Stroke

ToSkia is Stroke::to_tiny_skia.

type Tree

type Tree struct {
	Width, Height float32
	Root          *Group
}

Tree is the converted document (usvg's Tree, trimmed to what the icon transform reads).

func Parse

func Parse(text string) (*Tree, error)

Parse is Tree::from_str with default options.

func (*Tree) String

func (t *Tree) String() string

String is a debug rendering of the tree.

Jump to

Keyboard shortcuts

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