render

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Aff3

type Aff3 [6]float64

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 Gradient

type Gradient struct {
	Shape  Shape
	Spread Spread

	// Pix2Grad transforms coordinates from pixel space (the arguments to the
	// Image.At method) to gradient space. Gradient space is where a linear
	// gradient ranges from x == 0 to x == 1, and a radial gradient has center
	// (0, 0) and radius 1.
	//
	// This is an affine transform, so it can represent elliptical gradients in
	// pixel space, including non-axis-aligned ellipses.
	//
	// For a linear gradient, the bottom row is ignored.
	Pix2Grad Aff3

	Ranges []Range

	// First and Last are the first and last stop's colors.
	First, Last color.RGBA64
}

Gradient is a very large image.Image (the same size as an image.Uniform) whose colors form a gradient.

func (*Gradient) At

func (g *Gradient) At(x, y int) color.Color

At satisfies the image.Image interface.

func (*Gradient) Bounds

func (g *Gradient) Bounds() image.Rectangle

Bounds satisfies the image.Image interface.

func (*Gradient) ColorModel

func (g *Gradient) ColorModel() color.Model

ColorModel satisfies the image.Image interface.

func (*Gradient) GradientShape

func (g *Gradient) GradientShape() int

GradientShape returns 0 for a linear gradient and 1 for a radial gradient.

func (*Gradient) Init

func (g *Gradient) Init(shape Shape, spread Spread, pix2Grad Aff3, stops []Stop) bool

Init initializes g to a gradient whose geometry is defined by shape and pix2Grad and whose colors are defined by spread and stops.

func (*Gradient) SpreadMethod

func (g *Gradient) SpreadMethod() int

SpreadMethod returns 0 for 'none', 1 for 'pad', 2 for 'reflect', 3 for 'repeat'.

func (*Gradient) StopColors

func (g *Gradient) StopColors() []color.RGBA

StopColors returns as a slice the colors of the gradient stops.

func (*Gradient) StopOffsets

func (g *Gradient) StopOffsets() []float64

StopOffsets returns as a slice the offsets of the gradient stops.

func (*Gradient) Transform

func (g *Gradient) Transform() (a, b, c, d, e, f float64)

Transform is the pixel space to gradient space affine transformation matrix. | a b c | | d e f |

type Range

type Range struct {
	Offset0 float64
	Offset1 float64
	Width   float64
	R0      float64
	R1      float64
	G0      float64
	G1      float64
	B0      float64
	B1      float64
	A0      float64
	A1      float64
}

Range is the range between two stops.

func AppendRanges

func AppendRanges(a []Range, stops []Stop) []Range

AppendRanges appends to a the ranges defined by a's implicit final stop (if any exist) and stops.

func MakeRange

func MakeRange(s0, s1 Stop) Range

MakeRange returns the range between two stops.

type Renderer

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

Renderer implements the ivg.Destination interface to render an IconVG graphic onto a ivg/raster.Rasterizer.

Call SetRasterizer to change the rasterizer, before calling Decode or between calls to Decode.

func (*Renderer) AbsArcTo

func (z *Renderer) AbsArcTo(rx, ry, xAxisRotation float32, largeArc, sweep bool, x, y float32)

func (*Renderer) AbsCubeTo

func (z *Renderer) AbsCubeTo(x1, y1, x2, y2, x, y float32)

func (*Renderer) AbsHLineTo

func (z *Renderer) AbsHLineTo(x float32)

func (*Renderer) AbsLineTo

func (z *Renderer) AbsLineTo(x, y float32)

func (*Renderer) AbsQuadTo

func (z *Renderer) AbsQuadTo(x1, y1, x, y float32)

func (*Renderer) AbsSmoothCubeTo

func (z *Renderer) AbsSmoothCubeTo(x2, y2, x, y float32)

func (*Renderer) AbsSmoothQuadTo

func (z *Renderer) AbsSmoothQuadTo(x, y float32)

func (*Renderer) AbsVLineTo

