| 1 | package Geometry::Primitive::Ellipse; | ||
| 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 | 1 | ▶ | use Moose::Util::TypeConstraints; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | ▶ | use Geometry::Primitive::Point; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use Math::Trig ':pi'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 1 | with qw(Geometry::Primitive::Shape MooseX::Clone MooseX::Storage::Deferred); | |
| 10 | |||
| 11 | 1 | subtype 'My::Geometry::Primitive::Point' => as class_type('Geometry::Primitive::Point'); | |
| 12 | |||
| 13 | coerce 'My::Geometry::Primitive::Point' | ||
| 14 | => from 'ArrayRef' | ||
| 15 | 1 | ▶ | => via { Geometry::Primitive::Point->new(x => $_->[0], y => $_->[1]) }; |
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||
| 16 | |||
| 17 | |||
| 18 | 1 | has 'height' => ( | |
| 19 | is => 'rw', | ||
| 20 | isa => 'Num', | ||
| 21 | default => 0 | ||
| 22 | ); | ||
| 23 | 1 | has 'origin' => ( | |
| 24 | is => 'rw', | ||
| 25 | isa => 'My::Geometry::Primitive::Point', | ||
| 26 | coerce => 1 | ||
| 27 | ); | ||
| 28 | 1 | has 'width' => ( | |
| 29 | is => 'rw', | ||
| 30 | isa => 'Num', | ||
| 31 | default => 0 | ||
| 32 | ); | ||
| 33 | |||
| 34 | 1 | ▶ | sub area { |
|
Subroutine
area: called CC=1 SCAR=0.0
Pod
documented
| |||
| 35 | 1 | my ($self) = @_; | |
| 36 | 1 | return (pi * $self->width * $self->height) / 4; | |
| 37 | }; | ||
| 38 | |||
| 39 | 0 | ▶ | sub point_end { |
|
Subroutine
point_end: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 40 | 0 | my ($self) = @_; | |
| 41 | |||
| 42 | 0 | return $self->point_start; | |
| 43 | } | ||
| 44 | |||
| 45 | 0 | ▶ | sub point_start { |
|
Subroutine
point_start: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 46 | 0 | my ($self) = @_; | |
| 47 | |||
| 48 | 0 | return Geometry::Primitive::Point->new( | |
| 49 | x => $self->origin->x, | ||
| 50 | y => $self->origin->y - ($self->height / 2) | ||
| 51 | ); | ||
| 52 | } | ||
| 53 | |||
| 54 | 0 | ▶ | sub scale { |
|
Subroutine
scale: not called CC=1 SCAR=6.9
Pod
documented
| |||
| 55 | 0 | my ($self, $amount) = @_; | |
| 56 | |||
| 57 | 0 | return Geometry::Primitive::Ellipse->new( | |
| 58 | height => $self->height * $amount, | ||
| 59 | width => $self->width * $amount | ||
| 60 | ); | ||
| 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__ | ||