How to upload image in p5.js mode

I would like to upload an image file named "dillustration-01.png" (dimension: 1995 × 1667pixels) in p5.js mode. But if I use the following code, I get a blank screen with no image. I double checked that I have added the file "dillustration-01.png" in my sketch and I don't know why it's not working. Is there anything wrong with what I'm doing?

var img;  // Declare variable 'img'.

function setup() {
  createCanvas(1000, 1000);
  img = loadImage("dillustration-01.png");  // Load the image
}

function draw() {
  // Displays the image at its actual size at point (0,0)
  image(img, 0, 0);
  // Displays the image at point (0, height/2) at half size
  //image(img, 0, height/2, img.width/2, img.height/2);
}

Answers

Sign In or Register to comment.