bugzilla.mozilla.org will be intermittently unavailable on Saturday, March 24th, from 16:00 until 20:00 UTC.

Add support for ColorTransforms




Canvas: 2D
4 years ago
3 years ago


(Reporter: till, Unassigned)


Firefox Tracking Flags

(Not tracked)


(Whiteboard: [shumway:m2])



4 years ago
Spin-off from bug 927892.

As an analogue to `globalAlpha`, it'd be great to have the ability to specify a color transform similar to Flash's DisplayObject#transform.colorTransform[1].

Rationale: implementing color transform in JS is complicated and slow. Even for simple colors it requires parsing and modifying the CSS color definition. For putImageData it requires iterating over the bitmap data and applying the transform for each pixel individually. For gradients and patterns, it's simply not possible without replacing all usages with custom non-opaque objects.

Given that color transforms are used extensively in Flash, it appears like they're a feature that would find substantial use in Canvas 2D, too.

[1] http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/geom/ColorTransform.html
Could you apply an SVG feComponentTransfer filter to the content? http://www.w3.org/TR/SVG/filters.html#feComponentTransferElement looks like a linear one is what you want.

That should apply to a canvas element.

Comment 2

4 years ago
That does indeed look promising. Once the CanvasContext2D#filter property is available we can experiment with this filter. Thanks for the pointer.
Blocks: 1038057
You need to log in before you can comment on or make changes to this bug.