| Graphics-Color documentation | Contained in the Graphics-Color distribution. |
Graphics::Color::YUV - YUV color space
Graphics::Color::YUV represents a Color in an Y'UV color space.
use Graphics::Color::YUV;
my $color = Graphics::Color::YUV->new({
luma => .5,
blue_luminance => .5
red_luminance => .25,
});
Creates a new Graphics::Color::YUV.
Compares this color to the provided one. Returns 1 if true, else 0;
The opposite of equal_to.
Set/Get the luma (Y') component of this Color. Aliased to y.
Set/Get the blue_luminance component of this Color. Aliased to u.
Set/Get the red_luminance component of this Color. Aliased to v.
Get the name of this color. Only valid if the color was created by name.
Get a string version of this Color in the form of LUMA,BLUE_LUMINENCE,RED_LUMINANCE
Get the YUV values as an array
Cory Watson, <gphat@cpan.org>
perl(1), http://en.wikipedia.org/wiki/YUV
Copyright 2008 - 2009 by Cory G Watson
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| Graphics-Color documentation | Contained in the Graphics-Color distribution. |
package Graphics::Color::YUV; use Moose; use MooseX::Aliases; extends qw(Graphics::Color); use Graphics::Color::Types qw(NumberOneOrLess); has 'luma' => ( is => 'rw', isa => NumberOneOrLess, default => 0, alias => 'y' ); has 'blue_luminance' => ( is => 'rw', isa => NumberOneOrLess, default => 0, alias => 'u' ); has 'red_luminance' => ( is => 'rw', isa => NumberOneOrLess, default => 0, alias => 'v' ); has 'name' => ( is => 'rw', isa => 'Str' ); sub as_string { my ($self) = @_; return sprintf('%s,%s,%s', $self->luma, $self->blue_luminance, $self->red_luminance ); } sub as_array { my ($self) = @_; return ($self->luma, $self->blue_luminance, $self->red_luminance); } sub equal_to { my ($self, $other) = @_; return 0 unless defined($other); unless($self->luma == $other->luma) { return 0; } unless($self->blue_luminance == $other->blue_luminance) { return 0; } unless($self->red_luminance == $other->red_luminance) { return 0; } return 1; } # TODO RGB Conversion # OLD STYLE : Y' = 0.299R + 0.587G + 0.114B # NEW STYLE: Y' = 0.2125R + 0.7154G + 0.0721B # U = B - Y' # V = R - Y' # # http://www.fourcc.org/fccyvrgb.php __PACKAGE__->meta->make_immutable; no Moose; 1; __END__