svg

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: GPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	COMPRESS = false
)

Functions

func AssertFloatAttribute

func AssertFloatAttribute(attr *tokens.StringDict, key string) error

func BuildPath

func BuildPath(attr *tokens.StringDict, d []PathCommand, ctx context.Context) (tree.Tag, error)

func BuildTag

func BuildTag(key string, attr *tokens.StringDict, ctx context.Context) (tree.SVGTag, error)

func CompressFloatAttribute

func CompressFloatAttribute(attr *tokens.StringDict, key string,
	fn func(float64) float64)

func CompressStyles

func CompressStyles(attr *tokens.StringDict, vb tree.SVGViewBox)

func IsTag

func IsTag(key string) bool

func MinifyStyles

func MinifyStyles(attr *tokens.StringDict, containsText bool)

func NewDefs

func NewDefs(attr *tokens.StringDict, ctx context.Context) (tree.SVGTag, error)

func NewGeneric

func NewGeneric(key string, attr *tokens.StringDict, ctx context.Context) (tree.SVGTag, error)

func NewGroup

func NewGroup(attr *tokens.StringDict, ctx context.Context) (tree.SVGTag, error)

func NewInkscapeGrid

func NewInkscapeGrid(attr *tokens.StringDict, ctx context.Context) (tree.SVGTag, error)

func NewMetadata

func NewMetadata(attr *tokens.StringDict, ctx context.Context) (tree.SVGTag, error)

func NewRect

func NewRect(attr *tokens.StringDict, ctx context.Context) (tree.SVGTag, error)

func NewSodiPodiNamedView

func NewSodiPodiNamedView(attr *tokens.StringDict, ctx context.Context) (tree.SVGTag, error)

func SegmentsLength

func SegmentsLength(segments []PathSegment) float64

func SegmentsPosition

func SegmentsPosition(segments []PathSegment, t float64) (float64, float64)

Types

type Arc

type Arc struct {
	PathSegmentData
	ArcCoreData
	// contains filtered or unexported fields
}

func NewArc

func NewArc(start, stop PathCommand, x0, y0, x1, y1 float64, rx, ry, xAxisRot float64,
	largeArc, positiveSweep bool) *Arc

func (*Arc) Length

func (s *Arc) Length() float64

func (*Arc) Position

func (s *Arc) Position(f float64) (float64, float64)

func (*Arc) Reverse

func (s *Arc) Reverse() PathSegment

func (*Arc) Tangent

func (s *Arc) Tangent(f float64) (float64, float64)

type ArcBy

type ArcBy struct {
	ArcCoreData
	PathCommandData
	// contains filtered or unexported fields
}

func NewArcBy

func NewArcBy(dx, dy float64, rx, ry, xAxisRot float64, largeArc, positiveSweep bool, ctx context.Context) *ArcBy

func (*ArcBy) Compress

func (c *ArcBy) Compress(vb tree.SVGViewBox)

func (*ArcBy) Write

func (c *ArcBy) Write() string

type ArcCoreData

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

func (*ArcCoreData) Compress

func (c *ArcCoreData) Compress(vb tree.SVGViewBox)

type ArcTo

type ArcTo struct {
	ArcCoreData
	PathCommandData
	// contains filtered or unexported fields
}

func NewArcTo

func NewArcTo(x, y float64, rx, ry, xAxisRot float64, largeArc, positiveSweep bool, ctx context.Context) *ArcTo

func (*ArcTo) Compress

func (c *ArcTo) Compress(vb tree.SVGViewBox)

func (*ArcTo) Write

func (c *ArcTo) Write() string

type Close

type Close struct {
	PathCommandData
}

func NewClose

func NewClose(ctx context.Context) *Close

func (*Close) Compress

func (c *Close) Compress(vb tree.SVGViewBox)

func (*Close) Write

func (c *Close) Write() string

type Cubic

type Cubic struct {
	PathSegmentData
	// contains filtered or unexported fields
}

