Help creating an ArrayList of color values

Okay, step 1 : make the class

class ColorContainer {

color col1=color(0);

ColorContainer(color c_) {
   col1=c_;
} // the constructor

} // the class 

See reference class and website | tutorials | objects

Step 2 : before setup ()

ArrayList<ColorContainer> listC = new ArrayList();

Step 3

In setup make a for loop using lerpColor

for(int i=0;i<100;i++) {
float amt=map(i,0,100,0,1);// tells point between 2 colors for lerpColor 
color c1=color(255,0,0);
color c2=color(0,255,0);
listC.add(new ColorContainer(lerpColor(c1,c2,amt));
} // for

https://processing.org/reference/lerpColor_.html

Step 4
usage is fill(listC.get(3).col1); for example

3 Likes