Skip to content

Instantly share code, notes, and snippets.

@miketahani
Created February 27, 2015 03:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save miketahani/66f4749d1edf221a8126 to your computer and use it in GitHub Desktop.
Save miketahani/66f4749d1edf221a8126 to your computer and use it in GitHub Desktop.
creating a canvas clip mask using compositing operations
ctx.save();
ctx.beginPath();
ctx.fillStyle = 'white';
path.context(ctx)(landClipTopo);
ctx.fill();
ctx.globalCompositeOperation = 'source-in';
ctx.fillStyle = 'red';
ctx.fillRect(w/2-200, h/2-200, 200, 200);
ctx.closePath();
ctx.restore();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment