package Pastel
::Geometry
::Point
;
@ISA = ("Pastel::Mixin::Mixin");
bless $self, ref($class) || $class;
$self = $self->_init(@_);
if (@_ == 1){ #If only one parameter left after shifting
if(ref($_[0]) =~ /Point/i){
$self-> _clone_point
($_[0]);
my ($x, $y) = $self->_rearrange(["X", "Y"], @_);
$self->{x
} = $x ?
$x : 0;
$self->{x
} = $_[0]->get_x();
$self->{y
} = $_[0]->get_y();
my ($x) = $self->_rearrange(["X"], @_);
my ($y) = $self->_rearrange(["Y"], @_);
my ($x, $y) = $self->_rearrange(["X", "Y"], @_);
my ($x, $y) = $self->_rearrange(["X", "Y"], @_);
if ( ($self->{x
} == $x) && ($self->{y
} == $y) ){
my $r = ref($self)."[x=".$self->{x
}.",y=".$self->{y
}."]";
if (($_[0] =~ /:point/i) || (ref($_[0]) =~ /:point/i)){
if (@args == 1){ #Passed a reference
my $x = $args[0]->get_x();
my $y = $args[0]->get_y();
$d =_calculate_distance
($self->{x
}, $self->{y
},
$d = _calculate_distance
($self->{x
}, $self->{y
}, @args);
my ($x1, $y1, $x2, $y2) =
Pastel
::Mixin
::Mixin
::_rearrange
("static",["X1","Y1","X2","Y2"],@_);
$d = _calculate_distance
($x1, $y1, $x2, $y2);
sub _calculate_distance
{
my ($x1, $y1, $x2, $y2) = @_;
return sqrt ( ($x1 - $x2)**2 + ($y1 - $y2)**2 );