Return to Snippet

Revision: 52724
at November 1, 2011 13:30 by DanielFGray


Updated Code
<?php
/**
 * color scheme analyzer
 * works with any amount of colors, just change the array
 * this example uses the solarized color scheme <http://ethanschoonover.com/solarized>
 */
$pallette = array(
	'base03' => '#002b36',
	'base02' => '#073642',
	'base01' => '#586e75',
	'base00' => '#657b83',
	'base0' => '#839496',
	'base1' => '#93a1a1',
	'base2' => '#eee8d5',
	'base3' => '#fdf6e3',
	'yellow' => '#b58900',
	'orange' => '#cb4b16',
	'red' => '#dc322f',
	'magenta' => '#d33682',
	'violet' => '#6c71c4',
	'blue' => '#268bd2',
	'cyan' => '#2aa198',
	'green' => '#859900',
); ?>
<style type="text/css">
table {border-collapse:collapse; width:100%; font-weight:bold;}
tr {margin:0; padding:0; height:30px;}
td {margin:0; padding:0; width:<?php echo round(100/(count($pallette)+1), 2);?>%;}
</style>
<table>
<?php foreach($pallette as $color1=>$hex1):?>
	<tr style="background-color:<?php echo $hex1;?>">
	<td><?php echo $color1;?></td>
<?php foreach(array_reverse($pallette) as $color2=>$hex2):?>
		<td style="color:<?php echo $hex2;?>"><?php echo $color2;?></td>
<?php endforeach;?>
	</tr>
<?php endforeach;?>
</table>

Revision: 52723
at October 31, 2011 16:41 by DanielFGray


Initial Code
<?php
/**
 * color scheme analyzer
 * works with any amount of colors, just change the array
 * this example uses the solarized color scheme <http://ethanschoonover.com/solarized>
 */
$pallette = array(
	'base03' => '#002b36',
	'base02' => '#073642',
	'base01' => '#586e75',
	'base00' => '#657b83',
	'base0' => '#839496',
	'base1' => '#93a1a1',
	'base2' => '#eee8d5',
	'base3' => '#fdf6e3',
	'yellow' => '#b58900',
	'orange' => '#cb4b16',
	'red' => '#dc322f',
	'magenta' => '#d33682',
	'violet' => '#6c71c4',
	'blue' => '#268bd2',
	'cyan' => '#2aa198',
	'green' => '#859900',
); ?>
<style type="text/css">
table {border-collapse:collapse; width:100%;}
td {margin:0; padding:0; width:<?php echo round(100/(count($pallette)+1), 2);?>%;}
tr {margin:0; padding:0; height:30px;}
</style>
<table>
<?php foreach($pallette as $color1=>$hex1):?>
	<tr style="background-color:<?php echo $hex1;?>">
	<td><?php echo $color1;?></td>
<?php foreach($pallette as $color2=>$hex2):?>
		<td style="color:<?php echo $hex2;?>"><?php echo $color2;?></td>
<?php endforeach;?>
	</tr>
<?php endforeach;?>
</table>

Initial URL

                                

Initial Description

                                

Initial Title
php color-scheme viewer

Initial Tags
php, color

Initial Language
PHP