NAME

Term::ANSIColor::Gradients::Utils - color conversion and contrast utilities

SYNOPSIS

use Term::ANSIColor::Gradients::Utils qw(build_contrast intensity_shift) ;

my $contrast_idx  = build_contrast(196) ;   # complement of bright red
my $darker_idx    = intensity_shift(196, -4) ;

DESCRIPTION

Internal utility module providing ANSI 256-color index conversions and the algorithms used by the gradient data modules and CLI tool.

build_contrast($ansi_index)

Returns the ANSI 256-color index whose hue is complementary (180 degree hue rotation) to the input color, with luminance adjusted to ensure readability. For near-grey input (saturation < 0.15) a luminance flip is used instead.

intensity_shift($ansi_index, $delta)

Returns a new ANSI index representing the same hue and saturation as the input but with brightness (HSV value) shifted by $delta * 0.05. Positive values lighten, negative values darken. Result is clamped to [0, 1] before the nearest-ANSI search.

AUTHOR

Nadim Khemir <nadim.khemir@gmail.com>

LICENSE

This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself (Artistic License 2.0 or GPL 3.0).