| 1 | package Graphics::Color::YUV; | ||||||||||
| 2 | 1 | $Graphics::Color::YUV::VERSION = '0.31'; | |||||||||
| 3 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use MooseX::Aliases; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | 1 | extends qw(Graphics::Color); | |||||||||
| 7 | |||||||||||
| 8 | # ABSTRACT: YUV color space | ||||||||||
| 9 | |||||||||||
| 10 | 1 | ▶ | use Graphics::Color::Types qw(NumberOneOrLess); | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | |||||||||||
| 13 | 1 | has 'luma' => ( | |||||||||
| 14 | is => 'rw', | ||||||||||
| 15 | isa => NumberOneOrLess, | ||||||||||
| 16 | default => 0, | ||||||||||
| 17 | alias => 'y' | ||||||||||
| 18 | ); | ||||||||||
| 19 | |||||||||||
| 20 | |||||||||||
| 21 | 1 | has 'blue_luminance' => ( | |||||||||
| 22 | is => 'rw', | ||||||||||
| 23 | isa => NumberOneOrLess, | ||||||||||
| 24 | default => 0, | ||||||||||
| 25 | alias => 'u' | ||||||||||
| 26 | ); | ||||||||||
| 27 | |||||||||||
| 28 | |||||||||||
| 29 | 1 | has 'red_luminance' => ( | |||||||||
| 30 | is => 'rw', | ||||||||||
| 31 | isa => NumberOneOrLess, | ||||||||||
| 32 | default => 0, | ||||||||||
| 33 | alias => 'v' | ||||||||||
| 34 | ); | ||||||||||
| 35 | |||||||||||
| 36 | |||||||||||
| 37 | 1 | has 'name' => ( is => 'rw', isa => 'Str' ); | |||||||||
| 38 | |||||||||||
| 39 | |||||||||||
| 40 | 1 | ▶ | sub as_string { | ||||||||
|
Subroutine
as_string: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 41 | 1 | my ($self) = @_; | |||||||||
| 42 | |||||||||||
| 43 | 1 | return sprintf('%s,%s,%s', | |||||||||
| 44 | $self->luma, $self->blue_luminance, $self->red_luminance | ||||||||||
| 45 | ); | ||||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | |||||||||||
| 49 | 1 | ▶ | sub as_array { | ||||||||
|
Subroutine
as_array: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||
| 50 | 1 | my ($self) = @_; | |||||||||
| 51 | |||||||||||
| 52 | 1 | return ($self->luma, $self->blue_luminance, $self->red_luminance); | |||||||||
| 53 | } | ||||||||||
| 54 | |||||||||||
| 55 | |||||||||||
| 56 | 2 | ▶ | sub equal_to { | ||||||||
|
Subroutine
equal_to: called CC=5 SCAR=17.3
Pod
documented
| |||||||||||
| 57 | 2 | my ($self, $other) = @_; | |||||||||
| 58 | |||||||||||
| 59 | 2 | ▶ | return 0 unless defined($other); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 60 | |||||||||||
| 61 | 2 | ▶ | unless($self->luma == $other->luma) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 62 | 1 | return 0; | |||||||||
| 63 | } | ||||||||||
| 64 | 1 | ▶ | unless($self->blue_luminance == $other->blue_luminance) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 65 | 0 | return 0; | |||||||||
| 66 | } | ||||||||||
| 67 | 1 | ▶ | unless($self->red_luminance == $other->red_luminance) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 68 | 0 | return 0; | |||||||||
| 69 | } | ||||||||||
| 70 | |||||||||||
| 71 | 1 | return 1; | |||||||||
| 72 | } | ||||||||||
| 73 | |||||||||||
| 74 | |||||||||||
| 75 | # TODO RGB Conversion | ||||||||||
| 76 | # OLD STYLE : Y' = 0.299R + 0.587G + 0.114B | ||||||||||
| 77 | # NEW STYLE: Y' = 0.2125R + 0.7154G + 0.0721B | ||||||||||
| 78 | # U = B - Y' | ||||||||||
| 79 | # V = R - Y' | ||||||||||
| 80 | # | ||||||||||
| 81 | # http://www.fourcc.org/fccyvrgb.php | ||||||||||
| 82 | |||||||||||
| 83 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 84 | |||||||||||
| 85 | 1 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 86 | 1 | 1; | |||||||||
| 87 | |||||||||||
| 88 | __END__ | ||||||||||