如何用P5J制作透明的画布?
最多。 0.7.3,画布是透明的。 在此样品中,可以在圆环周围看到青色背景。
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.js"></script>
<iframe width="640" height="360" src="http://www.youtube.com/embed/M7lc1UVf-VE"></iframe>
<script>
function setup() {
createCanvas(400, 400, WEBGL);
fill('lightpink');
}
function draw() {
torus(100, 40);
}
</script>
<style>
canvas {
position: absolute;
z-Index: 1;
top: 0;
left: 0;
}
</style>
</body>
但是在该版本之后,绘制了黑色背景。 在此样品中,画布被不透明的黑色填充。 差异只是版本。
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.1/p5.js"></script>
<iframe width="640" height="360" src="http://www.youtube.com/embed/M7lc1UVf-VE"></iframe>
<script>
function setup() {
createCanvas(400, 400, WEBGL);
fill('lightpink');
}
function draw() {
torus(100, 40);
}
</script>
<style>
canvas {
position: absolute;
z-Index: 1;
top: 0;
left: 0;
}
</style>
</body>
如何制作最新版本的P5.js透明?
PS。 为了明确说明,我编辑了YouTube电影的背景。 使用旧的P5J,它是透明的,可以通过P5图看电影。但是有了新版本,画布被黑色背景填充,我无法叠加电影上的图纸。
Up to ver. 0.7.3, the canvas is transparent.
In this sample, cyan background can be seen around the torus.
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/0.7.3/p5.js"></script>
<iframe width="640" height="360" src="http://www.youtube.com/embed/M7lc1UVf-VE"></iframe>
<script>
function setup() {
createCanvas(400, 400, WEBGL);
fill('lightpink');
}
function draw() {
torus(100, 40);
}
</script>
<style>
canvas {
position: absolute;
z-Index: 1;
top: 0;
left: 0;
}
</style>
</body>
But after that version, black background is drawn.
In this sample, canvas is filled by opaque black color.
The difference is only the version.
<body>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.1/p5.js"></script>
<iframe width="640" height="360" src="http://www.youtube.com/embed/M7lc1UVf-VE"></iframe>
<script>
function setup() {
createCanvas(400, 400, WEBGL);
fill('lightpink');
}
function draw() {
torus(100, 40);
}
</script>
<style>
canvas {
position: absolute;
z-Index: 1;
top: 0;
left: 0;
}
</style>
</body>
How can I make the latest version of p5.js transparent?
PS.
To make the point clear, I edited the background to youtube movie.
With the old p5js, it is transparent and can see the movie through the p5 drawing. But with the new version, canvas is filled by black background and I cannot overlay the drawing on the movie.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以通过文档找到的一种方法是使用背景功能
One way i can find through DOCS is using background function