[whatwg] proposal: Add support for masking to canvas

Rik Cabanier cabanier at gmail.com
Tue Jan 29 20:37:27 PST 2013

I like that better too.

So the API could be as follows:

enum CanvasMaskType { luminosity, alpha};
dictionary maskOptions {

CanvasImageSource image;
unrestricted double? sx;
unrestricted double? sy;
unrestricted double? sw;
unrestricted double? sh;
unrestricted double dx;
unrestricted double dy;
unrestricted double? dw;
unrestricted double? dh;
CanvasMaskType? maskType = "luminosity";
boolean? invert = false;
boolean? clipToMask = true;


void maskImage(maskOptions options);
void resetMask();

If not specified, the dw and dh arguments must default to the values of sw
and sh, interpreted such that one CSS pixel in the image is treated as one
unit in thescratch bitmap's coordinate space. If the sx, sy, sw, and sh
arguments are omitted, they must default to 0, 0, the image's intrinsic
width in image pixels, and the image's intrinsic height in image pixels,


On Tue, Jan 29, 2013 at 8:18 PM, Tab Atkins Jr. <jackalmage at gmail.com>wrote:

> On Tue, Jan 29, 2013 at 7:30 PM, Rik Cabanier <cabanier at gmail.com> wrote:
> > Do you believe it's OK to have 12 arguments or would a dictionary be
> better?
> No, it's not okay.  ^_^  Particularly when some of the parameters are
> boolean - boolean positional arguments are the devil.  Go with a dict.
> ~TJ

More information about the whatwg mailing list