Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

207
Views
Access p5.js functions and properties on an object, instead of in the global scope?

There are tons of p5.js variables, and they are all defined globally, which can seriously clutter the global scope. Is there a way to store them in a single object, like this:

const p5 = [something goes here]
p5.setup
p5.draw
p5.preload
p5.color
p5.fill
p5.stroke
// instead of
setup
draw
preload
// ...etc

Is there a way to do that?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I think what you are looking for is the usage pattern for p5.js called instance mode. In this mode you create an instance of the p5 object with a callback that defines your sketch.

Additionally, if you are using TypeScript and/or compiling a Node.js package as a bundle or module for use in the browser than you can use the npm packages p5 and @types/p5 so that you can import/require p5 as a module and if you are using TypeScript get type checking.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!