svg

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Jul 12, 2023 License: BSD-3-Clause Imports: 10 Imported by: 0

Documentation

Overview

Package svg provides methods for working with fingerprint SVG documents.

Index

Constants

View Source
const CUBIC string = "C"

CUBIC is the string identifier for a `Cubic` path.

View Source
const LINE string = "L"

LINE is the string identifier for a `Line` path.

View Source
const MISSING string = "X"

MISSING is a the string identifier for a path that can not be parsed.

View Source
const POINT string = "P"

POINT is the string identifier for a `Point`.

View Source
const UNKNOWN string = ""

UNKNOWN is a the string identifier for a path type that is not supported.

Variables

This section is empty.

Functions

func DerivePathType added in v0.0.6

func DerivePathType(d string) string

DerivePathType returns a string identifier for the SVG path (`d` attribute) defined by 'd'.

func Draw added in v0.0.6

func Draw(dc *gg.Context, coords Coordinates, color string, scale float64) error

Draw renders the path defined by 'coords' on to 'gg'.

func DrawCubic added in v0.0.6

func DrawCubic(dc *gg.Context, curves Cubic, color string, scale float64) error

Draw renders the path defined by 'coords' as a closed cubic curve path on to 'gg'.

func DrawLine added in v0.0.6

func DrawLine(dc *gg.Context, points Line, color string, scale float64) error

Draw renders the path defined by 'coords' as a closed line string on to 'gg'.

Types

type Coordinates added in v0.0.6

type Coordinates interface {
	Type() string
}

Coordinate is an interface representation the coordinates defined by a `Path` instance.

func DeriveCoordinates added in v0.0.6

func DeriveCoordinates(d string) (Coordinates, error)

DerivePathType returns a `Coordinates` instance derived from the SVG path (`d` attribute) defined by 'd'.

type Cubic added in v0.0.6

type Cubic [][3]Point

Cubic is a list of a tuples of `Point` instances that make up a cubic curve path.

func (Cubic) Type added in v0.0.6

func (c Cubic) Type() string

Type returns the `CUBIC` string.

type Document

type Document struct {
	// Width is the width of the fingerprint SVG drawing.
	Width int `xml:"width,attr" json:"width"`
	// Height is the width of the fingerprint SVG drawing.
	Height int `xml:"height,attr" json:"height"`
	// ViewBox is the viewbox boundary of the fingerprint SVG drawing.
	ViewBox string `xml:"viewBox,attr" json:"viewbox"`
	// Date is the date that a fingerprint SVG drawing was produced.
	Date string `xml:"x-fingerprint-date,attr" json:"date"`
	// Paths is the list of SVG path that define a fingerprint SVG drawing.
	Paths []*Path `xml:"path" json:"paths"`
}

Document defines a struct representing a fingerprint SVG document. At this time it is not

func Unmarshal added in v0.0.2

func Unmarshal(r io.Reader) (*Document, error)

Unmarshal will parse the fingerprint SVG document defined by 'r' in a new `Document` instance.

func (*Document) ToImage added in v0.0.2

func (doc *Document) ToImage(max_dimension float64) (image.Image, error)

ToImage will rasterize 'doc' and return it as an `image.Image` instance whose maximum dimension is scaled to 'max_dimension'

type Line added in v0.0.6

type Line []Point

Line is a list of pairs of `Point` instances that make up a line path.

func (Line) Type added in v0.0.6

func (l Line) Type() string

Type returns the `LINE` string.

type Path

type Path struct {
	// Fill is the colour assigned to the path.
	Fill string `xml:"fill,attr" json:"f"`
	// FillOpacity is the opacity of the colour (assigned to the path).
	FillOpacity float64 `xml:"fill-opacity,attr" json:"o"`
	// D is the SVG-encoded value of the path.
	D string `xml:"d,attr" json:"d"`
}

Path is a struct representing an individual path element in a fingerprint SVG drawing.

func (*Path) Coordinates

func (p *Path) Coordinates() (Coordinates, error)

Coodinates with return a `Coordinates` instance derived derived from the `D` property of 'p'.

func (*Path) Draw added in v0.0.6

func (p *Path) Draw(dc *gg.Context, scale float64) error

Draw will render 'p' in to 'dc'.

func (*Path) HexColor added in v0.0.2

func (p *Path) HexColor() string

HexColor will return the 8-digit hexidecial color (fill + fill opacity) for the path

func (*Path) Type added in v0.0.6

func (p *Path) Type() string

Type will return a string identifier for the type of path derived from the `D` property of 'p'.

type Point added in v0.0.6

type Point [2]float64

Point is a two dimensional X,Y coordinate.

func (Point) Type added in v0.0.6

func (p Point) Type() string

Type returns the `POINT` string.

Jump to

Keyboard shortcuts

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