You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
letmovie;functionpreload(){// my video is 640 x 360movie=createVideo("flyboard.mp4");movie.volume(0);}functionsetup(){createCanvas(640,360);pixelDensity(1);movie.play();// Commenting this out makes it workmovie.hide();}functiondraw(){background(220);// Commenting this out makes it work// (or moving it to setup it seems)movie.size(width,height);image(movie,0,0);}
Previously, if elt.width was 0, due to the || check, it would get overridden with a different value. However, after this commit, it only gets overridden if the value is exactly undefined.
elt.width is 0 because offsetWidth is 0 for any element with display: none, which is what we set when we hide a video element. To address the source of this issue, rather than reverting that commit (relying on the difference between 0 and undefined is maybe something we should try to avoid relying on), I recommend replacing these lines:
Most appropriate sub-area of p5.js?
p5.js version
1.6.0 to 1.8.0
Web browser and version
Firefox 117
Operating System
MacOS 14
Steps to reproduce this
Steps:
createVideo
video.hide()
video.size(w, h)
image(video, 0, 0)
This shows nothing on canvas post 1.6.0. Omitting steps 2 or 3 makes it work again (it seems it's the combination of both of them that does it.)
Specifically, these two lines evaluate to 0 when setting the size on the hidden element:
p5.js/src/dom/dom.js
Lines 2267 to 2268 in 28740f9
Snippet:
https://editor.p5js.org/davepagurek/sketches/YwkhJXFtr
The text was updated successfully, but these errors were encountered: