// Note: two files needed here, Args.php (http://pastebin.com/WvEasCnB) and ColorScheme.php (http://pastebin.com/JL7CpLNy)
// For inserting colors into a CSS file. For example,
// format .css like this, using double hashes and codes
// from the color scheme (like in
// http://students.washington.edu/kuksenok/colors/ColorScheme.php?demo)
// and then call this file with REQUEST colors set to the scheme
// pointer, and the styles - to the .css file. The output will be well-formatted
// CSS. The benefit is that all the styles work perfectly fine without this,
// and many schemes can be easily applied.
// eg: http://students.washington.edu/kuksenok/colors/ColorCSS.php?colors=billow&styles=CW.css
// http://students.washington.edu/kuksenok/colors/ColorCSS.php?colors=grorange&styles=CW.css
// http://students.washington.edu/kuksenok/colors/CW.css
//
// .option{
// display:none;
// /*border:solid 5px ##_5;*/
// position:absolute;
// /*background-color:##_5;*/
// }
// .sel{
// padding:2px;
// /*color:##P0;*/
// /*border:solid 1px ##_5;*/
// }
$schemes = array();
if ($handle = opendir('./')) {
while (false !== ($file = readdir($handle))) {
if (substr($file, -7) == ".scheme") {
$schemes[] = substr($file, 0, -7);
}
}
}
require_once("ColorScheme.php");
require_once("Args.php");
$dark = getearg("dark", array("f", "t"));
$txtdef = getearg("colors", $schemes) . ".scheme";
$css = getsarg("styles", null);
echo "/* Using " . $txtdef . " color scheme */\n\n";
$text = file_get_contents($css);
$text = explode("/*", $text);
$colors = new ColorScheme($txtdef, $dark == "t");
foreach ($text as $line) {
$line = explode("*/", $line);
$pos = strpos($line[0], "##");
if ($pos === false && $pos + 3 < strlen($line[0])) {
if (count($line) > 1)
echo "/*" . $line[0] . "*/" . $line[1];
else
echo $line[0];
}else {
$which = $line[0][$pos + 2];
$shade = $line[0][$pos + 3];
echo substr($line[0], 0, $pos) . $colors->hex($which, $shade) . substr($line[0], $pos + 4) . $line[1];
}
}