Login   Register  
PHP Classes
elePHPant
Icontem

File: color_harmony_generator.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Usman Didi Khamdani  >  Color Harmony Class  >  color_harmony_generator.php  >  Download  
File: color_harmony_generator.php
Role: Example script
Content type: text/plain
Description: this example is used to to generate one color to eight harmonic color in Monochromatic, Analogous, Complementary and Triads
Class: Color Harmony Class
Convert and generate harmonic colors
Author: By
Last change: fix using bgcolor with css background-color
Date: 4 years ago
Size: 6,768 bytes
 

Contents

Class file image Download
<!-- 
this example is used to to generate one color to eight harmonic color in Monochromatic, Analogous, Complementary and Triads
author: usman didi khamdani
author's email: usmankhamdani@gmail.com
author's phone: +6287883919293
--> 

<h3>Color Harmony Generator</h3>

<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
Hex Base Color <input type="text" name="bc" value="<?php if(isset($_POST['bc'])) { echo $_POST['bc']; } else {} ?>" /> <input type="submit" value="Generate" />
</form>
<hr />

<?php

if(isset($_POST['bc']) && $_POST['bc']!=NULL) {

    include(
'color_harmony.class.php');

    
$c = new colorHarmony;

    
$c->isHEX($_POST['bc']);

    if(
$c->HEXError==1) {
        echo 
$c->HEXErrorMessage;
    } else {

        echo 
'<table align="center" border="0" cellpadding="10">
        <tr>
        <td>'
;

        
##############################################

        
$RH1 $c->Monochromatic($_POST['bc']);

        echo 
'<h3>Monochromatic</h3>';
        echo 
'<table width="400" height="200" border="1" cellpadding="5">
        <tr>
        <td  align="center" valign="middle" style="background-color:'
.$RH1[0].'">'.$RH1[0].'</td><td  align="center" valign="middle" style="background-color:'.$RH1[1].'">'.$RH1[1].'</td><td  align="center" valign="middle" style="background-color:'.$RH1[2].'">'.$RH1[2].'</td><td  align="center" valign="middle" style="background-color:'.$RH1[3].'">'.$RH1[3].'</td>
        </tr>
        <tr>
        <td  align="center" valign="middle">Color 1</td><td  align="center" valign="middle">Color 2</td><td  align="center" valign="middle">Color 3</td><td  align="center" valign="middle">Color 4</td>
        </tr>
        <tr>
        <td  align="center" valign="middle" style="background-color:'
.$RH1[4].'">'.$RH1[4].'</td><td  align="center" valign="middle" style="background-color:'.$RH1[5].'">'.$RH1[5].'</td><td  align="center" valign="middle" style="background-color:'.$RH1[6].'">'.$RH1[6].'</td><td  align="center" valign="middle" style="background-color:'.$RH1[7].'">'.$RH1[7].'</td>
        </tr>
        <tr>
        <td  align="center" valign="middle">Color 5</td><td  align="center" valign="middle">Color 6</td><td  align="center" valign="middle">Color 7</td><td  align="center" valign="middle">Color 8</td>
        </tr>
        </table>'
;

        
##############################################

        
echo '</td>';

        echo 
'<td>';

        
##############################################

        
$RH2 $c->Analogous($_POST['bc']);

        echo 
'<h3>Analogous</h3>';
        echo 
'<table width="400" height="200" border="1" cellpadding="5">
        <tr>
        <td  align="center" valign="middle" style="background-color:'
.$RH2[0].'">'.$RH2[0].'</td><td  align="center" valign="middle" style="background-color:'.$RH2[1].'">'.$RH2[1].'</td><td  align="center" valign="middle" style="background-color:'.$RH2[2].'">'.$RH2[2].'</td><td  align="center" valign="middle" style="background-color:'.$RH2[3].'">'.$RH2[3].'</td>
        </tr>
        <tr>
        <td  align="center" valign="middle">Color 1</td><td  align="center" valign="middle">Color 2</td><td  align="center" valign="middle">Color 3</td><td  align="center" valign="middle">Color 4</td>
        </tr>
        <tr>
        <td  align="center" valign="middle" style="background-color:'
.$RH2[4].'">'.$RH2[4].'</td><td  align="center" valign="middle" style="background-color:'.$RH2[5].'">'.$RH2[5].'</td><td  align="center" valign="middle" style="background-color:'.$RH2[6].'">'.$RH2[6].'</td><td  align="center" valign="middle" style="background-color:'.$RH2[7].'">'.$RH2[7].'</td>
        </tr>
        <tr>
        <td  align="center" valign="middle">Color 5</td><td  align="center" valign="middle">Color 6</td><td  align="center" valign="middle">Color 7</td><td  align="center" valign="middle">Color 8</td>
        </tr>
        </table>'
;

        
##############################################

        
echo '</td>
        </tr>
        <tr>
        <td>'
;

        
##############################################

        
$RH3 $c->Complementary($_POST['bc']);

        echo 
'<h3>Complementary</h3>';
        echo 
'<table width="400" height="200" border="1" cellpadding="5">
        <tr>
        <td  align="center" valign="middle" style="background-color:'
.$RH3[0].'">'.$RH3[0].'</td><td  align="center" valign="middle" style="background-color:'.$RH3[1].'">'.$RH3[1].'</td><td  align="center" valign="middle" style="background-color:'.$RH3[2].'">'.$RH3[2].'</td><td  align="center" valign="middle" style="background-color:'.$RH3[3].'">'.$RH3[3].'</td>
        </tr>
        <tr>
        <td  align="center" valign="middle">Color 1</td><td  align="center" valign="middle">Color 2</td><td  align="center" valign="middle">Color 3</td><td  align="center" valign="middle">Color 4</td>
        </tr>
        <tr>
        <td  align="center" valign="middle" style="background-color:'
.$RH3[4].'">'.$RH3[4].'</td><td  align="center" valign="middle" style="background-color:'.$RH3[5].'">'.$RH3[5].'</td><td  align="center" valign="middle" style="background-color:'.$RH3[6].'">'.$RH3[6].'</td><td  align="center" valign="middle" style="background-color:'.$RH3[7].'">'.$RH3[7].'</td>
        </tr>
        <tr>
        <td  align="center" valign="middle">Color 5</td><td  align="center" valign="middle">Color 6</td><td  align="center" valign="middle">Color 7</td><td  align="center" valign="middle">Color 8</td>
        </tr>
        </table>'
;

        
##############################################

        
echo '</td>';

        echo 
'<td>';

        
##############################################

        
$RH4 $c->Triads($_POST['bc']);

        echo 
'<h3>Triads</h3>';
        echo 
'<table width="400" height="200" border="1" cellpadding="5">
        <tr>
        <td  align="center" valign="middle" style="background-color:'
.$RH4[0].'">'.$RH4[0].'</td><td  align="center" valign="middle" style="background-color:'.$RH4[1].'">'.$RH4[1].'</td><td  align="center" valign="middle" style="background-color:'.$RH4[2].'">'.$RH4[2].'</td><td  align="center" valign="middle" style="background-color:'.$RH4[3].'">'.$RH4[3].'</td>
        </tr>
        <tr>
        <td  align="center" valign="middle">Color 1</td><td  align="center" valign="middle">Color 2</td><td  align="center" valign="middle">Color 3</td><td  align="center" valign="middle">Color 4</td>
        </tr>
        <tr>
        <td  align="center" valign="middle" style="background-color:'
.$RH4[4].'">'.$RH4[4].'</td><td  align="center" valign="middle" style="background-color:'.$RH4[5].'">'.$RH4[5].'</td><td  align="center" valign="middle" style="background-color:'.$RH4[6].'">'.$RH4[6].'</td><td  align="center" valign="middle" style="background-color:'.$RH4[7].'">'.$RH4[7].'</td>
        </tr>
        <tr>
        <td  align="center" valign="middle">Color 5</td><td  align="center" valign="middle">Color 6</td><td  align="center" valign="middle">Color 7</td><td  align="center" valign="middle">Color 8</td>
        </tr>
        </table>'
;

        
##############################################

        
echo '</td>
        </tr>
        </table>'
;

    }

}

?>