Mat100
June 23, 2021, 9:54am
1
Hi,
How do I load images numbered 0000 - 0100?
I have a series of images "frame-0000.png to “frame-0100.png”
If I use this code…
for (int i = 0; i < images.length; i ++ ) {
images[i] = loadImage( "frame-000" + i + ".png"); }
it will only load images 0-9.
If I it change to…
for (int i = 0; i < images.length; i ++ ) {
images[i] = loadImage( "frame-" + i + ".png"); }
it will of course complain there is no image called “frame-0.png” etc
How do I add a wildcard so it looks more like… or let “i” always be a four digit number with leading zeroes?
for (int i = 0; i < images.length; i ++ ) {
images[i] = loadImage( "frame-" "*" + i + ".png"); }
Many thanks!
glv
June 23, 2021, 10:42am
2
Hello,
One of these should take care of that:
There are resources (tutorials, references, examples) here:
:)
Mat100
June 23, 2021, 10:53am
3
Ah ha, many thanks!
I had just started watching a first String tutorial on YouTube (Coding Train), and I see the next is called “Split and Join”, so that should be interesting
I’ve never coded anything before so I’m a bit slow
Many thanks!
glv
June 23, 2021, 10:55am
4
Hello,
Take a look at one (or all!) of the n*() ones… used a wildcard there!
:)
glv
June 23, 2021, 11:04am
6
Hello,
Keep in mind that some of the Processing “helper” functions\methods are there to simplify things.
I used one of the n*() functions here to clean up the output:
3D Mesh of Sine Waves from Coding Challenge
You can also use Java methods:
Java String format() method with method signature and examples of concat, compare, touppercase, tolowercase, trim, length, equals, split, string format in java etc.
Since you are a beginner progress at your own pace.
:)
1 Like
Mat100
June 23, 2021, 2:11pm
7
Ahh, worked a treat!
Thanks for the example for printing the colour values, very helpful.
And interesting to know you can use Java syntax in addition!
Thanks again!
1 Like