Documentation ¶
Index ¶
- Constants
- func MulAff3(x, y float32, a Aff3) (X, Y float32)
- type Aff3
- type Error
- type Generator
- func (g *Generator) SetCircularGradient(cx, cy, rx, ry float32, spread GradientSpread, stops []GradientStop) error
- func (g *Generator) SetDestination(d ivg.Destination)
- func (d *Generator) SetEllipticalGradient(cx, cy, rx, ry, sx, sy float32, spread GradientSpread, stops []GradientStop) error
- func (d *Generator) SetGradient(shape GradientShape, spread GradientSpread, stops []GradientStop, ...) error
- func (g *Generator) SetLinearGradient(x1, y1, x2, y2 float32, spread GradientSpread, stops []GradientStop) error
- func (e *Generator) SetPathData(d string, adj uint8) error
- func (e *Generator) SetTransform(transforms ...Aff3)
- type GradientShape
- type GradientSpread
- type GradientStop
Constants ¶
const ( CSELUsedAsBothGradientAndStop = Error("ivg: CSEL used as both gradient and stop") TooManyGradientStops = Error("ivg: too many gradient stops") )
Variables ¶
This section is empty.
Functions ¶
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.
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) SetTransform ¶
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 ¶
GradientStop is a color/offset gradient stop.