We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello,
I'm a beginner at processing. I have created an animation where circles bounce around the screen. I tried to put an image in the background using this in the draw function.
PImage img; img = loadImage("stars.jpg"); background(img);
It works but it makes the animation extremely slow and choppy. I understand that this is happening because for every frame the image file has to be accessed and drawn, which takes a lot of resources. I tried putting the image in the setup but then my moving balls leave black trails.
Is there a way to put an image on the background of an animation without visibly slowing down the animation?
Thank you.
Answers
Function loadImage() is extremely SLOW! Any resources a program use should be loaded & instantiated inside setup()! :-&
This makes the variable
img
accessible in both setup and drawWhat are setup() and draw()?
@quark Thank you! It works!