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

264
Vistas
p5.js loadImage and image to set a background image

SOLVED I was missing script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.4.0/p5.min.js"> in index.html

I am using JavaScript and the p5.js library in VSC and trying to get an image to load to use as a background. Previously I had the script.js and background.png files in separate folders under the same parent directory, but I changed them temporarily to see if the file paths were the problem. The code in script.js stands as following:

let BG;

function preload() {
    BG = loadImage('background.png');
}

function setup() {
    createCanvas(200,200);
    image(BG,0,0,100,100);
}

And as mentioned before, the files are all in the same directory. File structure

I would like to get the image saved as background.png to display on the canvas because currently it does not. I have used loadImage() and image() in exactly this fashion before in preload() and setup(), though this time it is not working. Help is appreciated, thank you.

about 4 years ago · Juan Pablo Isaza
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