Skip to content

Conversation

@Spongman
Copy link
Contributor

@Spongman Spongman commented Aug 16, 2018

fixes #3153

yet another confusion between this.canvas and this.elt

IMHO, since the Renderers (and p5 itself) are instanceof p5.Element we should remove those classes' this.canvas properties and change all the code to use the p5.Element.elt variable. having two variables (sometimes) that serve the same purpose requires code like this:

cnv = img.canvas || img.elt;

if (this.canvas !== undefined) {

if (this.isSrcP5Image) {

@Zalastax
Copy link
Member

I agree with your sentiment but wonder how this situation came to be.
Searching for .canvas = I get these results:

this.canvas = document.createElement('canvas');

this.canvas = document.createElement('canvas');

this.canvas = elt;

this.canvas = document.createElement('canvas');

this._pInst.canvas = c;

Searching for .elt = I get these results:
this.elt = elt;

elt = this.elt = arg.elt;

elt = this.elt = existing_radios.elt;

and a comment about checking if the canvas is associated with the p5 instance

p5.js/lib/addons/p5.dom.js

Lines 1938 to 1939 in 5a46133

// main canvas associated with p5 instance
if (this._pInst._curElement.elt === this.elt) {

Some of the places that assign canvas also assign elt afterwards. There seems to be a thought behind this. If we decide to not go with your suggestion I really want that thought to be well documented.

@Spongman
Copy link
Contributor Author

i'm guessing it's just a consequence of how things came together organically over time. perhaps Graphics wasn't originally instanceof p5.Element...

@Spongman
Copy link
Contributor Author

Spongman commented Aug 16, 2018

i'm going to close this, as i think the issue may be more involved than what i did here.

@Spongman
Copy link
Contributor Author

i think that should be a bit better. the issue was that the canvas was not initialized before delegating the calls to the 2d renderer. the elt/canvas issue can wait for another day ;-)

@lmccart lmccart merged commit 2cb6a4d into processing:master Aug 26, 2018
@lmccart
Copy link
Member

lmccart commented Aug 26, 2018

thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

video.get() seems to freeze live stream of the video

3 participants