cocos2d/cocos2d-html5 — pull request #1896 by musikov (2014-06-04 11:19:15+00:00)
Title: fixed bug with inverted ClippingNode with DrawNode as stencil on Canvas;

_Summary:_
_setInverted(true)_ doesn't work if You're using _DrawNode_ as _stencil_ on _canvas_ renderer;

_Reproduce steps:_
-Set _renderMode_ to _canvas_
-Add _ClippingNode_
-Set _inverted_ to _true_ for _ClippingNode_
-Set _DrawNode_ as stencil;
Expected results:
everything draws outside DrawNode;
Actual results:
everything is drawn inside DrawNode;

For quick reproduce:
-set renderMode
-add these lines at the end of _MyLayer.init_ function in template

---
for (var i = 0; i < 2; ++i) {
var s = cc.size(size.width, size.height / 2);
var white = cc.color(255, 255, 255, 255);

var node = cc.ClippingNode.create();

var fadeLayer = cc.LayerColor.create(white, s.width, s.height);
node.addChild(fadeLayer);

var stencil = cc.DrawNode.create();
var rectangle = [
cc.p(s.width * 0.25, s.height * 0.25),
cc.p(s.width * 0.25, s.height * 0.75),
cc.p(s.width * 0.75, s.height * 0.75),
cc.p(s.width * 0.75, s.height * 0.25)
];
stencil.drawPoly(rectangle, white, 1, white);
node.setInverted(i % 2);
node.setStencil(stencil);

node.setPosition(0, (i % 2) * size.height / 2);
this.addChild(node);
}
---

There's a restriction in this solution: only clockwise polygons are supported;