table of contents
- experimental 4.0.1+svn1923525-1
Mail::SpamAssassin::HTML::Color(3pm) | User Contributed Perl Documentation | Mail::SpamAssassin::HTML::Color(3pm) |
NAME¶
Mail::SpamAssassin::HTML::Color - A class to parse and manipulate CSS color values
SYNOPSIS¶
use Mail::SpamAssassin::HTML::Color; my $color = Mail::SpamAssassin::HTML::Color->new('rgba(255, 0, 153, 0.5)'); $color->blend([255, 255, 255]); my $distance = $color->distance([0, 0, 0]); print "$color"; # Outputs the color as a hex string
DESCRIPTION¶
This class provides methods to parse various CSS color formats, blend them with a background color, calculate the distance between two colors, and convert the color to a hex string.
METHODS¶
new($color)¶
Creates a new color object from a CSS color string.
blend($background)¶
Blends the color with the given background color. Modifies the color in-place and returns the modified object.
distance($other_color)¶
Calculates the distance between the current color and another color using a brightness-weighted geometric formula.
as_hex¶
Returns the color as a hex string with a leading '#'.
as_array¶
Returns the color as an array of RGB values.
2025-02-03 | perl v5.40.0 |