I try to draw a path and they use it as a mask of my canvas.
'use strict'; var canvas = new fabric.Canvas('c', { hoverCursor: 'pointer', isDrawingMode: true }); canvas.freeDrawingBrush = new fabric.PencilBrush(canvas); canvas.freeDrawingBrush.color = '#000'; canvas.freeDrawingBrush.width = 100; fabric.Image.fromURL('http://fabricjs.com/assets/pug_small.jpg', function(img) { canvas.add(img); canvas.setWidth(img.getWidth()); canvas.setHeight(img.getHeight()); canvas.centerObject(img); img.selectable = false; }); canvas.on('path:created', function(data) { var path = data.path; canvas.remove(path); canvas.clipTo = function(context) { path.render(context); }; canvas.isDrawingMode = false; canvas.renderAll(); });
How can I make the whole path the visible area of my image?
http://jsfiddle.net/db45yhpo/
EDIT
This is what I am trying to achieve, but using FabricJS.
http://www.createjs.com/demos/easeljs/alphamaskreveal
html5-canvas canvas fabricjs
Alex Figueiredo
source share