We are about to switch to a new forum software. Until then we have removed the registration on this forum.
It is a very basic question, I am trying to load an image that is inside the same folder of the index.html file but I can't. Here the code of the sketch:
var img;
function setup() {
createCanvas(windowWidth, windowHeight);
img=loadImage("img1.png");
}
function draw() {
image(img,0,0);
}
And here the code of the index.html:
<html>
<head>
<title>IMAGE</title>
<script language="javascript" type="text/javascript" src="../../lib/p5.js"></script>
<script language="javascript" type="text/javascript" src="sketch.js"></script>
</head>
<body>
</body>
</html>
What am I doing wrong? Thanks in advance!
Answers
http://p5js.org/reference/#/p5/preload
Unfortunately it doesn't solve the problem, the sketch is frozen in the loading.... moment. It looks like it is not able to access the image....
Maybe try out some Firefox-based browser in order to run your sketch. :-?
It worked, thanks! But what is the problem with Chrome and how could I make it more universal? I don't want my sketch to be browser-dependent!
https://forum.Processing.org/two/discussions/tagged/--allow-file-access-from-files
Thanks a lot!