Documentation
¶
Overview ¶
Package raster renders display boxes to RGBA images and PNG streams with a pure-Go antialiased vector rasterizer.
Encode and EncodePNG walk the visible display-list commands in paint order. Path templates resolve as At + point*Em, rules fill their placed rectangles, explicit paints override palette roles, and Box.Bounds includes certified overflow. A nil Options uses DefaultOptions.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidBox reports a malformed display box. ErrInvalidBox = errors.New("raster: invalid box") // ErrInvalidOptions reports an invalid scale, padding, or output size. ErrInvalidOptions = errors.New("raster: invalid options") // ErrInvalidPath reports a path segment that cannot be rasterized. ErrInvalidPath = errors.New("raster: invalid path") // ErrInvalidWriter reports a nil PNG destination. ErrInvalidWriter = errors.New("raster: invalid writer") // ErrImageTooLarge reports dimensions that cannot form an image.RGBA. ErrImageTooLarge = errors.New("raster: image too large") )
Functions ¶
func Encode ¶
Encode rasterizes box into a caller-owned RGBA image.
The image includes the complete Box.Bounds, including certified overflow. Each dimension is ceil(boundsDimension*Scale + 2*Padding), with a minimum of one pixel. Box coordinates map to output pixels as (boundsCoordinate-bounds.Min)*Scale + Padding.
Types ¶
type Options ¶
Options controls raster output.
Scale is the number of output pixels per host unit and must be finite and positive. Padding is measured in output pixels and must be finite and nonnegative. A nil Background creates a transparent image; a non-nil Background fills the complete image before visible commands are drawn.
func DefaultOptions ¶
func DefaultOptions() Options
DefaultOptions returns a transparent one-pixel-per-unit image with eight pixels of padding and conventional black, red, and muted-gray paints.