Imported Upstream version 0.6.26
This commit is contained in:
@@ -121,6 +121,7 @@ class pnp_Core {
|
||||
preg_match('/^(-?[0-9\.,]+)\s*(\S?)(\S?)/',$value,$matches);
|
||||
|
||||
$mag = 0;
|
||||
$value = $matches[1];
|
||||
while ($value >= $base){
|
||||
$value /= $base;
|
||||
$mag++;
|
||||
|
||||
@@ -444,6 +444,35 @@ class rrd_Core {
|
||||
return $line;
|
||||
}
|
||||
|
||||
# http://stackoverflow.com/questions/3512311/how-to-generate-lighter-darker-color-with-php
|
||||
public static function colbright($hex, $steps) {
|
||||
if($hex === FALSE){
|
||||
throw new Kohana_exception("rrd::". __FUNCTION__ . "() First Parameter 'hex' is missing");
|
||||
}
|
||||
if($steps === FALSE){
|
||||
throw new Kohana_exception("rrd::". __FUNCTION__ . "() Second Parameter 'steps' is missing");
|
||||
}
|
||||
// Steps should be between -255 and 255. Negative = darker, positive = lighter
|
||||
$steps = max(-255, min(255, $steps));
|
||||
|
||||
// Normalize into a six character long hex string
|
||||
$hex = str_replace('#', '', $hex);
|
||||
if (strlen($hex) == 3) {
|
||||
$hex = str_repeat(substr($hex,0,1), 2).str_repeat(substr($hex,1,1), 2).str_repeat(substr($hex,2,1), 2);
|
||||
}
|
||||
|
||||
// Split into three parts: R, G and B
|
||||
$color_parts = str_split($hex, 2);
|
||||
$return = '#';
|
||||
|
||||
foreach ($color_parts as $color) {
|
||||
$color = hexdec($color); // Convert to decimal
|
||||
$color = max(0,min(255,$color + $steps)); // Adjust color
|
||||
$return .= str_pad(dechex($color), 2, '0', STR_PAD_LEFT); // Make two char hex code
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
public static function debug($data=FALSE){
|
||||
if($data != FALSE){
|
||||
ob_start();
|
||||
|
||||
Reference in New Issue
Block a user