func (z *Renderer) AbsVLineTo(y float32)

func (*Renderer) CSel

func (z *Renderer) CSel() uint8

func (*Renderer) ClosePathAbsMoveTo

func (z *Renderer) ClosePathAbsMoveTo(x, y float32)

func (*Renderer) ClosePathEndPath

func (z *Renderer) ClosePathEndPath()

func (*Renderer) ClosePathRelMoveTo

func (z *Renderer) ClosePathRelMoveTo(x, y float32)

func (*Renderer) NSel

func (z *Renderer) NSel() uint8

func (*Renderer) RelArcTo

func (z *Renderer) RelArcTo(rx, ry, xAxisRotation float32, largeArc, sweep bool, x, y float32)

func (*Renderer) RelCubeTo

func (z *Renderer) RelCubeTo(x1, y1, x2, y2, x, y float32)

func (*Renderer) RelHLineTo

func (z *Renderer) RelHLineTo(x float32)

func (*Renderer) RelLineTo

func (z *Renderer) RelLineTo(x, y float32)

func (*Renderer) RelQuadTo

func (z *Renderer) RelQuadTo(x1, y1, x, y float32)

func (*Renderer) RelSmoothCubeTo

func (z *Renderer) RelSmoothCubeTo(x2, y2, x, y float32)

func (*Renderer) RelSmoothQuadTo

func (z *Renderer) RelSmoothQuadTo(x, y float32)

func (*Renderer) RelVLineTo

func (z *Renderer) RelVLineTo(y float32)

func (*Renderer) Reset

func (z *Renderer) Reset(viewbox ivg.ViewBox, palette [64]color.RGBA)

Reset resets the Destination for the given Metadata.

func (*Renderer) SetCReg

func (z *Renderer) SetCReg(adj uint8, incr bool, c ivg.Color)

func (*Renderer) SetCSel

func (z *Renderer) SetCSel(cSel uint8)

func (*Renderer) SetLOD

func (z *Renderer) SetLOD(lod0, lod1 float32)

func (*Renderer) SetNReg

func (z *Renderer) SetNReg(adj uint8, incr bool, f float32)

func (*Renderer) SetNSel

func (z *Renderer) SetNSel(nSel uint8)

func (*Renderer) SetRasterizer

func (z *Renderer) SetRasterizer(dst raster.Rasterizer, r image.Rectangle)

SetRasterizer sets the rasterizer to draw into. The IconVG graphic (which does not have a fixed size in pixels) will be scaled in the X and Y dimensions to fit the rectangle r. The scaling factors may differ in the two dimensions.

func (*Renderer) StartPath

func (z *Renderer) StartPath(adj uint8, x, y float32)

type Shape

type Shape uint8

Shape is the gradient shape.

const (
	ShapeLinear Shape = iota
	ShapeRadial
)

type Spread

type Spread uint8

Spread is the gradient spread, or how to spread a gradient past its nominal bounds (from offset being 0.0 to offset being 1.0).

const (
	// SpreadNone means that offsets outside of the [0, 1] range map to
	// transparent black.
	SpreadNone Spread = iota
	// SpreadPad means that offsets below 0 and above 1 map to the colors that
	// 0 and 1 would map to.
	SpreadPad
	// SpreadReflect means that the offset mapping is reflected start-to-end,
	// end-to-start, start-to-end, etc.
	SpreadReflect
	// SpreadRepeat means that the offset mapping is repeated start-to-end,
	// start-to-end, start-to-end, etc.
	SpreadRepeat
)

func (Spread) Clamp

func (s Spread) Clamp(x float64) float64

Clamp clamps x to the range [0, 1]. If x is outside that range, it is converted to a value in that range according to s's semantics. It returns -1 if s is SpreadNone and x is outside the range [0, 1].

type Stop

type Stop struct {
	Offset float64
	RGBA64 color.RGBA64
}

Stop is an offset and color.

Jump to

Keyboard shortcuts

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