I figured out, that if I comment out anything having to do with the image, the code works in the browser (Firefox):
Here´s what happens in a smaller test example: I used a coding example from the MAKE: Getting started with p5.js book. They mention some things having to do with servers, but don´t go into detail and commence with the coding example below…
var img;
function preload() {
img = loadImage("lunar.jpg");
}
function setup() {
createCanvas(480,120);
}
function draw() {
image(img, 0, 0);
}
The .jpg-file is copied into the project folder and is located besides the sketch.js file.
Here´s the consoles error:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at file:///C:/Users/Dandimite/Desktop/p5/Lunar_pic/lunar.jpg. (Reason: CORS request not http).
TypeError: NetworkError when attempting to fetch resource.
THX for help!!
BX