Sof*_*oft 6 canvas processing.js
我正在使用processing.js在javascript中开发一个画笔应用程序它正在使用一个canvas对象.我想在画布的背景上保留一个图像.在前台画一些东西.保存时我只需要获取前景数据.
为此,我们需要使画布对象透明,以便可见背景图像.
我没有看到任何使画布透明的选项.我怎么做?
Jar*_*red 13
更好的是,在你的pjs顶部放了:
/* @pjs transparent=true; */
Run Code Online (Sandbox Code Playgroud)
...然后在你的绘制循环中:
background(0, 0, 0, 0);
Run Code Online (Sandbox Code Playgroud)
瞧!
<canvas> 默认是透明的.
我已经做了一个概念证明,可以在这里找到:
http://irae.pro.br/lab/canvas_pie_countdown/
针对IE6,IE7,IE8,Firefox 2,Firefox 3,Chrome和iPhone进行了测试.
context.clearRect(0,0,width, height)
Run Code Online (Sandbox Code Playgroud)
这就是您所需要的=)
请记住,您可以在画布对象上使用 CSS 样式。
canvas.style.position = "absolute";
canvas.style.left = the x position of the div you're going over +"px";
canvas.style.top = the y position of the div you're going over + "px";
Run Code Online (Sandbox Code Playgroud)