| Geometry-Primitive documentation | Contained in the Geometry-Primitive distribution. |
Geometry::Primitive::Dimension - A width and height
Geometry::Primitive::Dimension encapsulates a height and width.
use Geometry::Primitive::Dimension; my $point = Geometry::Primitive::Dimeions->new(width => 100, height => 100);
Set/Get the height value.
Set/Get the width value.
Creates a new Geometry::Primitive::Point.
Compares this dimesion to another.
Return this dimesion as a string $widthx$height
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::Dimension; use Moose; use Moose::Util::TypeConstraints; use MooseX::Storage; with qw(Geometry::Primitive::Equal MooseX::Clone MooseX::Storage::Deferred); use overload ('""' => 'to_string'); has 'height' => ( is => 'rw', isa => 'Num', default => 0, ); has 'width' => ( is => 'rw', isa => 'Num', default => 0 ); coerce 'Geometry::Primitive::Dimension' => from 'ArrayRef' => via { Geometry::Primitive::Dimension->new(width => $_->[0], height => $_->[1]) }; sub equal_to { my ($self, $other) = @_; return (($self->width == $other->width) && $self->height == $other->height); } sub to_string { my ($self) = @_; return $self->width.'x'.$self->height; } __PACKAGE__->meta->make_immutable; no Moose; 1;