# How to create different color for each point

**URL:** <https://discourse.processing.org/t/how-to-create-different-color-for-each-point/21011>\
**Category:** Coding Questions\
**Tags:** homework\
**Created:** [May 18, 2020, 10:29am UTC](https://discourse.processing.org/t/how-to-create-different-color-for-each-point/21011 "2020-05-18T10:29:20Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DeathEater](https://avatars.discourse-cdn.com/v4/letter/d/2acd7d/32.png) [@DeathEater](https://discourse.processing.org/u/DeathEater)\
**Post date:** [May 18, 2020, 10:29am UTC](https://discourse.processing.org/t/how-to-create-different-color-for-each-point/21011/1 "2020-05-18T10:29:20Z")

</div>

```auto
import java.awt.Point;

final static int N_POINTS_EACH= 13;

float scale = 0.25f;

ArrayList <PointSet> allpointsets;

int currentset = 0;

void settings() {
  size(700, 500);
}

void setup() {
  frameRate(60);
  allpointsets = new ArrayList(); // processing doesn't recognize the <> 
  Table table = loadTable("points.csv", "header");
  for ( TableRow tr : table.rows() ) {
    
    allpointsets.add(new PointSet(tr));
    
    
    
  }
  //println(allpointsets.size());
}

void draw() {
  background(0);
  strokeWeight(5);
  
  
  PointSet ps = allpointsets.get(currentset);
  for ( Point p : ps.points ) {
    // Java default double -> Processing default float
    
    stroke(random(0,255),random(0,255),random(0,255));
    point((float)p.getX()*scale, (float)p.getY()*scale );
    
    
   
  }
  
  currentset++;
  if ( currentset>=allpointsets.size() ) currentset = 0;
  
}

void keyPressed(){ //changes the value of scale when the key is pressed.
  if (key==','){
    scale -= 0.01;
  }
  else if(key=='.'){
    scale += 0.01;
  }
}

class PointSet {
  Point [] points;

  PointSet( processing.data.TableRow row ) {
    points = new Point[N_POINTS_EACH];
    for (int i=0; i<N_POINTS_EACH; i++) {
      int x = row.getInt( "x"+(i+1) ); // +1 because starting from "x1" in data 
      int y = row.getInt( "y"+(i+1) );
      points[i] = new Point(x, y);
    }
  }
}

```

---

<div class="post-metadata">

**Author:** ![josephh](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/josephh/32/210_2.png) [@josephh](https://discourse.processing.org/u/josephh)\
**Post date:** [May 18, 2020, 3:27pm UTC](https://discourse.processing.org/t/how-to-create-different-color-for-each-point/21011/2 "2020-05-18T15:27:09Z")

</div>

Hi,

Welcome to the community! 😉

First of all, you should format your code by pressing `Ctrl+T` in the Processing IDE then use the `</>` button in the message editor on the forum.
