processing / processing/p5.js

[p5.js 2.0 Bug Report]: p5.Graphics does not have the setAttributes function

Open
#8,170 9 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Area:Core Area:WebGL p5.js 2.0+
Dominant language
JavaScript
Stars
24k
Forks
3.8k
Avg merge
3d 16h
Merged PRs (30d)
25

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:
  1. Create a new WebGL graphic via let g = createGraphics(200, 200, WEBGL)
  2. 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: https://github.com/processing/p5.js/blob/095f22090d774d28bdc3d977d0bc5b2e646233d6/src/core/p5.Graphics.js#L676-L693

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?)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in src/core/p5.Graphics.js around lines 676-693 and inspect how addon modules are registered on p5.Graphics.prototype. Compare that path with the renderergl addon and the p5.registerAddon entry point, then reproduce the reported createGraphics(..., WEBGL) and setAttributes call. Done means the missing method and the broader addon-registration behavior are addressed without breaking existing registration.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.