^^Random color
La stringa rgb(nr,nr,nr), si puo' costruire in molti modi.
La funzione si puo' usare senza sapere come funziona !!!
Basta copiarla e incollarla nel proprio script. (E poi richiamarla alla bisogna).
function random_color() // restituisce una stringa che descrive un random color
{var color_str_random = "rgb(";
var d56 = 256;
color_str_random += Math.floor(d56*Math.random());
color_str_random += "," + Math.floor(d56*Math.random());
color_str_random += "," + Math.floor(d56*Math.random());
color_str_random += ")" ;
return color_str_random;
}
colorRed = Math.floor(256*Math.random()); // color intensity 0-255
colorGreen = Math.floor(256*Math.random()); // color intensity 0-255
colorBlue = Math.floor(256*Math.random()); // color intensity 0-255
ctx.fillStyle = "rgb("+colorRed+","+colorGreen+","+colorBlue+")";