Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/same.hue.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Nathan Lucas  >  Color Conversion  >  examples/same.hue.php  >  Download  
File: examples/same.hue.php
Role: Example script
Content type: text/plain
Description: Similar colors of the same hue.
Class: Color Conversion
Convert color values between different models
Author: By
Last change:
Date: 2008-05-27 08:42
Size: 818 bytes
 

Contents

Class file image Download
<?php
/**
 * This is an example on using Color to get similar
 * colors based on a supplied hex or rgb color.
 */

$hsv Color::hex2hsv("#00CCFF");
//$hsv = Color::rgb2hsv(0, 204, 255);

for ($i 0$i 5$i++) {
    
$rS mt_rand(0100);
    
$rV mt_rand(0100);

    
$bg "#".Color::hsv2hex($hsv['h'], $rS$rV);
    
//$rgb = Color::hsv2rgb($hsv['h'], $rS, $rV);
    //$bg = "rgb(".$rgb['r'].", ".$rgb['g'].", ".$rgb['b'].")"
    
echo "<div style=\"width:100px;height:100px;background-color:".$bg.";\">&nbsp;</div>\n";
}

/**
 * You can do the same but for random hues keeping the same by
 * keeping the supplied saturation and value, random saturation
 * by keeping the hue and value, and this will also work using
 * the HSL methods, if you prefer to work with those values.
 */
?>