Skip to content

Commit fd7958b

Browse files
committed
bugfix: P_4_3_1_02 added sorting of filenames
Previously the files were sorted automatically by their filenames and therefore loaded in the correct order. Since some version of Processing this had somehow changed, so we've put that sorting in.
1 parent 2dc36ac commit fd7958b

39 files changed

+278
-10469
lines changed

01_P/P_4_3_1_02/P_4_3_1_02.pde

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,29 @@ void setup() {
4545
// ------ load shapes ------
4646
// replace this location with a folder on your machine or use selectFolder()
4747
//File dir = new File(selectFolder("choose a folder with svg files ..."));
48-
File dir = new File(sketchPath(""),"data");
48+
File dir = new File(sketchPath(""), "data");
49+
4950
if (dir.isDirectory()) {
5051
String[] contents = dir.list();
51-
shapes = new PShape[contents.length];
52+
String[] svgFiles = new String[0];
5253
for (int i = 0 ; i < contents.length; i++) {
5354
// skip hidden files and folders starting with a dot, load .svg files only
5455
if (contents[i].charAt(0) == '.') continue;
5556
else if (contents[i].toLowerCase().endsWith(".svg")) {
5657
File childFile = new File(dir, contents[i]);
57-
println(childFile.getPath());
58-
shapes[shapeCount] = loadShape(childFile.getPath());
59-
shapeCount++;
58+
println(i, childFile.getPath());
59+
svgFiles = append(svgFiles, childFile.getPath());
6060
}
6161
}
62+
63+
svgFiles = sort(svgFiles);
64+
65+
shapeCount = svgFiles.length;
66+
shapes = new PShape[shapeCount];
67+
for (int i = 0 ; i < shapeCount; i++) {
68+
shapes[i] = loadShape(svgFiles[i]);
69+
}
6270
}
63-
64-
println(shapeCount);
6571
}
6672

6773
void draw() {
@@ -104,4 +110,4 @@ void keyReleased() {
104110
String timestamp() {
105111
Calendar now = Calendar.getInstance();
106112
return String.format("%1$ty%1$tm%1$td_%1$tH%1$tM%1$tS", now);
107-
}
113+
}
Lines changed: 8 additions & 8 deletions
Loading

01_P/P_4_3_1_02/data/076.svg

Lines changed: 0 additions & 949 deletions
This file was deleted.

01_P/P_4_3_1_02/data/076_m.svg

Lines changed: 11 additions & 0 deletions
Loading
Lines changed: 10 additions & 10 deletions
Loading

0 commit comments

Comments
 (0)