- Joined
- Oct 22, 2001
- Location
- Buffalo, NY
how do I add color to my score?
Can you post up your code to turn your WUs yellow like that?
Can you post up your code to turn your WUs yellow like that?
Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!
Christoph said:*This is mainly an excuse to link to something in the folding forum from the seti forum. I don't plan on defecting.
print "Work Units:[co lor=yellow]$wus". "[/color]\n";
print "[CO LOR=Orange][SI ZE=1][FO NT=Courier New]Orange Size 1 Courier New[/FONT][/SIZE][/COLOR]";
####################################[b][/b]###########################################
#color_string:
#This function returns its third argument (a string) with color tags, as
#specified by its other parameters.
#
#Usage: color_string($rgb_i, $rgb_f, $string, $err, $pds, $fun)
#$rgb_i : hex triplet (eg "ff00ff") indicating the color to start with
#$rgb_f : hex triplet indicating the color to stop with
#$string : the string to add color tags to
#
#All arguments below are optional, but you can't use one without using the ones
#before it. eg you need to specify $err and $pds in order to specify $fun.
#
#$err : 0-255 - add/subtract random fluctuations between 0 and $err to each
# color. The colors will always be valid, even if $err is large.
#$periods : how many times to cycle from $rgb_i to $rgb_f
#$fun : specify the function used to move between $rgb_i and $rgb_f
#
#Examples of valid usage:
#
#$pi = atan2(1,1)*4; #standard definition
#$str = color_string("ff00ff", "ffff00", "Like, wow.");
#$str = color_string("ff00ff", "ffff00", "Like, wow.", 15);
#$str = color_string("ff00ff", "ffff00", "Like, wow.", 15, 2);
#$str = color_string("ff00ff", "ffff00", "Like, wow.", 15, 2,
# sub {my $x = shift; return abs(sin($x*$pi))} );
###########################################[b][/b]####################################
sub color_string
{
$start_rgb = shift;
$end_rgb = shift;
$string = shift;
#optional args below
$error = shift;
$error = 0 if (! defined $error);
$periods = shift;
$periods = 1 if (! defined $periods);
$fun = shift;
$fun = sub {my $x = shift; return ((255*$x % 256)/255);} if (!defined $fun);
#ugly bug if this isn't declared my
my $color_str;
$str_len = length $string;
$i=0;
foreach $char (split //, $string) {
$fstr_color=color_grad($start_rgb,$end_rgb,$s[b][/b]tr_len,$i++,$error,$periods,$fun);
#vb3 seems to treat individually colored spaces an non-printable
if ($char eq " ") {
$color_str .= "\[color\=\#$invisible\].\[/color\]";
} else {
$color_str .= "\[color\=\#$fstr_color\]$char\[/color\]";
}
}
#print "COLOR STRING: returning $color_str\n";
return $color_str;
}
##########################################[b][/b]#####################################
#color_grad_fun:
#This function returns a single hex triplet based on the parameters passed to
#it.
#
#Usage: color_grad_fun($rgb_i, $rgb_f, $curr, $err, $pds, $fun)
#$rgb_i : hex triplet (eg "ff00ff") indicating the color to start with
#$rgb_f : hex triplet indicating the color to stop with
#$curr : a number between 0 and 1 indicating how far through the gradient
# the color is.
#
#All arguments below are optional, but you can't use one without using the ones
#before it. eg you need to specify $err and $pds in order to specify $fun.
#
#$err : 0-255 - add/subtract random fluctuations between 0 and $err to each
# eg you need to specify $err and $pds in order to specify $fun.
#
#$err : 0-255 - add/subtract random fluctuations between 0 and $err to each
# color. The colors will always be valid, even if $err is large.
#$periods : how many times to cycle from $rgb_i to $rgb_f
#$fun : specify the function used to move between $rgb_i and $rgb_f
# Default: 0
#$periods : how many times to cycle from $rgb_i to $rgb_f
# Default: 1
#$fun : specify the function used to move between $rgb_i and $rgb_f
# Default: constant increase
##########################################[b][/b]#####################################
sub color_grad_fun
{
my $start_rgb = shift; #"ff00ff"
my $end_rgb = shift; #"00ff00"
my $curr_step = shift; #floating pt number between 0 and 1. inclusive
#OPTIONAL ARG: error is random variation, in decimal shades
my $error = shift;
$error = 0 if (! defined $error);
#OPTIONAL ARG: how many times to cycle through the above function
my $periods = shift;
$periods = 1 if (! defined $periods);
#OPTIONAL ARG: function with a period of 1 and a range 0-1 to determine color distribution
my $fun = shift;
#This function has the same behavior as the previous implementation.
$fun = sub {my $x = shift; return ((255*$x % 255)/255);} if (!defined $fun);
$error /= 255;
for $curr (0,1,2) {
$min = hex(substr($start_rgb,$curr*2,2)) / 255;
$max = hex(substr($end_rgb,$curr*2,2)) / 255;
$range = $max - $min;
$funval = &$fun($curr_step*$periods);
#print "max is $max, min is $min, range is $range, step is $curr_step,";
$color[$curr] = ($min + $range*$funval);
if ($error == 0) {
$my_error = 0;
} else {
$my_error = (rand 2*$error) - $error;
}
while (($color[$curr]+$my_error) < 0 || ($color[$curr]+$my_error) > 1) {
$my_error = ((rand 2*$error) - $error);
}
#at this point, $my
#print "using error of $my_error, max is $error\n";
#$norml = $color[$curr]*255;
#print "normal color is $norml, ";
$color[$curr] += $my_error;
$color[$curr] *= 255;
#$color[$curr] = sprintf("%.0f",)
#print "color is $color[$curr]\n";
}
return sprintf("%02x%02x%02x",$color[0],$color[1],$color[2]);
}
#########################################[b][/b]######################################
#color_grad:
#This function returns a single hex triplet based on the parameters passed to
#it. This function is just a wrapper for color_grad_fun. Either can be used.
#
#Usage: color_grad($rgb_i, $rgb_f, $step_f, $step_c, $err, $pds, $fun)
#$rgb_i : hex triplet (eg "ff00ff") indicating the color to start with
#$rgb_f : hex triplet indicating the color to stop with
#$step_f : how many total steps in the gradient (ie step_final)
#$step_c : the number of the current step; if this is half of step_f, the color
# returned will be halfway between rgb_i and rgb_f
#All arguments below are optional, but you can't use one without using the ones
#before it. eg you need to specify $err and $pds in order to specify $fun.
#
#$err : 0-255 - add/subtract random fluctuations between 0 and $err to each
# color. The colors will always be valid, even if $err is large.
#$periods : how many times to cycle from $rgb_i to $rgb_f
#$fun : specify the function used to move between $rgb_i and $rgb_f
#########################################[b][/b]######################################
sub color_grad
{
$start_rgb = shift; #"ff00ff"
$end_rgb = shift; #"00ff00"
$last_step = shift; #"36"
$curr_step = shift; #"12"
#error is random variation, in decimal shades
$error = shift;
$periods = shift;
$fun = shift;
return color_grad_fun($start_rgb,$end_rgb,$curr_step/$last_step,$error,$periods,$fun);
}
JerMe said:I'm no programmer...
Christoph said:You lie!
$file_pic = 'C:\\mksig\\dnacolor.txt';
open(INFO, $file_pic);
@lines = <INFO>;
chop(@lines);
close(INFO);