The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Color::Fade - Perl extension for fading text colors.

SYNOPSIS

  use Color::Fade qw(color_fade format_html);

  print format_html (color_fade (
    'Jackdaws love my big sphynx of quartz.',
    '#FF0000', '#00FF00', '#0000FF',
  ));

DESCRIPTION

Color::Fade uses mathematical formulas to take an input string of virtually any length, and virtually any number of colors, and assign an individual color to each character to fade between each of the input colors.

In other words, it makes your sentences look really pretty. :)

EXPORT

Exports color_fade, format_html, format_css, format_ubb, and format_aim on demand.

METHODS

color_fade ($string, @colors)

Fade $string among the colors in @colors, where $string is a string of length greater than zero, and @colors is an array of colors in six byte hexadecimal format, with or without the leading octothorpe. @colors must have at least two elements.

When called in array context, the method returns an array in which each element is of the format:

  <color #xxxxxx>y

For each character, where xxxxxx is a hexadecimal color code and y is one character from the original string.

When called in scalar context, this array is joined before being returned.

Note: It is perfectly possible to have more colors than you have characters in the original string. All that will happen is that each character of output will have a color from the original array, in the order the array was passed in, until there are no characters left.

format_html (@codes)

Formats @codes in standard HTML, where @codes is an array returned from color_fade. Do not pass a scalar into this array; it won't run the way you expect it to.

Outputs a scalar of HTML source code in the format:

  <font color="#xxxxxx">y</font>

format_css (@codes)

For those of us who try to stay on the W3C's good side and be HTML 4.01 compliant, this method formats it in code that is HTML 4.01 compliant!

Outputs a scalar of HTML source code in the format:

  <span style="color: #xxxxxx">y</span>

format_ubb (@codes)

Since so many of us programmers are regular members of message boards, a function was included to format it for UBB code.

Outputs a scalar of UBB code in the format:

  [color=#xxxxxx]y[/color]

format_aim (@codes)

This special routine is to format the code for use on AOL Instant Messenger. It is the same as format_html, but it lacks any of the </font> tags (as these tend to close every open font tag, not just the most recently opened one).

Outputs a scalar in the format:

  <font color="#xxxxxx">y

SEE ALSO

Cuvou's Text Fader, an online implementation of this module. http://www.cuvou.com/wizards/fader.cgi

AUTHOR

Casey Kirsle, <casey at cuvou.net>

COPYRIGHT AND LICENSE

Copyright (C) 2007 by Casey Kirsle

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.8 or, at your option, any later version of Perl 5 you may have available.