The color properties can be linked (as any other property) to variable. Changing the variable, changes the color.
You need to define an array of colors. In Java the correct type can be either int or java.awt.Color. In Javascript you need an array of either int or String.
for (i=0; i < N ; i + + ) { // color change lookang if (v[i] <0.5) { // v[i] is the array of the velocities of i number of particles color[i] = "rgba(50,0,250,255)"; // low velocity blue color } else if ( v[i]<1){ color[i] = "rgba(100,0,200,255)"; } else if ( v[i]<1.5){ color[i] = "rgba(150,0,150,255)"; } else if ( v[i]<2){ color[i] = "rgba(200,0,100,255)"; } else { color[i] = "rgba(250,0,50,255)"; // high velocity red color } }
Thanks all of you. But I still cannot set color I want because I don't know how to set array of int which can use for set color. Now I am using just one integer to set color.