phoboslab/Ejecta — pull request #18 by Tharit (2012-10-05 18:46:18+00:00)
Title: added stencil test for transparent lines

Here's a simple implementation of using the stencil buffer to disable overdraw/overlapping in `stroke`.
I had to disable the line textures for this to work, as it requires all pixels to be of the same color.

Our two examples:
![image](http://f.cl.ly/items/1W2Q3R3V0G1a0S3p3K1D/Screen%20Shot%202012-10-05%20at%208.42.03%20PM.png)

```javascript
var canvas = document.getElementById('canvas');
var ctx = canvas.getContext('2d');

ctx.lineWidth = 11;
ctx.lineJoin = 'bevel';
ctx.lineCap = 'round';
ctx.globalAlpha = 0.5;
ctx.strokeStyle = '#fff';

ctx.beginPath();
ctx.moveTo(100, 200 );
ctx.lineTo(200, 250 );
ctx.lineTo(100, 320 );
ctx.lineTo(100, 350 );
ctx.bezierCurveTo( 100, 370, 130, 450, 200, 400 );

ctx.stroke();

ctx.beginPath();

ctx.translate(200,200);
ctx.scale(0.5,0.5);

ctx.moveTo(50, 350 );
ctx.lineTo(50, 50 );
ctx.lineTo(100, 50 );
ctx.lineTo(100, 150 );
ctx.lineTo(0, 150 );

ctx.stroke();
```