| Geometry-Primitive documentation | Contained in the Geometry-Primitive distribution. |
Geometry::Primitive::Point - An XY coordinate
Geometry::Primitive::Point represents a location in two dimensional space.
use Geometry::Primitive::Point;
my $point = Geometry::Primitive::Point->new({ x => 2, y => 0 });
Set/Get the X value.
Set/Get the Y value.
Creates a new Geometry::Primitive::Point.
Compares this point to another.
Return this point as a string $x,$y
Cory Watson <gphat@cpan.org>
You can redistribute and/or modify this code under the same terms as Perl itself.
| Geometry-Primitive documentation | Contained in the Geometry-Primitive distribution. |
package Geometry::Primitive::Point; use Moose; use Moose::Util::TypeConstraints; use MooseX::Storage; with qw(Geometry::Primitive::Equal MooseX::Clone MooseX::Storage::Deferred); use overload ('""' => 'to_string'); has 'x' => ( is => 'rw', isa => 'Num' ); has 'y' => ( is => 'rw', isa => 'Num' ); coerce 'Geometry::Primitive::Point' => from 'ArrayRef' => via { Geometry::Primitive::Point->new(x => $_->[0], y => $_->[1]) }; sub equal_to { my ($self, $other) = @_; return (($self->x == $other->x) && $self->y == $other->y); } sub to_string { my ($self) = @_; return $self->x.','.$self->y; } __PACKAGE__->meta->make_immutable; no Moose; 1;