line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Geometry::Primitive::Point; |
2
|
5
|
|
|
5
|
|
271339
|
use Moose; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
use Moose::Util::TypeConstraints; |
4
|
|
|
|
|
|
|
use MooseX::Storage; |
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
with qw(Geometry::Primitive::Equal MooseX::Clone MooseX::Storage::Deferred); |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
use overload ('""' => 'to_string'); |
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has 'x' => ( |
11
|
|
|
|
|
|
|
is => 'rw', |
12
|
|
|
|
|
|
|
isa => 'Num' |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
has 'y' => ( |
15
|
|
|
|
|
|
|
is => 'rw', |
16
|
|
|
|
|
|
|
isa => 'Num' |
17
|
|
|
|
|
|
|
); |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
coerce 'Geometry::Primitive::Point' |
20
|
|
|
|
|
|
|
=> from 'ArrayRef' |
21
|
|
|
|
|
|
|
=> via { Geometry::Primitive::Point->new(x => $_->[0], y => $_->[1]) }; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub equal_to { |
24
|
|
|
|
|
|
|
my ($self, $other) = @_; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
return (($self->x == $other->x) && $self->y == $other->y); |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub to_string { |
30
|
|
|
|
|
|
|
my ($self) = @_; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
return $self->x.','.$self->y; |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
no Moose; |
38
|
|
|
|
|
|
|
1; |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head1 NAME |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Geometry::Primitive::Point - An XY coordinate |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=head1 DESCRIPTION |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
Geometry::Primitive::Point represents a location in two dimensional space. |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 SYNOPSIS |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
use Geometry::Primitive::Point; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my $point = Geometry::Primitive::Point->new({ x => 2, y => 0 }); |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head2 x |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Set/Get the X value. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 y |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Set/Get the Y value. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 METHODS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
=head2 new |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Creates a new Geometry::Primitive::Point. |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head2 equal_to |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
Compares this point to another. |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=head2 to_string |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
Return this point as a string $x,$y |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 AUTHOR |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
Cory Watson <gphat@cpan.org> |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
You can redistribute and/or modify this code under the same terms as Perl |
85
|
|
|
|
|
|
|
itself. |