9
A
回答
0
设置铅笔颜色到透明:
context.fillStyle = "rgba(255,0,0,0)";
在rgba()
格式,最后一个是α通道,0是完全透明的
2
作为替代方案,可以使用绘制在多个<canvas>
对象然后从顶部画布擦除以显示下方的图像。参见:html5 - canvas element - Multiple layers
16
基本上,将globalCompositeOperation
设置为copy
,并使用不透明度为0的颜色(例如, "rgba(0,0,0,0)"
你正在尝试。
的问题是回答在这里更详细一点:
3
function eraser()
{
context.strokeStyle = "rgb(255, 255, 255)";
context.globalCompositeOperation = "copy";
context.strokeStyle = ("rgba(255,255,255,255)"); /* or */ context.fillStyle = "rgba(255,0,0,0)";
}
无论是在我的情况下工作!
1
https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API/Tutorial/Compositing
其实功能是:
function eraser(){
context.strokeStyle = "rgb(255, 255, 255)";
context.globalCompositeOperation = "destination-out";
context.strokeStyle = ("rgba(255,255,255,255)");
/* or */
context.fillStyle = "rgba(255,0,0,0)";
}
你可以回到源过来。
0
代码用于使用globalCompositeOperation“目的地-out”和“源极 - 之上”
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();
}
透明橡皮擦我已经使用easeljs这里但是代码是独立于它,并且可以与任何画布HTML5绘制的javascript被集成代码
+0
请问您能否进一步解释代码 – utdev 2017-04-27 19:49:30
相关问题
- 1. HTML5帆布:globalCompositeOperation(橡皮擦)
- 2. 橡皮擦/橡胶为Android帆布
- 3. 在html5画布中的橡皮擦工具
- 4. 橡皮擦在OpenGL ES iphone
- 5. iPhone石英绘图橡皮擦
- 6. 橡皮擦工具为iOS应用
- 7. Java:类型橡皮擦实施
- 8. 素描应用的橡皮擦
- 9. 橡皮擦不适用于iOS绘图
- 10. osx橡皮擦滑动背景
- 11. 画布,我的橡皮擦不起作用
- 12. 帆布内部的帆布html5
- 13. HTML5帆布和bubble.js
- 14. 画布上的半透明橡皮刷
- 15. 在html中使用.Zap橡皮擦文件
- 16. 如何在DrawingApp中实现橡皮擦功能?
- 17. 橡皮擦等效绘图应用程序,C#,Silverlight,WP7
- 18. 帮助用橡皮擦从缓冲图像
- 19. 如何在android中实现手指橡皮擦?
- 20. 如何在android中使用手指橡皮擦?
- 21. OpenGL图形编辑器...执行橡皮擦工具
- 22. 如何在SVG中实现橡皮擦功能?
- 23. 为什么在使用橡皮擦时会出现黑线?
- 24. 画一条线,就像一个橡皮擦Swift3
- 25. ios和橡皮筋
- 26. HTML5帆布碰撞检测
- 27. HTML5帆布扇贝形状
- 28. HTML5帆布:程度符号
- 29. HTML5帆布使用easeljs锅
- 30. HTML5帆布带圆角
它没有工作。 “橡皮擦铅笔”剧照以红色(实际绘图铅笔的颜色)绘制。 – Valentina 2010-09-24 19:38:07
尝试将颜色设置为“透明”(http://dev.w3.org/csswg/css3-color/#transparent),或者'strokestyle'而不是'fillstyle' – Javier 2010-09-24 19:43:26
=(没有,我已经试过了context.strokeStyle =“rgba(0,0,0,0)”; and context.fillStyle =“rgba(0,0,0,0)”;。任何想法? – Valentina 2010-09-24 19:46:46