generate

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: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CSELUsedAsBothGradientAndStop = Error("ivg: CSEL used as both gradient and stop")
	TooManyGradientStops          = Error("ivg: too many gradient stops")
)

Variables

This section is empty.

Functions

func MulAff3

func MulAff3(x, y float32, a Aff3) (X, Y float32)

Types

type Aff3

type Aff3 [6]float32

Aff3 is a 3x3 affine transformation matrix in row major order, where the bottom row is implicitly [0 0 1].

m[3*r + c] is the element in the r'th row and c'th column.

func Concat

func Concat(affs ...Aff3) Aff3

func Scale

func Scale(v ...float32) Aff3

func Translate

func Translate(x, y float32) Aff3

type Error

type Error string

func UnrecognizedPathDataVerb

func UnrecognizedPathDataVerb(verb byte) Error

func (Error) Error

func (e Error) Error() string

type Generator

type Generator struct {
	ivg.Destination
	// contains filtered or unexported fields
}

func (*Generator) SetCircularGradient

func (g *Generator) SetCircularGradient(cx, cy, rx, ry float32, spread GradientSpread, stops []GradientStop) error

SetCircularGradient is like SetGradient with radial=true except that the transformation matrix is implicitly defined by a center (cx, cy) and a radius vector (rx, ry) such that (cx+rx, cy+ry) is on the circle.

func (*Generator) SetDestination

func (g *Generator) SetDestination(d ivg.Destination)

func (*Generator) SetEllipticalGradient

func (d *Generator) SetEllipticalGradient(cx, cy, rx, ry, sx, sy float32, spread GradientSpread, stops []GradientStop) error

SetEllipticalGradient is like SetGradient with radial=true except that the transformation matrix is implicitly defined by a center (cx, cy) and two axis vectors (rx, ry) and (sx, sy) such that (cx+rx, cy+ry) and (cx+sx, cy+sy) are on the ellipse.

func (*Generator) SetGradient

func (d *Generator) SetGradient(shape GradientShape, spread GradientSpread, stops []GradientStop, transform Aff3) error

SetGradient sets CREG[CSEL] to encode the gradient whose colors defined by spread and stops. Its geometry is either linear or radial, depending on the radial argument, and the given affine transformation matrix maps from graphic coordinate space defined by the metadata's viewBox (e.g. from (-32, -32) to (+32, +32)) to gradient coordinate space. Gradient coordinate space is where a linear gradient ranges from x=0 to x=1, and a radial gradient has center (0, 0) and radius 1.

The colors of the n stops are encoded at CREG[cBase+0], CREG[cBase+1], ..., CREG[cBase+n-1]. Similarly, the offsets of the n stops are encoded at NREG[nBase+0], NREG[nBase+1], ..., NREG[nBase+n-1]. Additional parameters are stored at NREG[nBase-4], NREG[nBase-3], NREG[nBase-2] and NREG[nBase-1].

The CSEL and NSEL selector registers maintain the same values after the method returns as they had when the method was called.

See the package documentation for more details on the gradient encoding format and the derivation of common transformation matrices.

func (*Generator) SetLinearGradient

func (g *Generator) SetLinearGradient(x1, y1, x2, y2 float32, spread GradientSpread, stops []GradientStop) error

SetLinearGradient is like SetGradient with shape=ShapeLinear except that the transformation matrix is implicitly defined by two boundary points (x1, y1) and (x2, y2).

func (*Generator) SetPathData

func (e *Generator) SetPathData(d string, adj uint8) error

func (*Generator) SetTransform

func (e *Generator) SetTransform(transforms ...Aff3)

type GradientShape

type GradientShape uint8

GradientShape is the gradient shape.

const (
	GradientShapeLinear GradientShape = iota
	GradientShapeRadial
)

type GradientSpread

type GradientSpread uint8

GradientSpread is how to spread a gradient past its nominal bounds (from offset being 0.0 to offset being 1.0).

const (
	GradientSpreadNone GradientSpread = iota
	GradientSpreadPad
	GradientSpreadReflect
	GradientSpreadRepeat
)

type GradientStop

type GradientStop struct {
	Offset float32
	Color  color.Color
}

GradientStop is a color/offset gradient stop.

Jump to

Keyboard shortcuts

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