-
Notifications
You must be signed in to change notification settings - Fork 77
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
Incompatible with P5.js version 1.7.0 and 1.8.0 #254
Comments
I can confirm this :/ |
I am trying to tracking down the causes but no luck. here are things that I have tried so far,
if (this.drawingContext && this.drawingContext.__clearCanvas) {
this.drawingContext.__clearCanvas()
} the change throws the following error
throws following error.
looks like renderint.ts
it seems 1.8.0 added
Diff p5.createGraphics 1.6.0 -> 1.8.0 Diff p5.createCanvas 1.6.0 -> 1.8.0 |
Just confirming that this error is still the case for p5.js v.1.9.0. |
It appears this may be due to a difference in how the p5 source is bundled? The function Renderer2D(elt, pInst, isMainCanvas) {
var _this;
_classCallCheck(this, Renderer2D);
_this = _super.call(this, elt, pInst, isMainCanvas);
_this.drawingContext = _this.canvas.getContext('2d');
_this._pInst._setProperty('drawingContext', _this.drawingContext);
return _this;
} It works for me locally if in the file p5.Renderer2D.call(this, elt, pInstProxy, isMainCanvas) to Object.assign(this, p5.Renderer2D.call(this, elt, pInstProxy, isMainCanvas)) |
Awesome, the change you suggested works on the editor.p5js.org with p5.js v.1.9.0 too - woo hoo🎉 |
Confirmed working locally with p5.js v1.9.0 as well. |
I'm curious if someone would be willing to publish their fork with this working change. I tried the same patch locally and published it to npm, but it wasn't performing as expected in my project 👀 |
@xanderjl I have not forked it but if it helps, I have included a patched version in my Toko framework. That one works fine with p5.js v1.9.0. |
Hi guys, I tried your fix and it's works just on |
I confirmed that Lines 51 to 53 in 553c2b2
As @CampbellOwen suggested now Render2D is a class instead of a function since version 1.7.0, class Renderer2D extends p5.Renderer {
constructor(elt, pInst, isMainCanvas) {
super(elt, pInst, isMainCanvas);
this.drawingContext = this.canvas.getContext('2d');
this._pInst._setProperty('drawingContext', this.drawingContext);
} I've managed to run the tests on a forked branch for p5.js 1.9.0. |
commit d2003ab Author: yuta nakayama <nkymut@gmail.com> Date: Sun May 12 19:31:15 2024 +0800 update: rollup dependencies ver commit 03e463d Author: yuta nakayama <nkymut@gmail.com> Date: Sat May 11 08:29:59 2024 +0800 fix: package.json commit a052366 Author: nkymut <nkymut@gmail.com> Date: Fri May 10 14:09:30 2024 +0800 fix: p5.js@1.7.0+ (zenozeng#254,zenozeng#255,zenozeng#258) commit b59ef84 Author: nkymut <nkymut@gmail.com> Date: Fri May 10 11:41:21 2024 +0800 fix: createGraphics@1.7.0+(zenozeng#254) commit 9742701 Author: yuta nakayama (didny) <didny@nus.edu.sg> Date: Tue May 7 17:14:03 2024 +0800 add to .gitignore fix:zenozeng#255 commit 7f79e7d Author: yuta nakayama (didny) <didny@nus.edu.sg> Date: Tue May 7 17:03:36 2024 +0800 fix typo commit e1dde64 Author: yuta nakayama (didny) <didny@nus.edu.sg> Date: Tue May 7 16:59:11 2024 +0800 excempt dist/p5.svg.js from .gitignore fix:zenozeng#255 commit 040bf76 Author: yuta nakayama (didny) <didny@nus.edu.sg> Date: Tue May 7 16:46:20 2024 +0800 add dist commit e9e0e5c Merge: c71403f cf65a2f Author: yuta nakayama (didny) <didny@nus.edu.sg> Date: Tue May 7 15:56:44 2024 +0800 merge BL451 fix commit c71403f Author: yuta nakayama (didny) <didny@nus.edu.sg> Date: Tue May 7 15:40:57 2024 +0800 update examples to 1.9.0 commit cf65a2f Author: Benjamin Lappalainen <b.m.lappalainen@gmail.com> Date: Sat Mar 23 13:29:40 2024 -0400 Fix compatibility with p5js 1.7.0+
If I try to use p5.js-svg with a newer version of p5.js (1.7.0 and 1.8.0) I get the following error message:
Uncaught TypeError: this.drawingContext is undefined
When I switch back the p5 version to 1.6.0, everything is fine. An easy way to test is is to use the example page from this repository and try different versions of p5.js.
The full message I get in Firefox is:
I get a similar error message in Chrome:
And Safari:
The text was updated successfully, but these errors were encountered: