|
Revision 285, 1.7 kB
(checked in by bermiferrer, 3 years ago)
|
Reorganizing API packages hierarchy.
|
| Line | |
|---|
| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
require_once(AK_VENDOR_DIR.DS.'pear'.DS.'Image'.DS.'Color.php'); |
|---|
| 20 |
|
|---|
| 21 |
class AkColor extends Image_Color |
|---|
| 22 |
{ |
|---|
| 23 |
function rgbToHex() |
|---|
| 24 |
{ |
|---|
| 25 |
$rgb = func_get_args(); |
|---|
| 26 |
$hex = ''; |
|---|
| 27 |
foreach (count($rgb) == 1 ? $rgb[0] : $rgb as $color){ |
|---|
| 28 |
$color = dechex($color); |
|---|
| 29 |
$hex .= strlen($color) == 2 ? $color : $color.$color; |
|---|
| 30 |
} |
|---|
| 31 |
return $hex; |
|---|
| 32 |
} |
|---|
| 33 |
|
|---|
| 34 |
function hexToRgb($hex_color) |
|---|
| 35 |
{ |
|---|
| 36 |
$hex_color = strtolower(trim($hex_color,'#;&Hh')); |
|---|
| 37 |
return array_map('hexdec',explode('.',wordwrap($hex_color, ceil(strlen($hex_color)/3),'.',1))); |
|---|
| 38 |
} |
|---|
| 39 |
|
|---|
| 40 |
function getOpositeHex($hex_color) |
|---|
| 41 |
{ |
|---|
| 42 |
$rgb = AkColor::hexToRgb($hex_color); |
|---|
| 43 |
foreach ($rgb as $k=>$color){ |
|---|
| 44 |
$rgb[$k] = (255-$color < 0 ? 0 : 255-$color); |
|---|
| 45 |
} |
|---|
| 46 |
return AkColor::rgbToHex($rgb); |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
function getRandomHex() |
|---|
| 50 |
{ |
|---|
| 51 |
return AkColor::rgbToHex(rand(0,255),rand(0,255),rand(0,255)); |
|---|
| 52 |
} |
|---|
| 53 |
} |
|---|
| 54 |
|
|---|
| 55 |
?> |
|---|
| 56 |
|
|---|