canvastest

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2026 License: Apache-2.0 Imports: 5 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 canvastest holds drawings that exercise a canvas player, and what their pixels must show, so each backend's tests check their player the same way: they draw each Sample on white at twice its points and run its probes.

Index

Constants

View Source
const Scale = 2

Scale is the pixels a point the samples are drawn at.

Variables

This section is empty.

Functions

func Differ

func Differ(a, b *image.RGBA) (int, image.Point)

Differ counts the pixels of a and b that differ by more than anti-aliasing may, and returns the first.

func Logo(root string) []byte

Logo reads the gallery's logo, which the image sample draws, from the module's root given as a path from the test's directory.

Types

type Probe

type Probe struct {
	X, Y float64
	What string
	OK   func(c color.RGBA) bool
	W, H float64
	All  bool
}

Probe is a point, or a rectangle when W and H are set, in points, and what its pixel must be: some pixel of the rectangle, or all of them with All.

type Sample

type Sample struct {
	Name          string
	Width, Height int // points
	Drawing       *driver.Drawing
	Probes        []Probe
}

Sample is a drawing and the pixels it must make.

func Samples

func Samples(text driver.TextEngine, logo []byte) []*Sample

Samples returns the drawings, recorded with the platform's text engine as a canvas's are, logo being an image the last one draws.

func Split

func Split(text driver.TextEngine) []*Sample

Split returns drawings whose static part (driver.CanvasSplit) is long, each with a bound argument: a chart's area, line and bars under a clip and a shadow, then a ring, which keeps the path it builds, and a bar filled with the path the static part left. A backend that keeps a static part checks that playing the ops after it over the part's pixels draws what a full replay does.

func (*Sample) Check

func (s *Sample) Check(img *image.RGBA) []string

Check returns the probes of s that img fails, img being s drawn at Scale on white.

Jump to

Keyboard shortcuts

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