Graphics::Color - Device and library agnostic color spaces.


Graphics-Color documentation Contained in the Graphics-Color distribution.

Index


Code Index:

NAME

Top

Graphics::Color - Device and library agnostic color spaces.

SYNOPSIS

Top

Graphics color is a device and library agnostic system for creating and manipulating colors in various color spaces.

  my $color = Graphics::Color::RGB->new(
      red => .5, green => .5, blue => .5, alpha => .5
  );
  say $color->as_string;

DISCLAIMER

Top

I'm not an art student or a wizard of arcane color knowledge. I'm a normal programmer with a penchant for things graphical. Hence this module is likely incomplete in some places. Patches are encouraged. I've intentions of adding more color spaces as well as conversion routines (where applicable).

COLOR TYPES

Top

The following color types are supported.

CMYK

HSL

RGB

YIQ

YUV

CONSTRUCTOR

Top

Graphics::Color->new(%options);

Makes a new, useless Graphics::Color object. There's no reason to do this.

METHODS

Top

derive

Clone this color but allow one of more of it's attributes to change by passing in a hashref of options:

  my $new = $color->derive({ attr => $newvalue });

The returned color will be identical to the cloned one, save the attributes specified.

equal_to

Compares this color to the provided one. Returns 1 if true, else 0;

not_equal_to

The opposite of equal_to.

AUTHOR

Top

Cory G Watson, <gphat@cpan.org>

CONTRIBUTORS

Top

Guillermo Roditi, <groditi@gmail.com>

BUGS

Top

Please report any bugs or feature requests to bug-graphics-color at rt.cpan.org, or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Graphics-Color. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes.

COPYRIGHT & LICENSE

Top


Graphics-Color documentation Contained in the Graphics-Color distribution.

package Graphics::Color;
use Moose;
use Moose::Util::TypeConstraints;

with qw(MooseX::Clone Graphics::Color::Equal MooseX::Storage::Deferred);

our $AUTHORITY = 'cpan:GPHAT';
our $VERSION = '0.28';

sub derive {
    my ($self, $args) = @_;

    return unless ref($args) eq 'HASH';
    my $new = $self->clone;
    foreach my $key (keys %{ $args }) {
        $new->$key($args->{$key}) if($new->can($key));
    }
    return $new;
}

sub equal_to {
    die("Override me!");
}

__PACKAGE__->meta->make_immutable;

no Moose;
1;
__END__