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 Rodrigo Brandão  >  Create Colors  >  example.php  >  Download  
File: example.php
Role: Example script
Content type: text/plain
Description: Example of how to use the class
Class: Create Colors
Create a color based on another tone
Author: By
Last change:
Date: 2012-03-11 18:34
Size: 2,470 bytes
 

Contents

Class file image Download
<?php

include "createcolors.class.php";

$cc = new createcolors();

// the original color (can be defined = #ffeedd, ffeedd, #fde, fde)
$hex = isset($_GET["hex"]) ? $_GET["hex"] : "#79fd12";

// to create a color 40% darker than the original
$color $cc->hex($hex,"-40%");

// the "%" symbol can be ignored 
$color $cc->hex($hex,"-40");

// to create a color 66% lighter than the original
$color $cc->hex($hex,"+66%");

// the "%" and "+" symbols can be ignored
$color $cc->hex($hex,66);

// can use the function to create a correct hex (example: in = 3da, out = #33ddaa)
$color $cc->hex($hex);


/* Example of how to use the Create Colors class! */
$colors[0] = $cc->hex($hex,"-100");
$colors[1] = $cc->hex($hex,"-80");
$colors[2] = $cc->hex($hex,"-60");
$colors[3] = $cc->hex($hex,"-40");
$colors[4] = $cc->hex($hex,"-20");
$colors[5] = $cc->hex($hex,"+20");
$colors[6] = $cc->hex($hex,"+40");
$colors[7] = $cc->hex($hex,"+60");
$colors[8] = $cc->hex($hex,"+80");
$colors[9] = $cc->hex($hex,"+100");
?><!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Example of how to use the Create Colors class!</title>
<style>
body {
    margin:0;
    padding:0;
}
header {
    padding:20px;
    font-family:Georgia, "Times New Roman", Times, serif;
    font-style:italic;
    font-size:20px;
    background-color:#eee;
    color:#999;
    letter-spacing:-1px;
}
header strong {
    font-size:28px;
    color:#666;
}
header div {
    float:right;
    padding:0;
    margin:0;
}
header div input {
    border:0;
    margin:0 0 0 5px;
    padding:5px;
    font-size:14px;
    background-color:#ccc;
    color:#333;
    width:63px;
    font-family:"Courier New", Courier, monospace;
    font-weight:bold;
}
header div input.submit {
    background-color:#444;
    color:#eee;
    width:30px;
}
div { 
    padding:15px; font-family:"Courier New", Courier, monospace;
    font-size:14px;
    font-weight:bold;
}

/* color */
div {
    color:<?php echo $cc->hex($hex?>
}
<?php foreach($colors as $i=>$c) : ?>
    .color<?php echo $i ?> {
        background-color:<?php echo $c ?>;
    }
<?php endforeach; ?>
</style>
</head>
<body>
<header>Example of how to use the <strong>Create Colors</strong> class!
    <div>
        <form method="get">
            <input type="text" name="hex" value="<?php echo $hex ?>" maxlength="7">
            <input type="submit" value="Go" class="submit">
        </form>
    </div>
</header>
<?php foreach($colors as $i=>$c) : ?>
    <div class="color<?php echo $i ?>"><?php echo $c ?></div>
<?php endforeach; ?>
</body>
</html>