| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Geometry::Primitive::Circle; |
|
2
|
1
|
|
|
1
|
|
32176
|
use Moose; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use MooseX::Storage; |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
with qw(Geometry::Primitive::Shape MooseX::Clone MooseX::Storage::Deferred); |
|
6
|
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use Geometry::Primitive::Point; |
|
8
|
|
|
|
|
|
|
use Math::Trig ':pi'; |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'origin' => ( |
|
11
|
|
|
|
|
|
|
is => 'rw', |
|
12
|
|
|
|
|
|
|
isa => 'Geometry::Primitive::Point', |
|
13
|
|
|
|
|
|
|
coerce => 1 |
|
14
|
|
|
|
|
|
|
); |
|
15
|
|
|
|
|
|
|
has 'radius' => ( |
|
16
|
|
|
|
|
|
|
is => 'rw', |
|
17
|
|
|
|
|
|
|
isa => 'Num', |
|
18
|
|
|
|
|
|
|
default => 0 |
|
19
|
|
|
|
|
|
|
); |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
sub area { |
|
22
|
|
|
|
|
|
|
my ($self) = @_; |
|
23
|
|
|
|
|
|
|
return $self->radius**2 * pi; |
|
24
|
|
|
|
|
|
|
}; |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub circumference { |
|
27
|
|
|
|
|
|
|
my ($self) = @_; |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
return $self->diameter * pi; |
|
30
|
|
|
|
|
|
|
} |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub diameter { |
|
33
|
|
|
|
|
|
|
my ($self) = @_; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
return $self->radius * 2; |
|
36
|
|
|
|
|
|
|
} |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub point_end { |
|
39
|
|
|
|
|
|
|
my ($self) = @_; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
return $self->point_start; |
|
42
|
|
|
|
|
|
|
} |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub point_start { |
|
45
|
|
|
|
|
|
|
my ($self) = @_; |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
return Geometry::Primitive::Point->new( |
|
48
|
|
|
|
|
|
|
x => $self->origin->x, |
|
49
|
|
|
|
|
|
|
y => $self->origin->y - ($self->radius / 2) |
|
50
|
|
|
|
|
|
|
); |
|
51
|
|
|
|
|
|
|
} |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
sub scale { |
|
54
|
|
|
|
|
|
|
my ($self, $amount) = @_; |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
return Geometry::Primitive::Circle->new( |
|
57
|
|
|
|
|
|
|
radius => $self->radius * $amount |
|
58
|
|
|
|
|
|
|
); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
no Moose; |
|
64
|
|
|
|
|
|
|
1; |
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
__END__ |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head1 NAME |
|
69
|
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
Geometry::Primitive::Circle - A Circle |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
Geometry::Primitive::Circle represents an ellipse with equal width and height. |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
use Geometry::Primitive::Circle; |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
my $circle = Geometry::Primitive::Circle->new( |
|
81
|
|
|
|
|
|
|
radius => 15 |
|
82
|
|
|
|
|
|
|
); |
|
83
|
|
|
|
|
|
|
print $circle->diameter; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head2 origin |
|
88
|
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Set/Get the origin of this circle. |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head2 radius |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
Set/Get the radius of this circle. |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 METHODS |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 new |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Creates a new Geometry::Primitive::Circle |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head2 area |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
Returns the area of this circle. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head2 circumference |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
Returns the circumference of this circle. |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=head2 diameter |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
Returns the diameter of this circle |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head2 scale ($amount) |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Returns a new circle whose radius is $amount times bigger than this one. |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 point_end |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Set/Get the "end" point of this cicle. Calls C<point_start>. |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head2 point_start |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
Set/Get the "start" point of this cicle. Returns the point at the circle's |
|
124
|
|
|
|
|
|
|
origin X coordinate and the origin Y coordinate + radius / 2. |
|
125
|
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 AUTHOR |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Cory Watson <gphat@cpan.org> |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
You can redistribute and/or modify this code under the same terms as Perl |
|
133
|
|
|
|
|
|
|
itself. |