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.