Data::Faker::Colour - Generate random colours
use Data::Faker::Colour; local $, = ' '; my $f = Data::Faker::Colour->new; say 'Random colour: ', $f->colour_hex; say 'Three random colours of 60% lightness: ', $f->colour_hsluv_hex(3, -1, -1, 60); say 'A colour with 70% saturation, in CSS format: ', $f->colour_hsluv_css(1, -1, 70); say '5 colours with hue 120 and lightness 45%: ', $f->colour_hsluv_hex(5, 150, -1, 45);
This module is a plugin for Data::Faker for generating random colours. It uses the HSLuv colour space to permit generation of colours with specific hue, saturation, or lightness values. One use case would be generating colour schemes.
It is recommended to use this without Data::Faker, as Data::Faker does not currently pass arguments to methods.
Generate $cnt (default 1) random colours. Returns a list of 3-element arrayrefs, representing the R, G, and B components, each ranging 0-255.
As above, but returns a list of strings like #rrggbb.
#rrggbb
As above, but returns a list of strings like rgb(r, g, b).
rgb(r, g, b)
Generates $cnt (default 1) random colours using the HSLuv colour space. You can specify your desired hue, saturation and/or lightness, and all generated colours will have that hue/saturation/lightness.
Set $H, $S, $L to a positive value to request a specific hue/saturation/lightness, or to -1 for a randomly chosen one. They all default to -1.
As above but with hex/css output.
color can be substituted for colour in any of the methods above.
color
colour
Data::Faker, Convert::Colour, Convert::Colour::HSLuv
Marius Gavrilescu, <marius@ieval.ro>
Copyright (C) 2017 by Marius Gavrilescu
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.24.1 or, at your option, any later version of Perl 5 you may have available.
To install Data::Faker::Colour, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Data::Faker::Colour
CPAN shell
perl -MCPAN -e shell install Data::Faker::Colour
For more information on module installation, please visit the detailed CPAN module installation guide.