Colouring-In-XS
view release on metacpan or search on metacpan
lib/Colouring/In/XS.pm view on Meta::CPAN
$black->toRGB # rgb(0,0,0)
$black->toRGBA # rgba(0,0,0,1)
$black->toHSL # hsl(0,0%,0%)
$black->toHSV # hsv(0,0%,0%)
$black->toTerm # r0g0b0
$black->toOnTerm # on_r0g0b0
my $white = $black->lighten('100%');
my $black = $white->darken('100%');
my $transparent = $black->fadeout('100%');
$black = $transparent->fadein('100%');
...
use Colouring::In::XS qw/lighten darken/;
my $white = lighten('#000', '100%');
my $black = darken('#fff', '100%');
my $transparent = fade('#fff', '0%');
my $transparent = fadeout('#fff', '100%');
my $colour = fadein('rgba(125,125,125,0'), '100%');
=head1 Instantiate
=cut
=head2 new
Instantiate an Colouring::In::XS Object using a supported colour formated string or RGBA array reference.
lib/Colouring/In/XS.pm view on Meta::CPAN
=head2 rgb
Instantiate an Colouring::In::XS Object opaque colour from decimal red, green and blue (RGB) values.
my $colour = Colouring::In::XS->rgb(0, 0, 0);
=cut
=head2 rgba
Instantiate an Colouring::In::XS Object transparent colour from decimal red, green, blue and alpha (RGBA) values.
my $colour = Colouring::In::XS->rgb(0, 0, 0, 0.5);
=cut
=head2 hsl
Instantiate an Colouring::In::XS Object opaque colour from hue, saturation and lightness (HSL) values.
my $colour = Colouring::In::XS->hsl(0, 0%, 100%);
lib/Colouring/In/XS.pm view on Meta::CPAN
=head2 toRGB
Returns an opaque colour string from decimal red, green and blue (RGB) values.
my $string = $colour->toCSS;
=cut
=head2 toRGBA
Returns an transparent colour string from decimal red, green, blue and alpha (RGBA) values.
my $string = $colour->toRGBA;
=cut
=head2 toHEX
Returns an opaque colour string from decimal red, green and blue (RGB) values.
my $string = $colour->toHEX;
t/07-white-black.t view on Meta::CPAN
use Test::More;
use Colouring::In::XS;
my $white = Colouring::In::XS->new('#ffffff');
my $black = $white->darken('100%');
is($black->toCSS, '#000');
$white = $black->lighten('100%');
is($white->toCSS, '#fff');
my $transparent = $white->fadeout('100%');
is($transparent->toCSS, 'rgba(255,255,255,0)');
$white = $transparent->fadein('100%');
is($white->toCSS, '#fff');
done_testing();
( run in 0.457 second using v1.01-cache-2.11-cpan-0a6323c29d9 )