| 1 | use Renard::Incunabula::Common::Setup; | ||
| 2 | package Intertangle::Taffeta::Color::RGB24; | ||
| 3 | # ABSTRACT: A 24-bit RGB colour | ||
| 4 | $Intertangle::Taffeta::Color::RGB24::VERSION = '0.001'; | ||
| 5 | use Mu; | ||
| 6 | use Intertangle::Taffeta::Types qw(RGB24Value RGB24Component); | ||
| 7 | |||
| 8 | extends qw(Intertangle::Taffeta::Color); | ||
| 9 | |||
| 10 | has value => ( | ||
| 11 | is => 'ro', | ||
| 12 | isa => RGB24Value, | ||
| 13 | ); | ||
| 14 | |||
| 15 | around BUILDARGS => fun( $orig, $class, %args ) { | ||
| 16 | if( exists $args{r8} && exists $args{g8} && exists $args{b8} ) { | ||
| 17 | RGB24Component->assert_valid($args{r8}); | ||
| 18 | RGB24Component->assert_valid($args{g8}); | ||
| 19 | RGB24Component->assert_valid($args{b8}); | ||
| 20 | |||
| 21 | $args{value} = ( (delete $args{r8}) << 16 ) | ||
| 22 | + ( (delete $args{g8}) << 8 ) | ||
| 23 | + ( delete $args{b8} ); | ||
| 24 | } | ||
| 25 | |||
| 26 | return $class->$orig(%args); | ||
| 27 | }; | ||
| 28 | |||
| 29 | with qw(Intertangle::Taffeta::Color::Role::SVG Intertangle::Taffeta::Color::Role::RGB24Components); | ||
| 30 | |||
| 31 | 1; | ||
| 32 | |||
| 33 | __END__ |