-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Description
Most appropriate sub-area of p5.js?
- Accessibility
- Color
- Core/Environment/Rendering
- Data
- DOM
- Events
- Image
- IO
- Math
- Typography
- Utilities
- WebGL
- Build process
- Unit testing
- Internationalization
- Friendly errors
- Other (specify if possible)
p5.js version
2.0.5
Web browser and version
Any
Operating system
Any
Steps to reproduce this
Steps:
- Create a new WebGL graphic via
let g = createGraphics(200, 200, WEBGL) - Try to set its attributes via
g.setAttributes({ antialias: true })
Currently this fails because the function doesn't exist.
This is because, in 2.0, we add the usual p5 methods to p5.Graphics by explicitly setting up every addon module a second time by calling it on p5.Graphics.prototype:
Lines 676 to 693 in 095f220
| primitives2D(p5, p5.Graphics.prototype); | |
| attributes(p5, p5.Graphics.prototype); | |
| curves(p5, p5.Graphics.prototype); | |
| vertex(p5, p5.Graphics.prototype); | |
| customShapes(p5, p5.Graphics.prototype); | |
| setting(p5, p5.Graphics.prototype); | |
| loadingDisplaying(p5, p5.Graphics.prototype); | |
| image(p5, p5.Graphics.prototype); | |
| pixels(p5, p5.Graphics.prototype); | |
| transform(p5, p5.Graphics.prototype); | |
| primitives3D(p5, p5.Graphics.prototype); | |
| light(p5, p5.Graphics.prototype); | |
| material(p5, p5.Graphics.prototype); | |
| creatingReading(p5, p5.Graphics.prototype); | |
| trigonometry(p5, p5.Graphics.prototype); |
However, this is not a comprehensive list of addon modules (the renderergl one is missing, which has setAttributes), but also it means that if a third-party addon adds a method to p5, it will not get added to p5.Graphics.
So I think the fix for this shouldn't be just to add the renderergl module, but to see if we can fix addon registration to also work on p5.Graphics.prototype. (@limzykenneth, do you have thoughts on how to accomplish that? Would we get ordering issues if we make p5.registerAddon do both p5.prototype and p5.Graphics.prototype?)