Mail::SpamAssassin::HTML::Color(3pm)

Mail::SpamAssassin::HTML::Color3pm

A class to parse and manipulate css color values

Usage

  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

Overview

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.

From spamassassin 4.0.2-3 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.