rasterizer

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0, MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Draw

func Draw(c *canvas.Canvas, resolution canvas.Resolution, colorSpace canvas.ColorSpace) *image.RGBA

Draw draws the canvas on a new image with given resolution (in dots-per-millimeter). Higher resolution will result in larger images.

Types

type GradientImage

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

func NewGradientImage

func NewGradientImage(g canvas.Gradient, zp, size image.Point, res canvas.Resolution) *GradientImage

func (*GradientImage) At

func (img *GradientImage) At(x, y int) color.Color

func (*GradientImage) Bounds

func (img *GradientImage) Bounds() image.Rectangle

func (*GradientImage) ColorModel

func (img *GradientImage) ColorModel() color.Model

type Rasterizer

type Rasterizer struct {
	draw.Image
	// contains filtered or unexported fields
}

Rasterizer is a rasterizing renderer.

func FromImage

func FromImage(img draw.Image, resolution canvas.Resolution, colorSpace canvas.ColorSpace) *Rasterizer

FromImage returns a renderer that draws to an existing image. Resolution is in pixels per unit of canvas coordinates (millimeters). A higher resolution will give a larger and more detailed image.

func New

func New(width, height float64, resolution canvas.Resolution, colorSpace canvas.ColorSpace) *Rasterizer

New returns a renderer that draws to a rasterized image. The final width and height of the image is the width and height (mm) multiplied by the resolution (px/mm), thus a higher resolution results in larger images. By default the linear color space is used, which assumes input and output colors are in linearRGB. If the sRGB color space is used for drawing with an average of gamma=2.2, the input and output colors are assumed to be in sRGB (a common assumption) and blending happens in linearRGB. Be aware that for text this results in thin stems for black-on-white (but wide stems for white-on-black).

func (*Rasterizer) Close

func (r *Rasterizer) Close()

func (*Rasterizer) RenderImage

func (r *Rasterizer) RenderImage(img image.Image, m canvas.Matrix)

RenderImage renders an image to the canvas using a transformation matrix.

func (*Rasterizer) RenderPath

func (r *Rasterizer) RenderPath(path *canvas.Path, style canvas.Style, m canvas.Matrix)

RenderPath renders a path to the canvas using a style and a transformation matrix.

func (*Rasterizer) RenderText

func (r *Rasterizer) RenderText(text *canvas.Text, m canvas.Matrix)

RenderText renders a text object to the canvas using a transformation matrix.

func (*Rasterizer) Reset

func (r *Rasterizer) Reset()

Reset clears the image and accumulated scan cells so that the rasterizer can be reused for the next frame. It keeps the allocated buffers for the image and scan cells, avoiding per-frame allocations such as image.NewRGBA and scan cell lookup on repeated rendering (e.g. animations). Note that Close should still be called once all frames have been rendered.

func (*Rasterizer) Resolution

func (r *Rasterizer) Resolution() canvas.Resolution

Resolution returns the device resolution used for text hinting and pixel alignment, including when canvas falls back to clipped glyph outlines.

func (*Rasterizer) SetOp

func (r *Rasterizer) SetOp(op draw.Op)

SetOp sets the drawing operation. Either draw.Src or draw.Over.

func (*Rasterizer) Size

func (r *Rasterizer) Size() (float64, float64)

Size returns the size of the canvas in millimeters.

Jump to

Keyboard shortcuts

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