13 May 2019 This article covers the trick to generate a random color everytime in a single line of code so that you need not write down whole hexadecimal 

8428

x = 1 + int( random(6) ); // se comporta como un dado, de 1 a 6 El ordenador es incapaz de generar números realmente aleatorios, utiliza una tabla de números pseudo-aleatorios para ofrecernos resultados lo bastante aleatorios para la mayoría de los casos.

#CCFFAA We will use eight bit color for our grayscale range and 24 bit for full color (eight bits for each of the red, green, and blue color components). By adding the stroke () and fill () functions before something is drawn, we can set the color of any given shape. There is also the function background (), which sets a background color for the window. That's the general approach, and in your case you'll probably want to store those variables in your Planet class so that each planet can have its own color. Here's a small example that follows that approach to show a random color whenever the user clicks the mouse: