PHP Classes

Color Tools: Convert colors between different color models

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 126 All time: 9,360 This week: 125Up
Version License PHP version Categories
colortools 1.0.0BSD License5PHP 5, Graphics
Description 

Author

This class can convert colors between different color models.

It can take a color parameter as a value in several color models or as a name and converts it any of the color models it supports.

Current it supports color models in RGB hexadecimal, RGB, HSL, HSB, WebSafe, CMY, CMYK, GRAYSCALE, an array of individual byte values or an integer value.

The names of supported colors are read from a text file.

Picture of Christian Vigh
  Performance   Level  
Name: Christian Vigh <contact>
Classes: 32 packages by
Country: France France
Age: 57
All time rank: 13810 in France France
Week rank: 8 Up1 in France France Up
Innovation award
Innovation award
Nominee: 20x

Winner: 3x

Example

<?php
   
/******************************************************************************************

        This example shows the conversion some color values into different colorimetric
        models.

     ******************************************************************************************/

   
require_once ( 'Colors.phpclass' ) ;

    if (
php_sapi_name ( ) != 'cli' )
        echo
"<pre>" ;

   
$test_colors = array
       (
       
'#A0A0A0',
       
'#FFF',
       
'RGB(1,2,3)',
       
'Graphite',
       
'#0000FF'
       
) ;


    foreach (
$test_colors as $test_color )
       {
        echo
"Color to test : $test_color\n" ;
       
$color = new Color ( $test_color ) ;
        echo
"Color value in different colorimetric models :" ;
        echo
"\t" . str_replace ( "\n", "\n\t", print_r ( $color -> ToArray ( ), true ) ) . "\n" ;
        }


  Files folder image Files  
File Role Description
Accessible without login Plain text file ColorNames.txt Data Documentation
Plain text file Colors.phpclass Class Class source
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file README.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:126
This week:0
All time:9,360
This week:125Up