I want my processing sketch to load images from lorempixel at random, and display them to the user. I can do this perfectly fine from Processing ran in the Processing IDE, but it fails when I use it with Processing.js.
Here is my setup:
PImage img;
void setup() {
int x = (int) random(400,1024);
int y = (int) random(400,768);
String url = "http://lorempixel.com/" + x + "/" + y;
img = loadImage(url, "jpg");
size(x,y);
}
I get the following error in the JS console
GET http://lorempixel.com/494/548.jpg/ 404 (Not Found) processing-1.4.1.min.js:13
cW.loadImage processing-1.4.1.min.js:13
setup
b6 processing-1.4.1.min.js:13
F.Processing processing-1.4.1.min.js:13
Z processing-1.4.1.min.js:13
T.X.onreadystatechange
Why is it adding a .jpg to the end of my URL? Is there any way to load these images in the way I want?
I've tried removing the extra .jpg parameter from the loadImage call, but when I do that it successfully loads the image, and then crashes my program with the following error
Unable to get image data from canvas because the canvas has been tainted
by cross-origin data.
Can anyone explain why this is happening?