View on
MetaCPAN is shutting down
For details read Perl NOC. After June 25th this page will redirect to
Noah Petherbridge > Color-Fade-0.01 > Color::Fade



Annotate this POD

View/Report Bugs
Module Version: 0.01b   Source   Latest Release: Color-Fade-0.02


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


  use Color::Fade qw(color_fade format_html);

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


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. :)


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


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:


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


Cuvou's Text Fader, an online implementation of this module.


Casey Kirsle, <casey at>


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.

syntax highlighting: