- From: Tab Atkins Jr. via GitHub <sysbot+gh@w3.org>
- Date: Tue, 13 Sep 2016 17:01:28 +0000
- To: public-svg-issues@w3.org
Once again, a "side-effect free" group operation is impossible without cheating. Here's an example: ``` <svg> <g style="opacity: .5;"> <rect x="0" y="0" width="100" height="100" fill="red" /> <rect x="50" y="50" width="100" height="100" fill="yellow" /> </g> </svg> ``` As you can see, by putting `opacity` on the `<g>`, the red and yellow rectangles go transparent *as a group* - the yellow still fully occludes the red where they overlap, because they're effectively drawn at normal opacity, then made transparent as a group. Now, imagine sandwiching another rect between the yellow and red, filling *some* of the overlap area but not *all* of it. What would the effect be? Would the new rectangle be visible thru the yellow, even tho the red is fully occluded? What if the new rectangle was made transparent as well? Would it show the red behind it, even tho the yellow fully occludes the red? None of these options make sense, or can even be implemented without behind-the-scenes hackery. The only way to get something that *can* be sandwiched between red and yellow is to make the red and yellow rectangles *individually* transparent, like: ``` <svg> <recta x="25" y="25" width="100" height="100" fill="black" /> <g> <rect x="0" y="0" width="100" height="100" fill="red" style="opacity: .5;" /> <rect x="50" y="50" width="100" height="100" fill="yellow" style="opacity: .5;" /> </g> </svg> ``` Now you can sandwich a rectangle between the two and get a simple, consistent, understandable display. However, the yellow no longer occludes the red square. This might be the effect you want, or it might not. (This sort of effect going badly is sometimes seen in early 3D video games creating a "ghost" or "vision" by making a character model partially transparent. The eyes and teeth/mouth are often separate "objects" to the game, so they go transparent separately, leading to a frightening "evil skull" effect where you can see their whole eyeball and jaw thru their ghost-skin. More modern games properly transparent-ify the whole character model together, avoiding this effect.) This trade-off, between group effects and individual effects, is *inherent*. You can't get around it thru engineering, tho in some cases you can manually hack things to work (using clipping masks to manually implement occluding, for example). There is no way for SVG to offer a "side-effect free" version of opacity, or any filter-like effect. -- GitHub Notification of comment by tabatkins Please view or discuss this issue at https://github.com/w3c/svgwg/issues/264#issuecomment-246750601 using your GitHub account
Received on Tuesday, 13 September 2016 17:01:37 UTC