Sometime you see people use colorful screen names in chat rooms, and this piece of code can be used to decorate your screen name or other strings. Here are some samples:
This string is decorateduse strict; use warnings; print decorate("This string is decorated", [255,125,125], [255,255,0], + 2); print "<br>"; print decorate("This string is decorated", [125,0,255], [0,255,0], 2); + print "<br>"; sub decorate { my ($str, $left, $right, $size) = @_; my @step; $step[$_] = ($right->[$_] - $left->[$_]) / (length($str) - 1) for +(0 .. 2); my @chars = split //, $str; foreach (0 .. $#chars) { $chars[$_] = sprintf("<font size=%d color=#%02x%02x%02x>$chars +[$_]</font>", $size, $left->[0] + $_ * $step[0], $left->[1] + $_ * $s +tep[1], $left->[2] + $_ * $step[2]); } return join("", @chars); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: decorated string
by cleverett (Friar) on Nov 17, 2003 at 06:00 UTC | |
by pg (Canon) on Nov 17, 2003 at 06:39 UTC | |
by Aristotle (Chancellor) on Nov 22, 2003 at 08:32 UTC | |
by synistar (Pilgrim) on Nov 17, 2003 at 14:29 UTC |