Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

213
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda