| 1 | package Geometry::Primitive::Rectangle; | ||
| 2 | 1 | ▶ | use Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | 1 | ▶ | use MooseX::Storage; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | |||
| 5 | 1 | ▶ | use Geometry::Primitive::Point; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | 1 | with qw(Geometry::Primitive::Shape MooseX::Clone MooseX::Storage::Deferred); | |
| 8 | |||
| 9 | 1 | has 'height' => ( | |
| 10 | is => 'rw', | ||
| 11 | isa => 'Num', | ||
| 12 | required => 1 | ||
| 13 | ); | ||
| 14 | 1 | has 'origin' => ( | |
| 15 | is => 'rw', | ||
| 16 | isa => 'Geometry::Primitive::Point', | ||
| 17 | coerce => 1 | ||
| 18 | ); | ||
| 19 | 1 | has 'width' => ( | |
| 20 | is => 'rw', | ||
| 21 | isa => 'Num', | ||
| 22 | required => 1 | ||
| 23 | ); | ||
| 24 | |||
| 25 | 0 | ▶ | sub area { |
|
Subroutine
area: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 26 | 0 | my ($self) = @_; | |
| 27 | |||
| 28 | 0 | return $self->height * $self->width; | |
| 29 | } | ||
| 30 | |||
| 31 | 0 | ▶ | sub get_points { |
|
Subroutine
get_points: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 32 | 0 | my ($self) = @_; | |
| 33 | |||
| 34 | 0 | my @points; | |
| 35 | 0 | push(@points, $self->origin); | |
| 36 | 0 | push(@points, Geometry::Primitive::Point->new( | |
| 37 | x => $self->origin->x + $self->width, y => $self->origin->y | ||
| 38 | )); | ||
| 39 | 0 | push(@points, Geometry::Primitive::Point->new( | |
| 40 | x => $self->origin->x, y => $self->origin->y + $self->height | ||
| 41 | )); | ||
| 42 | 0 | push(@points, Geometry::Primitive::Point->new( | |
| 43 | x => $self->origin->x + $self->width, y => $self->origin->y + $self->height | ||
| 44 | )); | ||
| 45 | return \@points | ||
| 46 | 0 | } | |
| 47 | |||
| 48 | 0 | ▶ | sub scale { |
|
Subroutine
scale: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 49 | 0 | my ($self, $amount) = @_; | |
| 50 | |||
| 51 | 0 | $self->width($self->width * $amount); | |
| 52 | 0 | $self->height($self->height * $amount); | |
| 53 | } | ||
| 54 | |||
| 55 | 0 | ▶ | sub point_end { |
|
Subroutine
point_end: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 56 | 0 | my ($self) = @_; return $self->origin; | |
| 57 | } | ||
| 58 | |||
| 59 | 0 | ▶ | sub point_start { |
|
Subroutine
point_start: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 60 | 0 | my ($self) = @_; return $self->origin; | |
| 61 | } | ||
| 62 | |||
| 63 | 1 | __PACKAGE__->meta->make_immutable; | |
| 64 | |||
| 65 | 1 | ▶ | no Moose; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 66 | 1 | 1; | |
| 67 | |||
| 68 | __END__ | ||