| 1 | use Renard::Incunabula::Common::Setup; | ||
| 2 | package Intertangle::Taffeta::Color::Role::RGB24Components; | ||
| 3 | # ABSTRACT: RGB component colour role | ||
| 4 | $Intertangle::Taffeta::Color::Role::RGB24Components::VERSION = '0.001'; | ||
| 5 | use Moo::Role; | ||
| 6 | use MooX::ShortHas; | ||
| 7 | use namespace::autoclean; | ||
| 8 | use Intertangle::Taffeta::Types qw(RGB24Value RGB24Component); | ||
| 9 | |||
| 10 | requires 'value'; | ||
| 11 | |||
| 12 | lazy r8 => method() { ($self->value & 0xFF0000) >> 16; }, isa => RGB24Component; | ||
| 13 | |||
| 14 | lazy g8 => method() { ($self->value & 0x00FF00) >> 8; }, isa => RGB24Component; | ||
| 15 | |||
| 16 | lazy b8 => method() { ($self->value & 0x0000FF) >> 0; }, isa => RGB24Component; | ||
| 17 | |||
| 18 | method rgb_float_triple() { | ||
| 19 | ($self->r8 / 0xFF, $self->g8 / 0xFF, $self->b8 / 0xFF ); | ||
| 20 | } | ||
| 21 | |||
| 22 | 1; | ||
| 23 | |||
| 24 | __END__ |