Login   Register  
PHP Classes
elePHPant
Icontem

File: example.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Robert Eisele  >  xColor  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: example file for xColor
Class: xColor
Manipulate color values
Author: By
Last change: As some didn't read the comments the infusion extension of PHP is needed for the class. I hacked the 3 functions needed by the class in PHP to get the class working without this extension.
Date: 4 years ago
Size: 785 bytes
 

Contents

Class file image Download
<?php

if(!extension_loaded('infusion')) {

    function 
bround($n$b) {

        if(
$b == 0) {
            return 
false;
        }
        return 
$n $b $n $b;
    }

    function 
limit($num$max) {
        return 
$num $max $max $num;
    }

    function 
bound($x$min$max) {

        if (
$x $min) {
            return 
$min;
        } else if (
$x $max) {
            return 
$max;
        } else {
            return 
$x;
        }
    }
}


require 
'xcolor.php';

$xc = new xColor;
$xc->setType(T_COLOR_HEXT_COLOR_RGB);
$c1 $xc->random();
$c2 $xc->random();

$xc->setType(T_COLOR_RGBT_COLOR_HEX);
echo 
$xc->red($c1); // 90FFFF
echo $xc->green($c1); // FF0CFF
echo $xc->blue($c1); // FFFFB8
echo $xc->webround($c2); // 66CC99

// Get the color point on a gradient
$xc->gradientLevel($c1$c2100rand(0,100));

?>