| 1 | use Renard::Incunabula::Common::Setup; | ||
| 2 | package Intertangle::Taffeta::Style::Fill; | ||
| 3 | # ABSTRACT: Fill style | ||
| 4 | $Intertangle::Taffeta::Style::Fill::VERSION = '0.001'; | ||
| 5 | use Moo; | ||
| 6 | use Renard::Incunabula::Common::Types qw(Bool); | ||
| 7 | use Intertangle::Taffeta::Types qw(Color Opacity Dimension); | ||
| 8 | |||
| 9 | has opacity => ( | ||
| 10 | is => 'ro', | ||
| 11 | predicate => 1, | ||
| 12 | default => sub { 1 }, | ||
| 13 | isa => Opacity, | ||
| 14 | ); | ||
| 15 | |||
| 16 | has color => ( | ||
| 17 | is => 'ro', | ||
| 18 | predicate => 1, | ||
| 19 | isa => Color, | ||
| 20 | ); | ||
| 21 | |||
| 22 | method is_fill_none() :ReturnType(Bool) { | ||
| 23 | return ! $self->has_color && ! $self->has_opacity; | ||
| 24 | } | ||
| 25 | |||
| 26 | method svg_style() { | ||
| 27 | my $data = {}; | ||
| 28 | |||
| 29 | if( $self->is_fill_none ) { | ||
| 30 | $data->{fill} = 'none'; | ||
| 31 | } elsif( $self->has_color ) { | ||
| 32 | $data->{fill} = $self->color->svg_value; | ||
| 33 | } | ||
| 34 | |||
| 35 | if( $self->has_opacity ) { | ||
| 36 | $data->{'fill-opacity'} = $self->opacity; | ||
| 37 | } | ||
| 38 | |||
| 39 | $data; | ||
| 40 | } | ||
| 41 | |||
| 42 | 1; | ||
| 43 | |||
| 44 | __END__ |