pChart 2.x forum
http://wiki.pchart.net/forum/

pColor
http://wiki.pchart.net/forum/viewtopic.php?f=4&t=2222
Page 1 of 1

Author:  onnerby [ Thu Oct 27, 2011 1:33 pm ]
Post subject:  pColor

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 :D

Attachments:
pColor.class.php.zip [1.13 KiB]
Downloaded 975 times

Page 1 of 1 All times are UTC
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/