Next row
in
Programming Questions
•
2 years ago
Hello,
I have a problem with this script.
I load forms via a csv file.
But my problem is that all forms are loaded in a row. So I have a long number of shapes
Now my question: how can I wrap the series after a certain length?
EDIT:
Here is the code,csv and Forms. ;)
www.stephanlinsert.de//Testpage/Data.zip
- void setup() {
- size(1600, 800);
- noStroke();
- smooth();
- }
- void draw() {
- PShape s1;
- PShape s2;
- PShape s3;
- PShape s4;
- PShape s5;
- PShape s6;
- PShape s7;
- PShape s8;
- s1 = loadShape("Form/electro.svg");
- s2 = loadShape("Form/rock.svg");
- s3 = loadShape("Form/alternativ.svg");
- s4 = loadShape("Form/hiphop.svg");
- s5 = loadShape("Form/soundtrack.svg");
- s6 = loadShape("Form/live.svg");
- s7 = loadShape("Form/jazz.svg");
- s8 = loadShape("Form/pop.svg");
- background(200);
- String lines[] = loadStrings("Test.csv");
- String [][] csv;
- int csvWidth=0;
- //calculate max width of csv file
- for (int i=0; i < lines.length; i++) {
- String [] chars=split(lines[i], ',');
- if (chars.length>csvWidth) {
- csvWidth=chars.length;
- }
- }
- csv = new String [lines.length][csvWidth];
- for (int i=0; i < lines.length; i++) {
- String [] temp = new String [lines.length];
- temp= split(lines[i], ',');
- for (int j=0; j < temp.length; j++) {
- csv[i][j]=temp[j];
- if (temp[j].equals("electro")) {
- shape(s1, i*21, j, 20, 20);
- }
- if (temp[j].equals("rock")) {
- shape(s2, i*21, j, 20, 20);
- }
- if (temp[j].equals("alternativ")) {
- shape(s3, i*21, j, 20, 20);
- }
- if (temp[j].equals("hip hop")) {
- shape(s4, i*21, j, 20, 20);
- }
- if (temp[j].equals("soundtrack")) {
- fill(0, 190, 25);
- shape(s5, i*21, j, 20, 20);
- }
- if (temp[j].equals("live")) {
- shape(s6, i*21, j, 20, 20);
- }
- if (temp[j].equals("jazz")) {
- shape(s7, i*21, j, 20, 20);
- }
- if (temp[j].equals("pop")) {
- shape(s8, i*21, j, 20, 20);
- }
- }
- }
- }
1