Aussi étrange que cela puisse paraître, je ne pouvais pas trouver un double bon pour cette ...
Vous n'avez pas besoin de calculer un chemin à partir de votre bitmap. L'API CanvasRenderingContext2d offre quelques compositing and blending options, ce qui vous permettra de travailler directement avec les bitmaps.
fabricjs propose également cette option: http://fabricjs.com/docs/fabric.Object.html#globalCompositeOperation
var c = new fabric.Canvas('c', {
imageSmoothingEnabled: false
});
fabric.Image.fromURL(
'https://dl.dropboxusercontent.com/s/4e90e48s5vtmfbd/aaa.png',
function(image1) {
fabric.Image.fromURL(
'https://upload.wikimedia.org/wikipedia/commons/5/55/John_William_Waterhouse_A_Mermaid.jpg',
function(image2) { // the one to be clipped
c.add(image1);
c.add(image2);
c.renderAll();
}, {
globalCompositeOperation: 'source-in', // will be drawn only where pixels are already drawn
top: -300,
left: -400
});
}, {
width: 200,
height: 200
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/fabric.js/1.7.18/fabric.js"></script>
<canvas id="c" width="500" height="500"></canvas>
Ne pas utiliser clipPath mais compositing. Pas vraiment en tissu donc pas une bonne cible dupe https://stackoverflow.com/questions/25752870/clipping-image-to-image-using-canvas Mais il y en a, j'en suis sûr. – Kaiido