Random Composite with SVG Files
in
Programming Questions
•
3 years ago
Hi there,
I'm using SVG files to create a composite image. The image is made up of either one, two or three SVG files (on top of each other). This is fine to program with simply just 3 SVG files but say I have 15 and I want to access them in a random manner yet always keep to the rule of only using one, two or three of them to make the final composite. I can't seem to get my head around that. Here is my code :
int numShapes;
float rd = random (0,100);
if (rd <=33) {
numShapes = 1;
} else if ((rd > 33) && (rd < 66)) {
numShapes = 2;
} else {
numShapes = 3;
}
PShape[] composite = new PShape[numShapes];
for (int i = 0; i < composite.length; i++) {
String fileName = "forme_" + nf(i, 3) + ".svg";
composite[i] = loadShape(fileName);
shape(composite[i], 25, 25);
}
Any pointers in the correct direction would be much appreciated. Cheers
M
2