func NewCubic

func NewCubic(start, stop PathCommand, x0, y0, x1, y1 float64, xa, ya, xb, yb float64) *Cubic

func (*Cubic) Length

func (s *Cubic) Length() float64

func (*Cubic) Position

func (s *Cubic) Position(f float64) (float64, float64)

func (*Cubic) Reverse

func (s *Cubic) Reverse() PathSegment

func (*Cubic) Tangent

func (s *Cubic) Tangent(f float64) (float64, float64)

type CubicBy

type CubicBy struct {
	PathCommandData
	// contains filtered or unexported fields
}

func NewCubicBy

func NewCubicBy(dx1, dy1, dx2, dy2, dx, dy float64, ctx context.Context) *CubicBy

func (*CubicBy) Compress

func (c *CubicBy) Compress(vb tree.SVGViewBox)

func (*CubicBy) Write

func (c *CubicBy) Write() string

type CubicTo

type CubicTo struct {
	PathCommandData
	// contains filtered or unexported fields
}

func NewCubicTo

func NewCubicTo(x1, y1, x2, y2, x, y float64, ctx context.Context) *CubicTo

func (*CubicTo) Compress

func (c *CubicTo) Compress(vb tree.SVGViewBox)

func (*CubicTo) Write

func (c *CubicTo) Write() string

type Defs

type Defs struct {
	tree.SVGTagData
}

func (*Defs) Minify

func (t *Defs) Minify() bool

type ExtraCubicBy

type ExtraCubicBy struct {
	PathCommandData
	// contains filtered or unexported fields
}

func NewExtraCubicBy

func NewExtraCubicBy(dx2, dy2, dx, dy float64, ctx context.Context) *ExtraCubicBy

func (*ExtraCubicBy) Compress

func (c *ExtraCubicBy) Compress(vb tree.SVGViewBox)

func (*ExtraCubicBy) Write

func (c *ExtraCubicBy) Write() string

type ExtraCubicTo

type ExtraCubicTo struct {
	PathCommandData
	// contains filtered or unexported fields
}

func NewExtraCubicTo

func NewExtraCubicTo(x2, y2, x, y float64, ctx context.Context) *ExtraCubicTo

func (*ExtraCubicTo) Compress

func (c *ExtraCubicTo) Compress(vb tree.SVGViewBox)

func (*ExtraCubicTo) Write

func (c *ExtraCubicTo) Write() string

type ExtraQuadraticBy

type ExtraQuadraticBy struct {
	PathCommandData
	// contains filtered or unexported fields
}

func NewExtraQuadraticBy

func NewExtraQuadraticBy(dx, dy float64, ctx context.Context) *ExtraQuadraticBy

func (*ExtraQuadraticBy) Compress

func (c *ExtraQuadraticBy) Compress(vb tree.SVGViewBox)

func (*ExtraQuadraticBy) Write

func (c *ExtraQuadraticBy) Write() string

type ExtraQuadraticTo

type ExtraQuadraticTo struct {
	PathCommandData
	// contains filtered or unexported fields
}

func NewExtraQuadraticTo

func NewExtraQuadraticTo(x, y float64, ctx context.Context) *ExtraQuadraticTo

func (*ExtraQuadraticTo) Compress

func (c *ExtraQuadraticTo) Compress(vb tree.SVGViewBox)

func (*ExtraQuadraticTo) Write

func (c *ExtraQuadraticTo) Write() string

type GenBuilder

type GenBuilder struct {
}

func (*GenBuilder) Build

func (b *GenBuilder) Build(key string, attr *tokens.StringDict, ctx context.Context) (tree.SVGTag, error)

type Generic

type Generic struct {
	tree.SVGTagData
}

func (*Generic) Compress

func (t *Generic) Compress(vb tree.SVGViewBox)

func (*Generic) Minify

func (t *Generic) Minify() bool

func (*Generic) Validate

