Shapes in a gridsystem
in
Programming Questions
•
2 years ago
Hey everybody,
i got a problem with this code.
I try to arrange shapes in a gridsystem but the shapes are separeted to some music genres and every shape represents a song. (its like a rect for hip hop and so on)
Also the data wich music genre it is, comes from a csv-Data.
Now my problem is i can display only every second song because i count only every second row.
- void setup() {
- size(800, 800);
- noStroke();
- int a =0;
- }
- void draw() {
- background(255);
- 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;
- }
- }
- //create csv array based on # of rows and columns in csv file
- csv = new String [lines.length][csvWidth];
- //parse values into 2d array
- 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];
- println(temp[j]);
- if(temp[j].equals("electro")){
- fill(255,200,0);
- rect(i++,j,1,20);
- }
- if(temp[j].equals("rock")){
- fill(255,0,0);
- rect(i++,j,1,20);
- }
- if(temp[j].equals("alternativ")){
- fill(0);
- rect(i++,j,1,20);
- }
- if(temp[j].equals("hip hop")){
- fill(0);
- rect(i++,j,1,20);
- }
- if(temp[j].equals("soundtrack")){
- fill(0);
- rect(i++,j,1,20);
- }
- if(temp[j].equals("live")){
- fill(0);
- rect(i++,j,1,20);
- }
- if(temp[j].equals("jazz")){
- fill(0);
- rect(i++,j,1,20);
- }
- if(temp[j].equals("pop")){
- fill(0);
- rect(i++,j,1,20);
- }
- noLoop();
- }
- }
- }
1