I'm trying to build a freeform lasso tool to clip an image inside canvas. I'm using fabric.js to draw the shape. This is my attempt, many thanks to who can take some time for suggestions :)
<script src="http://ift.tt/1tznvBx" ></script>
<script src="http://ift.tt/k72nu2"></script>
<canvas id="c" width="500" height="500"></canvas>
<script>
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://ift.tt/1EY2Kze";
</script>
Aucun commentaire:
Enregistrer un commentaire