QUnit Canvas assertion plugin
This plugin for QUnit adds pixelEqual
and notPixelEqual
(plus alias pixelNotEqual
) assertion methods to test individual pixel values in a given canvas.
Usage
assert;assert; // Alias: `assert.pixelNotEqual`
Where:
canvas
: Reference to a canvas elementx
,y
: Coordinates of the pixel to testr
,g
,b
: The color value (0
-255
) of the pixel that you expecta
: The opacity value (0
-255
) of the pixel that you expect; may be omitted or passedundefined
if you want to ignore itmessage
: Optional message, same as for other assertions
Examples
module'Example module' { var canvas context fixtureEl = document; fixtureElinnerHTML = '<canvas width="5" height="5"></canvas>'; canvas = fixtureElfirstChild; try context = canvas; catche // probably no canvas support, just exit return; thiscanvas = canvas; thiscontext = context; }; ;
For more examples, refer to the unit tests.
Contributing
In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using grunt.