| 1 | use Renard::Incunabula::Common::Setup; | ||
| 2 | package Intertangle::Taffeta::Graphics::Role::WithBounds; | ||
| 3 | # ABSTRACT: A role for the bounds of a graphic object | ||
| 4 | $Intertangle::Taffeta::Graphics::Role::WithBounds::VERSION = '0.001'; | ||
| 5 | use Moo::Role; | ||
| 6 | use Intertangle::Yarn::Graphene; | ||
| 7 | |||
| 8 | use Renard::Incunabula::Common::Types qw(InstanceOf); | ||
| 9 | use Intertangle::Yarn::Types qw(Point Size); | ||
| 10 | |||
| 11 | has identity_bounds => ( | ||
| 12 | is => 'lazy', # _build_identity_bounds | ||
| 13 | isa => InstanceOf['Intertangle::Yarn::Graphene::Rect'], | ||
| 14 | ); | ||
| 15 | |||
| 16 | method _build_identity_bounds() { | ||
| 17 | Intertangle::Yarn::Graphene::Rect->new( | ||
| 18 | origin => $self->origin, | ||
| 19 | size => $self->size, | ||
| 20 | ); | ||
| 21 | } | ||
| 22 | |||
| 23 | has origin => ( | ||
| 24 | is => 'ro', | ||
| 25 | isa => Point, | ||
| 26 | coerce => 1, | ||
| 27 | default => sub { Intertangle::Yarn::Graphene::Point->new( x => 0, y => 0 ) }, | ||
| 28 | ); | ||
| 29 | |||
| 30 | has size => ( | ||
| 31 | is => 'lazy', # _build_size | ||
| 32 | isa => Size, | ||
| 33 | ); | ||
| 34 | |||
| 35 | 1; | ||
| 36 | |||
| 37 | __END__ |