func (t *Generic) Validate() error

type Group

type Group struct {
	tree.SVGTagData
}

func (*Group) Compress

func (t *Group) Compress(vb tree.SVGViewBox)

func (*Group) Minify

func (t *Group) Minify() bool

func (*Group) Validate

func (t *Group) Validate() error

type HorBy

type HorBy struct {
	PathCommandData
	// contains filtered or unexported fields
}

func NewHorBy

func NewHorBy(dx float64, ctx context.Context) *HorBy

func (*HorBy) Compress

func (c *HorBy) Compress(vb tree.SVGViewBox)

func (*HorBy) Write

func (c *HorBy) Write() string

type HorTo

type HorTo struct {
	PathCommandData
	// contains filtered or unexported fields
}

func NewHorTo

func NewHorTo(x float64, ctx context.Context) *HorTo

func (*HorTo) Compress

func (c *HorTo) Compress(vb tree.SVGViewBox)

func (*HorTo) Write

func (c *HorTo) Write() string

type InkscapeGrid

type InkscapeGrid struct {
	tree.SVGTagData
}

type Line

type Line struct {
	PathSegmentData
}

func NewLine

func NewLine(start, stop PathCommand, x0, y0, x1, y1 float64) *Line

func (*Line) Length

func (s *Line) Length() float64

func (*Line) Position

func (s *Line) Position(f float64) (float64, float64)

func (*Line) Reverse

func (s *Line) Reverse() PathSegment

func (*Line) Tangent

func (s *Line) Tangent(f float64) (float64, float64)

type LineBy

type LineBy struct {
	PathCommandData
	// contains filtered or unexported fields
}

func NewLineBy

func NewLineBy(dx, dy float64, ctx context.Context) *LineBy

func (*LineBy) Compress

func (c *LineBy) Compress(vb tree.SVGViewBox)

func (*LineBy) Write

func (c *LineBy) Write() string

type LineTo

type LineTo struct {
	PathCommandData
	// contains filtered or unexported fields
}

func NewLineTo

func NewLineTo(x, y float64, ctx context.Context) *LineTo

func (*LineTo) Compress

func (c *LineTo) Compress(vb tree.SVGViewBox)

func (*LineTo) Write

func (c *LineTo) Write() string

type Metadata

type Metadata struct {
	tree.SVGTagData
}

func (*Metadata) Minify

func (t *Metadata) Minify() bool

type MoveBy

type MoveBy struct {
	PathCommandData
	// contains filtered or unexported fields
}

func NewMoveBy

func NewMoveBy(dx, dy float64, ctx context.Context) *MoveBy

func (*MoveBy) Compress

func (c *MoveBy) Compress(vb tree.SVGViewBox)

func (*MoveBy) Write

func (c *MoveBy) Write() string

type MoveTo

type MoveTo struct {
	PathCommandData
	// contains filtered or unexported fields
}

func NewMoveTo

func NewMoveTo(x, y float64, ctx context.Context) *MoveTo

func (*MoveTo) Compress

func (c *MoveTo) Compress(vb tree.SVGViewBox)

func (*MoveTo) Write

func (c *MoveTo) Write() string

type NoChildrenBuilder

type NoChildrenBuilder struct {
}

func (*NoChildrenBuilder) Build

func (b *NoChildrenBuilder) Build(key string, attr *tokens.StringDict, ctx context.Context) (tree.SVGTag, error)

type Path

type Path struct {
	tree.SVGTagData
	// contains filtered or unexported fields
}

func (*Path) Compress

func (t *Path) Compress(vb tree.SVGViewBox)

func (*Path) Minify

func (t *Path) Minify() bool

func (*Path) Validate

func (t *Path) Validate() error

func (*Path) Write

func (t *Path) Write(indent string, nl, tab string) string

type PathCommand

type PathCommand interface {
	Write() string
	Compress(tree.SVGViewBox)
	Context() context.Context
}

