Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

199
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda