Documentation
¶
Overview ¶
Package pixelfxtest checks the Go port of pixelfx against pixelfx itself: it renders an effect the way tools/pixelfxref renders it with pixelfx at the pinned commit, and compares the frames with the reference PNGs that tool wrote. Every category's tests call CheckEffect for each of its effects.
The cases and frames, the same on both sides:
- "default": the effect with its default options, as a sprite sheet renders it (pixelfx.EachFrame), at the frames 25%, 50% and 75% of the way through it.
- "flip": the same with Flip set.
- "act", for an effect a character acts out: the performance (pixelfx.EachActFrame, 60 fps), at the first frame whose time reaches 25%, 50% and 75% of the way from the first pose to the end (two loops for a loop).
A reference is <case>-<frame>.png in the effect's testdata/ref/<name> directory, frame the 0-based frame index in three digits.
Index ¶
- Constants
- Variables
- func BenchmarkActFrames(b *testing.B, e *pixelfx.Effect)
- func BenchmarkFrames(b *testing.B, e *pixelfx.Effect)
- func CheckDeterministic(t *testing.T, e *pixelfx.Effect)
- func CheckEffect(t *testing.T, e *pixelfx.Effect, refDir string)
- func ReadPNG(path string) (w, h int, pix []byte, err error)
- func SheetSamples(n int) []int
- type Diff
- type Frame
Constants ¶
const ( MaxChannelDelta = 2 )
The one tolerance every parity test uses. A pixel matches its reference when each of its RGBA channels is within MaxChannelDelta of the reference's; a frame matches when at most MaxDifferingShare of its pixels do not. JavaScript and Go compute the same float64 operations in the same order, but their sin, cos, atan2, exp and pow may differ in the last bit, and arm64 may fuse a multiply and an add; such a difference moves the odd pixel across a rounding edge, never a whole shape.
const ActFPS = 60
ActFPS is the frame rate the act case is rendered at.
Variables ¶
var Samples = []float64{0.25, 0.5, 0.75}
Samples are the share of the way through an effect each sampled frame is.
Functions ¶
func BenchmarkActFrames ¶
BenchmarkActFrames measures performing e at ActFPS with the stock character and its target: each iteration updates the performance by one frame and draws it, so the allocations reported are per frame. It starts over when the performance ends, with the timer stopped, so starting a performance is not counted.
func BenchmarkFrames ¶
BenchmarkFrames measures playing e at its frame rate: each iteration updates it by one frame and draws the frame, so the allocations reported are per frame. It starts over when a one-shot ends, with the timer stopped, so starting a player is not counted.
func CheckDeterministic ¶
CheckDeterministic renders every frame of e twice for each of its cases and fails t unless the two passes are the same to the byte. The cases are its default options, Flip, and, when its meta has them, a seed other than the default's and its palette reversed; an effect a character acts out is also performed twice with the default options and with that seed and palette.
func CheckEffect ¶
CheckEffect renders e and compares every frame with its reference in refDir (testdata/ref/<name>), failing t when a reference is missing, the wrong size, or differs beyond the tolerance, or when refDir holds a reference no case renders. Set PIXELFXTEST_OUT to a directory to have the frames that differ written there.
func SheetSamples ¶
SheetSamples returns the frames sampled from an effect's n sheet frames.
Types ¶
type Diff ¶
Diff is how a frame differs from its reference: how many pixels differ by more than MaxChannelDelta, out of how many, the largest channel difference, and where the first differing pixel is.