Hi everyone, I wanted to know if there is a solution to import a lot of svg at the same time. they are all in the same folder. I have like 100 and I can’t see myself writing “PShape bot, bot2, bot3 …;”
Because I wanted to overlap each svg.
Thank you in advance for your answer.
PShape bot, bot2, bot3 ;
void setup() {
fullScreen();
// The file “bot1.svg” must be in the data folder
// of the current sketch to load successfully
bot = loadShape(“frame-0052 17.55.11 17.56.26.svg”);
bot2 = loadShape(“frame-0053 17.55.11 17.56.26.svg”);
bot3 = loadShape(“frame-0056 17.55.11 17.56.26.svg”);
noLoop();
}
void draw(){
background(0);
stroke(255);
noFill();
bot.disableStyle(); // Ignore the colors in the SVG
shape(bot);
bot2.disableStyle(); // Ignore the colors in the SVG
shape(bot2);// Draw
bot3.disableStyle(); // Ignore the colors in the SVG
shape(bot3);// Draw
}
I believe that you can also look for an ArrayList to load the files and add the shapes. However, this will only work if the filenames are equal or at least follow the same format. In your example, they all have the following format:
“frame-00XX 17.56.26.svg”
So, a loop might be a good idea. Something like:
int listSize = 100; //number of files
int count = 0; //lets asssume that the first svg has the name frame-0000 17.56.26.svg
//If it does not have just change to whatever integer you want it to start
ArrayList<PShape> bots; //ArrayList of shapes
void setup() {
bots = new ArrayList<PShape>();
//Load all the .svg files
for (int i = count; i < count + listSize; i++) {
//println("frame-00" + i + " 17.56.26.svg"); //DEBUG THE FILENAME
String filename = "frame-00" + i + " 17.56.26.svg";
bots.add(loadShape(filename)); //Load shape and add
}
}
void draw() {
background(0);
stroke(255);
noFill();
//For enhanced loop to disable and display shapes
for(PShape bot : bots){
bot.disableStyle();
shape(bot);
}
}
Thanks, it works perfectly! I modified the code a bit, and I also changed my file saving mode to make things easier. Thanks again . It’s been a week since I discovered Processing3 and I find it really interesting