We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Is it possible to pass PImage as a parameter to ? Than just use a boolean when I want to load or reload it.
ex: void name(PImage something){}
Answers
yes
How i cant seem to make it work?
Yes.
In fact, notice that in the PImage example, you are passing a PImage named photo as a parameter to the image() function.
this is what i tried. it said the float did not work
i am trying to load what i put into the function and move away from putting things in setup
setup() is the correct place to load any resources the sketch's gonna need.
Of course you can create separate functions to deal w/ loading stuff, but they still should be called from within setup().
Also notice loadImage() only accepts String arguments:
https://Processing.org/reference/loadImage_.html
You can load a lot into an array
Then we can just use the index of the array
There are tons of reasons to pass around PImages and encapsulate what you do with them in functions. But sometimes, you want to call those functions from setup.
In general: "NEVER load images from draw"
You can of course call bob from draw() but if you do, remember that draw runs 50 times per second.
So once you've called bob, set a boolean, that it's loaded and we don't want to load it again (check the boolean with if in bob)
Also, you have to pass a string to bob when you want to use it in bob with loadImage
so String imgName
and PImage img are different things in bob
bob could also return a value img to draw to let the img -- to let img be of global scope
But all this makes sense when you tell us what you are up to
I also noticed that a lot of questions from you didn't get an answer, so shame on us. PM me when you need more