View unanswered posts | View active topics It is currently Thu Mar 28, 2024 11:35 pm



Reply to topic  [ 1 post ] 
pColor 
Author Message
New pChart user
New pChart user

Joined: Fri Oct 21, 2011 6:30 pm
Posts: 3
Post 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 900 times
Thu Oct 27, 2011 1:33 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 1 post ] 

Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron