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
- Variables
- func CacheSources(n int) []driver.ImageSource
- func CheckTintSample(img image.Image, origin driver.Point, scale float32) []string
- func Checkerboard(width, height int) *image.RGBA
- func Differ(a, b *image.RGBA) (int, image.Point)
- func DrawAtlasSampling(d *driver.Drawing, src driver.ImageSource, size float32)
- func DrawSampling(d *driver.Drawing, src driver.ImageSource, size float32)
- func DrawTintSample(d *driver.Drawing, src driver.ImageSource, width, height float32)
- func DrawTintSprite(d *driver.Drawing)
- func Logo(root string) []byte
- func RedPNG() []byte
- func SamplingDifference(img image.Image, at image.Point, ref *image.RGBA, scale int, tolerance uint8) (image.Point, bool)
- func TintOffscreenSource(d *driver.Drawing, id uint64) driver.ImageSource
- func TintPixelsSource() driver.ImageSource
- func TintSource() (driver.ImageSource, error)
- type Probe
- type Sample
Constants ¶
const Scale = 2
Scale is the pixels a point the samples are drawn at.
const TintWidth, TintHeight = 160, 120
Variables ¶
var TintSpriteSize = driver.Size{Width: tintSpriteWidth, Height: tintSpriteHeight}
TintSpriteSize is the sprite's size in points, for an offscreen image of it.
Functions ¶
func CacheSources ¶ added in v0.2.0
func CacheSources(n int) []driver.ImageSource
CacheSources returns n tiny red images for cache-pressure tests, distinct from each other and from any it returned before: each PNG carries a number of its own in a text chunk, so they draw alike but their bytes, and so their keys, differ.
func CheckTintSample ¶
CheckTintSample compares the drawing to its reference fills, in the captured color space.
func Checkerboard ¶
Checkerboard has one texel per square, with black in its top left.
func Differ ¶
Differ counts the pixels of a and b that differ by more than anti-aliasing may, and returns the first.
func DrawAtlasSampling ¶
func DrawAtlasSampling(d *driver.Drawing, src driver.ImageSource, size float32)
DrawAtlasSampling draws the same four sampling squares through DrawAtlas.
func DrawSampling ¶
func DrawSampling(d *driver.Drawing, src driver.ImageSource, size float32)
DrawSampling draws a 16×16 checkerboard in four squares. The left side uses the default and restored smooth filter. The right side uses nearest before and after saving a different filter.
func DrawTintSample ¶
func DrawTintSample(d *driver.Drawing, src driver.ImageSource, width, height float32)
DrawTintSample records tinted, cropped and original draws of src over a solid backdrop.
func DrawTintSprite ¶
DrawTintSprite draws the sprite's stripes into an offscreen image TintSpriteSize large.
func Logo ¶
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.
func SamplingDifference ¶
func SamplingDifference(img image.Image, at image.Point, ref *image.RGBA, scale int, tolerance uint8) (image.Point, bool)
SamplingDifference returns the first pixel different from the source texel it should duplicate at the given integer scale.
func TintOffscreenSource ¶
func TintOffscreenSource(d *driver.Drawing, id uint64) driver.ImageSource
TintOffscreenSource makes the sprite as an offscreen canvas drawn by DrawTintSprite.
func TintPixelsSource ¶
func TintPixelsSource() driver.ImageSource
TintPixelsSource makes the sprite as a pixel buffer, a point a pixel.
func TintSource ¶
func TintSource() (driver.ImageSource, error)
TintSource makes the sprite as an encoded PNG.
Types ¶
type Probe ¶
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 AtlasSampling ¶
func AtlasSampling(text driver.TextEngine) *Sample
AtlasSampling checks DrawAtlas against the same nearest texel reference.
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 Sampling ¶
func Sampling(text driver.TextEngine) *Sample
Sampling checks every pixel of two nearest draws at 8× and looks for blended pixels in the corresponding smooth 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.