Graphics::Color::YIQ - YIQ color space


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

Index


Code Index:

NAME

Top

Graphics::Color::YIQ - YIQ color space

DESCRIPTION

Top

Graphics::Color::YIQ represents a Color in an YIQ color space.

DISCLAIMER

Top

I couldn't find clear information on the bounds of each value, so at the moment there are none.

SYNOPSIS

Top

    use Graphics::Color::YIQ;

    my $color = Graphics::Color::YIQ->new({
        luminance   => 0.5,
        in_phase    => .5
        quadrature  => .25,
    });

CONSTRUCTOR

Top

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

Creates a new Graphics::Color::YIQ.

METHODS

Top

equal_to

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

not_equal_to

The opposite of equal_to.

luminance

y

Set/Get the luminance component of this Color.

in_phase

i

Set/Get the in_phase component of this Color.

quadrature

q

Set/Get the quadrature component of this Color.

name

Get the name of this color. Only valid if the color was created by name.

as_string

Get a string version of this Color in the form of LUMINANCE,IN-PHASE,QUADRATURE

as_array

Get the YIQ values as an array

AUTHOR

Top

Cory Watson, <gphat@cpan.org>

SEE ALSO

Top

perl(1), http://en.wikipedia.org/wiki/YIQ

COPYRIGHT & LICENSE

Top


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

package Graphics::Color::YIQ;
use Moose;
use MooseX::Aliases;

extends qw(Graphics::Color);

has 'luminance' => (
    is => 'rw',
    isa => 'Num',
    default => 1,
    alias => 'y'
);
has 'in_phase' => (
    is => 'rw',
    isa => 'Num',
    default => 1,
    alias => 'i'
);
has 'quadrature' => (
    is => 'rw',
    isa => 'Num',
    default => 1,
    alias => 'q'
);
has 'name' => ( is => 'rw', isa => 'Str' );

sub as_string {
    my ($self) = @_;

    return sprintf('%s,%s,%s',
        $self->luminance, $self->in_phase, $self->quadrature
    );
}

sub as_array {
    my ($self) = @_;

    return ($self->luminance, $self->in_phase, $self->quadrature);
}

__PACKAGE__->meta->make_immutable;

sub equal_to {
    my ($self, $other) = @_;

    return 0 unless defined($other);

    unless($self->luminance == $other->luminance) {
        return 0;
    }
    unless($self->in_phase == $other->in_phase) {
        return 0;
    }
    unless($self->quadrature == $other->quadrature) {
        return 0;
    }

    return 1;
}

no Moose;
1;
__END__