PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of tobozo   HTML Color Matrix   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example code
Class: HTML Color Matrix
Determine the closest browser safe color value
Author: By
Last change: fixed typo (thanks to Lito for notifying)
Date: 18 years ago
Size: 1,159 bytes
 

Contents

Class file image Download
<?
 
/* $Id: example.php,v 1.0 2004/27/11 22:12:25 tobozo Exp $ */
?>
<html>
<head>
  <title>Find closest color</title>
</head>
<body><pre>

Code example :

&lt;?

require_once('colorMatrixHTML.class');


$red = 72;
$green = 123;
$blue = 211;

$HTMLcolor = colorMatrix::getClosestRGBLColor($red, $green, $blue);

?&gt;
</pre>
<?

require_once('colorMatrixHTML.class');

$red = 72;
$green = 123;
$blue = 211;

$hex = '#a1b2c3';

$HTMLcolor = colorMatrix::getClosestRGBColor($red, $green, $blue);




echo
"<font style='color:rgb($red,$green,$blue);'>This is the original color (red=$red, green=$green, blue=$blue)</font><br>";

echo
"<font style='color:$HTMLcolor;'>This is the closest color (html color = $HTMLcolor)</font><br><br>";

$hex = '#a1b2c3';

?><pre>

$HTMLcolor = colorMatrix::getClosestHTMLColor($hex);

</pre><?

$HTMLcolor
= colorMatrix::getClosestHTMLColor($hex);

echo
"<font style='color:$hex;'>This is the original color (hex=$hex)</font><br>";

echo
"<font style='color:$HTMLcolor;'>This is the closest color (html color = $HTMLcolor)</font><br><br>";

?>

</body>
</html>