fill shapes with pattern

edited October 2015 in How To...

How do I create a pattern, that changes its style taken from data at a .csv? For example I have a .csv with data including different numbers of affected people and I want to see that in the pattern, lets say with different sized dots. Is that possible in processing to take the information from the linked .csv and connect it to the styling of the pattern? If yes how do I do it?

Answers

  • EXAMPLE:

    //String[] data;
    String[] data = { "EARTH,0,0,255,300", "MOON,128,128,128,60", "MARS,255,0,0,200" };
    
    void setup(){
      size(400,400);
      textAlign(CENTER, CENTER);
      //data = loadStrings("my_data.csv");
      background(0);
      for(int line=0; line<data.length;line++){
       String[] words = data[line].split(",");
       fill( int(words[1]),int(words[2]),int(words[3]) );
       pushMatrix();
       translate( random(width), random(height) ); 
       ellipse(0,0,int(words[4]),int(words[4]));
       fill(255);
       textSize(24);
       text(words[0],0,0);
       popMatrix();
      }
      noLoop();
    }
    
  • Thanks, but I mean more like small dots filling a shape of a country (somehow like the pointillism example, but with no image) and the dots are more when there are more people affected and also bigger than the dots in another shape with less people affected. And the number of people and countries are in my .csv file!

  • I gave you an example that shows how to get data from a CSV file and draw different things depending on the data found in the CSV file.

    It's sort of hard to help you any more than this because you haven't provided any code showing us what you have working so far. Are you having trouble getting data from the CSV file? Are you having trouble using that data to draw different things?

  • edited November 2015

    Done

  • edited November 2015

    Done

Sign In or Register to comment.