Canvas being redrawn at 200x200 px

Hi All,

For some reason this sketch keeps displaying a canvas at 200x200px when I want it to be 500x500. The image is not scaled down, it just shows the top, left corner. When first building this sketch with just one image it worked and I was able to see the entire image. This behavior started when I added the preload function. In vscode the word setup in the setup function is darker now too. Something is going on that I don’t understand. The same behavior occurs in the online p5js editor.

Thank you!

let img = [];

function preload() {
  for (let i = 0; i < 10; i++) {
    img[i] = loadImage("assets/images/" + "meme" + i + ".jpg");

  function setup() {
    createCanvas(500, 500);

function draw() {
  let randImg = random(img);
  image(randImg, 0, 0, 500, 500);

Do you really want function setup() inside of function preload()? Usually they are separate.


No! I can’t believe I didn’t see that. It works now, thank you!!! :joy:

1 Like