在P5js中,我想在视频上叠加一个形状,但它们不共享同一个dom.
Code test here:视频应该通过切割形状的三角形轮廓可见.
代码:
let video;
function preload() {
video = createVideo("video.mp4");
}
function setup() {
createCanvas(400, 300);
background("gray");
video.size(400,400);
video.loop();
var w = width * 0.7;
var h = height * 0.7;
translate((width/2) - (w/2), (height/2) - (h/2));
fill("lightgray");
noStroke();
beginShape();
vertex(0, 0);
vertex(w, 0);
vertex(w, h);
vertex(0, h);
beginContour();
vertex(w * 0.2, h * 0.4);
vertex(w * 0.5, h * 0.8);
vertex(w * 0.8, h * 0.4);
endContour();
endShape();
noLoop();
}
我看到here个隐藏视频,使用image
(即image(video, 10, 10)
)可以绘制单个帧.唉,我使用noLoop()
,在我的情况下,draw()
中不会自动刷新视频.