Maybe there already is some helper for colors. But I needed some helper to parse hex colors and was able to get different prefix and sufixed that pChart uses.
So it works like this:
Code:
$mycolor = new pColor('#ff00ff');
var_dump($mycolor->get());
// will output ARRAY('R'=>255,'G'=>0,'B'=>255,'Alpha'=>100)
var_dump($mycolor->get('Border','',false));
// will output ARRAY('BorderR'=>255,'BorderG'=>0,'BorderB'=>255)
// Arguments are $prefix, $sufix, $includeAlpha
There are also some helpers to make colors brighter/darker and ability to copy object in a simple maner:
Code:
$chartcolor = new pColor('#ff44ff');
// And if we need a darker border
$chartbordercolor = $chartcolor->copy()->darker(0.3);
A last example to draw a scale with different variations of the same base color:
Code:
$basecolor = new pColor('#ff4422');
$mychart->drawscale(array()
+ $basecolor->copy()->brighter()->get('Axis','',false)
+ $basecolor->copy()->brighter(0.9)->get('Grid','',false)
);
Hope this always helps someone