Problem loading images in chrome firefox in processing.js
in
Processing with Other Languages
•
8 months ago
The problem am facing is that when i run the example Background image the example runs properly on Chrome and firefox
but when i copy that program and save it in Processing sketch folder with an other name and making suitable changes to the size() function so that the image iam using is same as the window size and making sure that the image iam using is in the same folder as sketch and after doing all this when i run this example the image is not set as the back ground in chrome as well as firefox ...feeling strange as in java mode it works.
ive used processing quite a bit but first time trying out Javascript mode on processing 2.07b
ne help will be appreciated
this is the changes to the code i made
Note:i have placed the image in the same folder where the sketch resides
please tell me if i am missing any step
but when i copy that program and save it in Processing sketch folder with an other name and making suitable changes to the size() function so that the image iam using is same as the window size and making sure that the image iam using is in the same folder as sketch and after doing all this when i run this example the image is not set as the back ground in chrome as well as firefox ...feeling strange as in java mode it works.
ive used processing quite a bit but first time trying out Javascript mode on processing 2.07b
ne help will be appreciated
this is the changes to the code i made
Note:i have placed the image in the same folder where the sketch resides
please tell me if i am missing any step
- /**
* Background Image.
*
* This example presents the fastest way to load a background image
* into Processing. To load an image as the background, it must be
* the same width and height as the program.
*/
// The next line is needed if running in JavaScript Mode with Processing.js
/* @pjs preload="helloworld.jpg"; */
PImage bg;
int y;
void setup() {
size(621, 401);// the changes i made to match the image size
bg = loadImage("helloworld.jpg");
}
void draw() {
background(bg);
stroke(226, 204, 0);
line(0, y, width, y);
y++;
if (y > height) {
y = 0;
}
}
1