-
-
Notifications
You must be signed in to change notification settings - Fork 3.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
p5.MediaElement size() #1079
Comments
I'm not sure how this happened but I'm looking at p5.dom.js 0.2.7 and the code change from 317fdd1 no longer seems to be in there. This is causing the pixels not to be resized appropriately when calling I believe here line 1679: if (this.canvas.width !== this.elt.width) {
this.canvas.width = this.elt.videoWidth;
this.canvas.height = this.elt.videoHeight;
this.width = this.canvas.width;
this.height = this.canvas.height;
} should be: if (this.canvas.width !== this.elt.width) {
this.canvas.width = this.elt.width;
this.canvas.height = this.elt.height;
this.width = this.canvas.width;
this.height = this.canvas.height;
} Or maybe something should be happening when |
thanks for catching this! i think there was something tricky with this one... let me look into it tomorrow. what would be super helpful is a unit test for this. i think it could just check the size of elements or a test a few pixels in the pixels array. |
very weird, i can't tell how this got lost but you're right it should def be the second version. i just made the change. thanks! |
This is an additional fix for when you want to draw a resized video into your canvas, but have not yet called loadPixels().
Additional fix #1079 drawing p5.MediaElement after size()
This particular fix was reverted due to issue #1274 and the pixels array length does not match the specified I am making a video about this question and when I upload that video I will post a link here. Just to be clear again, the code that resolves this issue is: if (this.canvas.width !== this.elt.width) {
this.canvas.width = this.elt.width;
this.canvas.height = this.elt.height;
this.width = this.canvas.width;
this.height = this.canvas.height;
} The code that resolves #1274 is: if (this.canvas.width !== this.elt.width) {
this.canvas.width = this.elt.videoWidth;
this.canvas.height = this.elt.videoHeight;
this.width = this.canvas.width;
this.height = this.canvas.height;
} What code would resolve both? |
Here is the video where I filed this issue. |
ahhh thank you for tracking down why this part always seems to be broken! and the video is amazing! i don't think this should be too hard to fix, i think the problem previously was just that we didn't realize there were two conflicting cases we kept switching back and forth between. i'll take a look at this in the next few days. |
Hi Lauren, Sorry this mail slipped by me.. I haven't found a solution yet that solves On Tue, Apr 12, 2016 at 10:26 AM, Lauren McCarthy notifications@github.com
Craig Pickard |
Ok, I think I've fixed this. The fix was to update if (this.canvas.width !== this.elt.width) {
this.canvas.width = this.elt.width;
this.canvas.height = this.elt.height;
this.width = this.canvas.width;
this.height = this.canvas.height;
} Both this issue and #1274 should work properly now. These were the two test cases I was using: for issue #1079: var capture;
function setup() {
createCanvas(640, 480);
capture = createCapture(VIDEO);
capture.size(320, 240);
}
function mousePressed() {
image(capture, 0, 0);
} and for issue #1274: var capture;
function setup() {
createCanvas(640, 480);
capture = createCapture(VIDEO);
}
function mousePressed() {
var img = capture.get(0, 0, width, height);
image(img, 0, 0, width, height);
} please let me know if i missed anything! |
Hooray! I promised to make a follow-up video about this so will do so and test! |
* 'master' of https://github.com/processing/p5.js: (52 commits) fix for vertically centering multiline text (issue processing#1316), updated documentation for textAlign() function fixes processing#1079 fixes processing#1274 Fix sort() example first pass xml done xml in progress xml in progress in progress xml fixing push pop around redraw closes processing#1058 adding documentation for createRadio() closes processing#1315 adding documentation for saveFarmes() closes processing#1324 adding example for drop Don't trigger warnings on preload(). Fixes processing#1350. fix processing#1349 extending timeout to 5s closes processing#1344 Add reference.css to style docs in this repository. Preprocess docs descriptions as Markdown. Delete progress.txt Fix trailing whitespace in random.js Improve documentation for random() clarify rationale for catching exceptions thrown by defineProperty. ...
Filing an issue @lmccart and I just talked about related to #1022. We adjusted the associated canvas size when calling
loadPixels()
so that the pixel array would match the DOM element size. I'm noticing users confused even when just callingimage()
to draw the image to the canvas that the size doesn't match what is set withsize()
.The text was updated successfully, but these errors were encountered: