Código de goma transparente usando globalCompositeOperation "destino de salida" y "fuente-over"
var handleMouseMove = function (event) {
midPt = new createjs.Point(oldPt.x + stage.mouseX>>1, oldPt.y+stage.mouseY>>1);
if(curTool.type=="eraser"){
var tempcanvas = document.getElementById('drawcanvas');
var tempctx=tempcanvas.getContext("2d");
tempctx.beginPath();
tempctx.globalCompositeOperation = "destination-out";
tempctx.arc(midPt.x, midPt.y, 20, 0, Math.PI * 2, false);
tempctx.fill();
tempctx.closePath();
tempctx.globalCompositeOperation = "source-over";
drawingCanvas.graphics.clear();
// keep updating the array for points
arrMidPtx.push(midPt.x);
arrMidPty.push(midPt.y);
stage.addChild(drawingCanvas);
stage.update();
}
he utilizado easeljs aquí sin embargo, el código es independiente de la misma y se puede integrar con cualquier javascript dibujo HTML5 Canvas código
No funciona. Los alambiques del 'borrador' se dibujan en rojo (el color del lápiz de dibujo real). – Valentina
intente configurar el color como simplemente "transparente" (http://dev.w3.org/csswg/css3-color/#transparent), o tal vez 'strokestyle' en lugar de' fillstyle' – Javier
= (Nada. Ya lo intenté context.strokeStyle = "rgba (0,0,0,0)"; y context.fillStyle = "rgba (0,0,0,0)"; ¿Alguna idea? – Valentina