other operations are done by inference

func ParsePathString

func ParsePathString(d string, ctx context.Context) ([]PathCommand, error)

func ShortenEnds

func ShortenEnds(pcs []PathCommand, dStart, dEnd float64, ctx context.Context) ([]PathCommand, error)

type PathCommandData

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

func (*PathCommandData) Context

func (c *PathCommandData) Context() context.Context

type PathSegment

type PathSegment interface {
	Length() float64
	// f between 0 and 1
	Position(f float64) (float64, float64)
	// f between 0 and 1
	Tangent(f float64) (float64, float64) // pointing from start to end, normalized

	Reverse() PathSegment
	Context() context.Context
}

func GenerateSegments

func GenerateSegments(pcs []PathCommand, ctx context.Context) ([]PathSegment, error)

type PathSegmentData

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

func (*PathSegmentData) Context

func (s *PathSegmentData) Context() context.Context

type Quadratic

type Quadratic struct {
	PathSegmentData
	// contains filtered or unexported fields
}

func NewQuadratic

func NewQuadratic(start, stop PathCommand, x0, y0, x1, y1 float64, xa, ya float64) *Quadratic

func (*Quadratic) Length

func (s *Quadratic) Length() float64

dirty approximation (probably good enough for all visual purposes)

func (*Quadratic) Position

func (s *Quadratic) Position(f float64) (float64, float64)

func (*Quadratic) Reverse

func (s *Quadratic) Reverse() PathSegment

func (*Quadratic) Tangent

func (s *Quadratic) Tangent(f float64) (float64, float64)

type QuadraticBy

type QuadraticBy struct {
	PathCommandData
	// contains filtered or unexported fields
}

func NewQuadraticBy

func NewQuadraticBy(dx1, dy1, dx, dy float64, ctx context.Context) *QuadraticBy

func (*QuadraticBy) Compress

func (c *QuadraticBy) Compress(vb tree.SVGViewBox)

func (*QuadraticBy) Write

func (c *QuadraticBy) Write() string

type QuadraticTo

type QuadraticTo struct {
	PathCommandData
	// contains filtered or unexported fields
}

func NewQuadraticTo

func NewQuadraticTo(x1, y1, x, y float64, ctx context.Context) *QuadraticTo

func (*QuadraticTo) Compress

func (c *QuadraticTo) Compress(vb tree.SVGViewBox)

func (*QuadraticTo) Write

func (c *QuadraticTo) Write() string

type Rect

type Rect struct {
	tree.SVGTagData
}

func (*Rect) Compress

func (t *Rect) Compress(vb tree.SVGViewBox)

func (*Rect) Minify

func (t *Rect) Minify() bool

func (*Rect) Validate

func (t *Rect) Validate() error

type SodiPodiNamedView

type SodiPodiNamedView struct {
	tree.SVGTagData
}

func (*SodiPodiNamedView) Minify

func (t *SodiPodiNamedView) Minify() bool

type TagBuilder

type TagBuilder interface {
	Build(key string, attr *tokens.StringDict, ctx context.Context) (tree.SVGTag, error)
}

type TextChildBuilder

type TextChildBuilder struct {
}

type VerBy

type VerBy struct {
	PathCommandData
	// contains filtered or unexported fields
}

func NewVerBy

func NewVerBy(dy float64, ctx context.Context) *VerBy

func (*VerBy) Compress

func (c *VerBy) Compress(vb tree.SVGViewBox)

func (*VerBy) Write

func (c *VerBy) Write() string

type VerTo

type VerTo struct {
	PathCommandData
	// contains filtered or unexported fields
}

func NewVerTo

func NewVerTo(y float64, ctx context.Context) *VerTo

func (*VerTo) Compress

func (c *VerTo) Compress(vb tree.SVGViewBox)

func (*VerTo) Write

func (c *VerTo) Write() string

Jump to

Keyboard shortcuts

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