#!c:\perl\bin\perl ###### SET THESE CONSTANTS #remember : smaller=darker #set these variables below or uncomment one of the subroutines
open R, (">ref.css"); #stylesheet filename
$r_incr=0; # 1: red increasing, -1: decreasing, 0: const $g_incr=1; # 1: green increasing, -1: decreasing, 0: const $b_incr=1; # 1: blue increasing, -1: decreasing, 0: const $r_const='ff'; # value of the constant when the variables $r_incr is set to 0 $g_const='ff'; # ditto, for variable #g_incr $b_const='ff'; # again, but for variable #b_incr $text_light_to_dark=-1; # -1: text color starts light then gets dark; 1: start dark $text_dark="\#ff0000"; # value of the dark text color (don't cheat and put a light color :-) $text_ligh="\#ffffff"; # value of the light text color $text_switch = 156; # when to switch text color; 1: rightaway 256: never
#&red_to_white; #&black_to_white; #&blue_to_white;
######## DO NOT MODIFY BELOW
sub red_to_white { $r_incr=0; # 1: red increasing, -1: decreasing, 0: const $g_incr=1; # 1: green increasing, -1: decreasing, 0: const $b_incr=1; # 1: blue increasing, -1: decreasing, 0: const $r_const='ff'; # set these if you set any color to a constant $g_const='ff'; $b_const='ff'; $text_light_to_dark=-1; # -1: start light get dark 1: start dar $text_dark="\#ff0000"; $text_ligh="\#ffffff"; $text_switch = 156; # when switching text color 1 rightaway 256 never } sub black_to_white { $r_incr=1; # 1: red increasing, -1: decreasing, 0: const $g_incr=1; # 1: green increasing, -1: decreasing, 0: const $b_incr=1; # 1: blue increasing, -1: decreasing, 0: const $r_const='ff'; # set these if you set any color to a constant $g_const='ff'; $b_const='ff'; $text_light_to_dark=-1; # -1: start light get dark 1: start dar $text_dark="\#000000"; $text_ligh="\#ffffff"; $text_switch = 156; # when switching text color 1 rightaway 256 never } sub blue_to_white { $r_incr=1; # 1: red increasing, -1: decreasing, 0: const $g_incr=1; # 1: green increasing, -1: decreasing, 0: const $b_incr=0; # 1: blue increasing, -1: decreasing, 0: const $r_const='ff'; # set these if you set any color to a constant $g_const='ff'; $b_const='ff'; $text_light_to_dark=-1; # -1: start light get dark 1: start dar $text_dark="\#000000"; $text_ligh="\#ffffff"; $text_switch = 156; # when switching text color 1 rightaway 256 never }
if ($text_light_to_dark==-1) { $text_beg=$text_ligh; $text_end=$text_dark; } elsif ($text_light_to_dark==1) { $text_end=$text_ligh; $text_beg=$text_dark; }
sub double { my ($s)=@_; $new=sprintf "%x", $s; if (substr("$new",1,1) eq '') { return "0$new"; } return $new; }
for $var(0..255) { $r_var= ($r_incr==1) ? double($var) : ($r_incr==-1)? double(255-$var): $r_const; $g_var= ($g_incr==1) ? double($var): ($g_incr==-1)? double(255-$var): $g_const; $b_var= ($b_incr==1) ? double($var) : ($b_incr==-1)? double(255-$var): $b_const;
print R "\.ref$var { \n\tbackground :\#"; print R $r_var.$g_var.$b_var;
if ($var < $text_switch) { #154 a good value print R ";\n\tcolor:$text_beg;\n" . "}"; } else { print R ";\n\tcolor:$text_end;\n" . "}"; } print R "\n" }