Lasso tool in html5 canvas
问题 I'm trying to build a freeform lasso tool to clip an image inside canvas. I'm using fabric.js to draw the shape. var canvas = document.getElementById('c'); var ctx = canvas.getContext('2d'); var img = document.createElement('IMG'); img.onload = function() { var OwnCanv = new fabric.Canvas('c', { isDrawingMode: true }); OwnCanv.freeDrawingBrush.color = "purple" OwnCanv.freeDrawingBrush.width = 4 ctx.clip(); ctx.drawImage(img, 0, 0); } img.src = "http://upload.wikimedia.org/wikipedia/commons/3