I have a clipping mask, and I want two images to be added to it, but I can only get one to show.
<canvas id='toilet_roll' width="900" height="1500"></canvas>
<script>
var design = 'http://dr.schwartzer.uk/paper1.png',
clip = 'http://dr.schwartzer.uk/roll_mask.png',
objImg = new Image(),
objImg2 = new Image(),
objMask = new Image(),
canvas = document.getElementById('toilet_roll'),
ctx = canvas.getContext("2d"),
x = 0,
y = 0;
function animate()
{
ctx.drawImage(objMask, 0, 0, 900, 1500);
ctx.globalCompositeOperation = 'source-in';
ctx.drawImage(objImg2, 0, y, 900, 1500);
ctx.drawImage(objImg, 0, (y+200), 900, 1500);
}
objImg.src = design;
objImg2.src = design;
objMask.src = clip;
objMask.onload = animate;
</script>
...but only the second image (objImg2) is clipped, objImg doesn't show at all.
Can anyone shed some light on what I'm doing wrong?