This is a port of the randomColor.js script created by David Merfield.
RandomColor generates attractive colors by default. More specifically, RandomColor produces bright colors with a reasonably high saturation. This makes randomColor particularly useful for data visualizations and generative art.
Get the code on GitHub
Once you have included RandomColor.class.php on your app, calling RandomColor::one($options) or RandomColor::many($count, $options) will return a random attractive color. Beneath is the live output of 36 generations.
RandomColor::many(36);
You can also pass an options object to randomColor. This allows you to specify the hue, luminosity and the format of colors to generate.
RandomColor::one(array('format'=>'hex'));
// "#f4c804"
RandomColor::one(array('format'=>'hsv'));
// array('h'=>49,'s'=>98,'v'=>96)
RandomColor::one(array('format'=>'hsl'));
// array('h'=>49,'s'=>96.0799999999999982946974341757595539093017578125,'l'=>48.96000000000000085265128291212022304534912109375)
RandomColor::one(array('format'=>'rgb'));
// array('r'=>244.0,'g'=>200.0,'b'=>4.0)
RandomColor::one(array('format'=>'hslCss'));
// "hsl(49,96.08%,48.96%)"
RandomColor::one(array('format'=>'rgbCss'));
// "rgb(244,200,4)"
RandomColor::one(array('format'=>'hexa'));
// "#f4c80400"
RandomColor::one(array('format'=>'hsva'));
// array('h'=>49,'s'=>98,'v'=>96)
RandomColor::one(array('format'=>'hsla'));
// array('h'=>49,'s'=>96.0799999999999982946974341757595539093017578125,'l'=>48.96000000000000085265128291212022304534912109375,'a'=>NULL)
RandomColor::one(array('format'=>'rgba'));
// array('r'=>244.0,'g'=>200.0,'b'=>4.0,'a'=>NULL)
RandomColor::one(array('format'=>'hslaCss'));
// "hsla(49,96.08%,48.96%,)"
RandomColor::one(array('format'=>'rgbaCss'));
// "rgba(244,200,4,)"
RandomColor::many(18, array('hue'=>'red'));
RandomColor::many(18, array('hue'=>'orange'));
RandomColor::many(18, array('hue'=>'yellow'));
RandomColor::many(18, array('hue'=>'green'));
RandomColor::many(18, array('hue'=>'blue'));
RandomColor::many(18, array('hue'=>'purple'));
RandomColor::many(18, array('hue'=>'pink'));
RandomColor::many(18, array('hue'=>'monochrome'));
RandomColor::many(27, array('hue'=>array('blue', 'yellow')));
RandomColor::many(27, array('luminosity'=>'light'));
RandomColor::many(27, array('luminosity'=>'dark'));
RandomColor::many(36, array('luminosity'=>'random', 'hue'=>'random'));
RandomColor::many(18, array('format' => 'rgbaCss'));