raster

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 21, 2026 License: 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

Overview

Package raster draws scenes in memory: the software renderer behind headless rendering, window captures and windows without a GPU renderer. Coverage comes from signed distances to rounded rectangles, so edges, corners and clips are anti-aliased the way the GPU shaders do it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClipMask

func ClipMask(dst *scene.Image, clips []scene.ClipShape, area image.Rectangle) *scene.Image

ClipMask updates a retained coverage image for nested clips in area. GPU renderers cache this independently of the content within a clip, so moving content under a stationary clip costs no CPU pixel work.

A row works out coverage only near the clips' edges: it is 0 outside a clip's bounds and 1 within the span every clip without a transform covers entirely, filled a run at a time. Large masks take several cores.

func Contains

func Contains(r scene.Rect, radii [4]float32, continuous bool, x, y float32) bool

Contains tests the interior of a rounded clip, using the same continuous corner geometry as rendering. Hit testing uses the shape's edge, without the pixel coverage used to smooth that edge on screen.

func Render

func Render(dst *Image, s *scene.Scene)

Render draws s into dst, which must be s.Width×s.Height.

Types

type Image

type Image struct {
	W, H, Stride int
	Pix          []byte
}

Image is a premultiplied BGRA bitmap, the layout Windows DIBs, cairo and Core Graphics take.

func NewImage

func NewImage(w, h int) *Image

NewImage returns a w×h image.

func (*Image) RGBA

func (m *Image) RGBA() []byte

RGBA returns the pixels as premultiplied RGBA, as image.RGBA holds them.

func (*Image) Resize

func (m *Image) Resize(w, h int)

Resize makes the image w×h, reusing its memory when it can.

type Renderer

type Renderer struct {
	// Image holds the last scene drawn, in mem.
	Image Image
	// contains filtered or unexported fields
}

Renderer draws the successive scenes of a window into Image, redrawing only where a scene differs from the one before (scene.Differ): a blinking caret, a ticking clock or a button under the pointer redraws only itself.

func (*Renderer) Invalidate

func (r *Renderer) Invalidate()

Invalidate makes the next Render draw everything.

func (*Renderer) Release

func (r *Renderer) Release()

Release frees the image and what Render remembers: the next Render draws everything. Image must not be used meanwhile.

func (*Renderer) Render

func (r *Renderer) Render(s *scene.Scene) []image.Rectangle

Render draws s, and returns the rectangles of Image it changed. s may change once Render returns.

Jump to

Keyboard shortcuts

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