[whatwg] Canvas - globalCompositeOperation

Philip Taylor excors+whatwg at gmail.com
Thu Mar 29 05:14:31 PDT 2007


I've added some tests at
http://canvex.lazyilluminati.com/tests/tests/index.2d.composite.transparent.html
based on the definitions I suggested. Firefox and Safari match the
expected results, Opera misses on atop/xor/lighter. (I skipped darker,
because it doesn't make sense and I'm hoping it'll just go away...)
(The automatic testing may give the wrong answers if your browser has
a getImageData that isn't the same as Firefox's (which returns
premultiplied alpha) - I believe that's a problem in Firefox and/or
the spec, but I'm not looking into it in any detail now.)


When I originally said
|  The calculation of aO must be clamped to the range [0, 1].
that actually should be
|  The calculation of aO and cO must be clamped to the range [0, 1].
because of e.g. the "white lighten white" case, where cO can exceed 1.


On 28/03/07, ddailey <ddailey at zoominternet.net> wrote:
> I suspect you already are aware of this but in addition to the references
> you provide
> the SVG 1.1 reco gives examples of the Porter-Duff composites
> http://www.w3.org/TR/SVG11/filters.html

Thanks, I hadn't thought of looking there. That SVG 1.1 section
(feComposite) seems to skip over the issue of actually defining what
the operators mean, and refers to the Porter-Duff paper. The SVG 1.2
draft at http://www.w3.org/TR/2004/WD-SVG12-20041027/rendering.html#comp-op-prop
does give the equations, and also adds a dozen extra operators, but
removes the ability to define your own arithmetic ones. SVG Tiny 1.2
at http://www.w3.org/TR/SVGMobile12/painting.html#CompositingSimpleAlpha
appears to get rid of all the compositing except for plain source-over
blending, so it's the same as SVG 1.0 at
http://www.w3.org/TR/SVG10/masking.html#SimpleAlphaBlending . (I don't
know what to conclude from this, except that there presumably isn't a
universal consistent convention for what compositing operators should
be provided.)

> It appears that Opera is not handling them properly in SVG either:
> http://srufaculty.sru.edu/david.dailey/svg/newstuff/filterComposite2.svg

It seems to at least do
http://www.w3.org/TR/SVG11/images/filters/feComposite.svg quite close
to the example rendering (whereas Firefox does nothing except
source-over) - the colours are a bit darker, but I don't know if
that's an issue with Opera or with the example.

> David Dailey

-- 
Philip Taylor
excors at gmail.com



More information about the whatwg mailing list