Help creating an ArrayList of color values

Here is another approach. Since color() returns an integer. We can use an ArrayList of integers, and just append with the color function.

ArrayList<Integer> colors;

void setup(){
  size(500, 500);
  
  colors = new ArrayList<Integer>();
  
  colors.add(color(255, 0, 0));
  
  fill(colors.get(0));
  rect(0, 0, 100, 100);
}
2 Likes