Back to Parent

Processing sketch
JSONObject json;
String genre = "pop rap";
String[] genres;
PFont f; 

void setup() {
  size(800,600);
  f = createFont("Arial",26,true);
  json = loadJSONObject("roisinspotifydata.json");

  JSONArray values = json.getJSONArray("items");
  genres = new String[values.size()];
 
  
  //String[] genres = new String[values.size()];

  for (int i = 0; i < values.size(); i++) {
    //int id = animal.getInt("id");

    JSONObject genrename = values.getJSONObject(i); 
    String genre = genrename.getString("genre");
    genres[i] = genre;
    //String name = animal.getString("name");


  //if(genre.equals("pop rap") == true) {  

    println(genre);
  //}

  }
}

void draw() {
  
  background(26);
  stroke(255);
  for (int i = 0; i < genres.length; i++){
    if(genres[i].equals("pop rap") == true){
       fill(164, 96, 145);
      ellipse(120,250,50,50);
    }
    
    if(genres[i].equals("hip hop") == true){
      fill(127, 42, 104, 180);
      ellipse(270,230,88,88);
      ellipse(270,230,70, 70);
      ellipse(270,230,60,60);
      ellipse(270,230,52,52);
      textSize(20);
      text(genres[i], 240, 295);
    }
    
    if(genres[i].equals("australian alternative rock") == true) {
      fill(103, 142, 144, 160);
      ellipse(150, 120, 70, 70);
      ellipse(150, 120, 60, 60);
      textSize(18);
      text(genres[i], 120, 175);
  }
  
   if(genres[i].equals("underground hip hop") == true) {
      fill(150, 167, 177, 190);
      ellipse(250, 350, 50, 50);
  }
  
     if(genres[i].equals("rap") == true) {
      fill(102, 98, 153, 190);
      ellipse(360, 400, 65, 65);
  }
  
       if(genres[i].equals("dance pop") == true) {
      fill(1, 30, 45, 190);
      ellipse(470, 310, 50, 50);
  }
  
       if(genres[i].equals("hip pop") == true) {
      fill(123, 90, 147, 180);
      ellipse(270, 520, 80, 80);
      ellipse(270, 520, 70, 70);
  }
  
       if(genres[i].equals("grime") == true) {
      fill(22, 18, 84, 200);
      ellipse(430, 190, 40, 40);
  }
  
       if(genres[i].equals("g funk") == true) {
      fill(85, 120, 139, 200);
      ellipse(650, 440, 60, 60);
  }
  
       if(genres[i].equals("r&b") == true) {
      fill(84, 43, 114, 200);
      ellipse(570, 380, 40, 40);
  }
  
       if(genres[i].equals("pop") == true) {
      fill(40, 84, 108, 170);
      ellipse(520, 440, 78, 78);
      ellipse(520, 440, 56, 56);
      text(genres[i], 500, 500);
  }

}
  textSize(26);
  fill(255);
  text("Spotyourself", 350, 30);
  textSize(18);
  text("what your music taste looks like", 300, 50);
}
Click to Expand

Content Rating

Is this a good/useful/informative piece of content to include in the project? Have your say!

0