Re: Adding blending to the canvas API

On 4/5/2012 5:32 PM, Rik Cabanier wrote:
> Filters/shaders and blending are very different concepts.
> Filters take 1 source and modify the pixels.
> Blending operations take 2 sources, blend the pixels and generate a 
> new image.
>
> I can see that filters and custom shaders can useful but I'm just 
> looking for feedback on blending at this point.
> The simplest way to do this seems to extend the list of compositing 
> operators and specify that the result of the blend operation is always 
> composited with src-over.
> Since Canvas draws in immediate mode, concepts like grouping are most 
> likely not going to translate.
>

Feedback:


In all uses of Canvas, source-over is by far the most popular operator. 
We've used "atop" in addition to source-over with blend modes. Add the 
destination operations back in, and there's only a few that aren't used.

One of the benefits of using an existing property, like fillStyle or 
globalCompositeOperation, is that it'll throw and/or not update the 
value, when it's unrecognized. This is really handy for polyfill. When 
you do something like globalCompositeOperation = '-x-hue', it's easy to 
see that it's unsupported as a native mode.

..

Fragment shaders and filters take zero-or-more sources; they always take 
at least one path.

Blending operations take two sources (both with paths).

Blend "filters" from SVG:
https://dvcs.w3.org/hg/FXTF/raw-file/tip/filters/index.html#InterfaceSVGFEBlendElement

In the context of "filters", I'm discussing custom filters in the 
context of blending operations.
Filters are a super-set of blend ops.

-Charles

Received on Friday, 6 April 2012 01:00:58 UTC