Hello again,
thanks for all your replies! I made some tests on the different proposals listed here.
1st test was, use a png mask, and display it on top. For this, i had to make a mask of 2048 x 2048px to be able to cover my whole screen. The rendering works, so at least i have a first working prototype of what i wanted to achieve ! Result can be seen here :
http://tof.canardpc.com/view/16a4ac92-ec25-4543-85b0-420930d62171.jpgAs expected it is a bit of a performance hit, but it is still playable. The drawbacks are that the image is somewhat big, and it's resolution dependent, so changing resolution would mean change the resource, which could grow even bigger...
I also had a look at the composing possibilities. I'm trying to get rid of any ressource for now, and draw the mask elements in code. By digging through the different composition possibilities, i think i should use one called "destination-in", which from what i see would keep the thing i draw on in the shape i'm drawing with; i saw that here :
http://www.w3schools.com/tags/playcanvas.asp?filename=playcanvas_globalcompop&preval=destination-inso my idea was render a circle on top of the scene, and manage in way to have a black clear color that would give my effect. Bad news here, i can't get anything working...
Similar to what i use to draw the png, i'm using the following code in an item derivating from a Renderable :
draw: function (renderer) {
var previousGco = renderer.getContext().globalCompositeOperation;
renderer.getContext().globalCompositeOperation = "destination-in";
renderer.fillArc(this.target_x - 128 + 16, this.target_y - 128 + 16, 128, 0, 2*Math.PI);
renderer.getContext().globalCompositeOperation = previousGco;
}
The result is that i get a slower game, with no visual difference. There rendering part of the circle seems correct, using a normal composition effect shows a white circle. Something which is weird, displaying the debug overlay with the quadtree display show up a circle around the target and with a weird bug on a part of the quad tree display :
http://tof.canardpc.com/view/79a09c37-6663-45a8-814c-15093cd5665c.jpgSo there has to be something i'm missing here with the composing; Is anything being reset after the draw call of my class happens? I tried to dig into the source code and noticed that the prepareSurface() code sets the composite operation, but i doubt this is a conflict in my case. Or could i be missing something like a full repaint of the canvas ?
Anyway, the composing possibilities looks interesting, it made me want to make a flame effect somewhere with the "lighter" composing effect, similar to what the particles seem to do. But i don't master the thing yet :p
Thanks!