Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

ezmath.php
Go to the documentation of this file.
1 <?php
20 class eZMath
21 {
31 static function normalizeColorArray( $array )
32 {
33 foreach ( array_keys( $array ) as $key )
34 {
35 $array[$key] = (float)$array[$key]/256;
36 }
37
38 return $array;
39 }
40
49 static function rgbToCMYK( $rgbArray )
50 {
51 $cya = 1 - min( 1, max( (float)$rgbArray['r'], 0 ) );
52 $mag = 1 - min( 1, max( (float)$rgbArray['g'], 0 ) );
53 $yel = 1 - min( 1, max( (float)$rgbArray['b'], 0 ) );
54
55 $min = min( $cya, $mag, $yel );
56 if ( 1 - $min == 0 )
57 {
58 return array( 'c' => 1,
59 'm' => 1,
60 'y' => 1,
61 'k' => 0 );
62 }
63
64 return array( 'c' => ( $cya - $min ) / ( 1 - $min ),
65 'm' => ( $mag - $min ) / ( 1 - $min ),
66 'y' => ( $yel - $min ) / ( 1 - $min ),
67 'k' => $min );
68 }
69
81 static function rgbToCMYK2( $r, $g, $b )
82 {
83 return eZMath::rgbToCMYK( array( 'r' => $r,
84 'g' => $g,
85 'b' => $b ) );
86 }
87 }
88 ?>
eZMath
eZMath provide a simple math library for common math operations
Definition: ezmath.php:21
eZMath\rgbToCMYK
static rgbToCMYK( $rgbArray)
Definition: ezmath.php:49
eZMath\rgbToCMYK2
static rgbToCMYK2( $r, $g, $b)
Definition: ezmath.php:81
eZMath\normalizeColorArray
static normalizeColorArray( $array)
Definition: ezmath.php:31
Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.