2004-02-03 08:31:26 +00:00
|
|
|
#include "gui/Point.h"
|
2002-08-17 05:27:34 +00:00
|
|
|
|
|
|
|
@implementation Point
|
|
|
|
|
|
|
|
- (id) initWithComponents: (integer)_x : (integer)_y
|
|
|
|
{
|
2004-02-13 02:51:38 +00:00
|
|
|
self = [self init];
|
2002-08-17 05:27:34 +00:00
|
|
|
x = _x;
|
|
|
|
y = _y;
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) initWithPoint: (Point) aPoint
|
|
|
|
{
|
2004-02-13 02:51:38 +00:00
|
|
|
self = [self init];
|
2002-08-17 05:27:34 +00:00
|
|
|
|
|
|
|
if (!self || !aPoint)
|
|
|
|
return NIL;
|
|
|
|
|
|
|
|
x = [aPoint x];
|
|
|
|
y = [aPoint y];
|
|
|
|
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (id) copy
|
|
|
|
{
|
|
|
|
local id myCopy = [super copy];
|
|
|
|
|
|
|
|
if (!myCopy)
|
|
|
|
myCopy = [[self class] alloc];
|
|
|
|
|
|
|
|
return [myCopy initWithComponents: x : y];
|
|
|
|
}
|
|
|
|
|
2003-04-22 15:48:39 +00:00
|
|
|
- (integer) x
|
2002-08-17 05:27:34 +00:00
|
|
|
{
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
2003-04-22 15:48:39 +00:00
|
|
|
- (integer) y
|
2002-08-17 05:27:34 +00:00
|
|
|
{
|
|
|
|
return y;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) setPoint: (Point)aPoint
|
|
|
|
{
|
|
|
|
x = [aPoint x];
|
|
|
|
y = [aPoint y];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) addPoint: (Point) aPoint
|
|
|
|
{
|
|
|
|
x += [aPoint x];
|
|
|
|
y += [aPoint y];
|
|
|
|
}
|
|
|
|
|
|
|
|
- (void) subtractPoint: (Point) aPoint
|
|
|
|
{
|
|
|
|
x -= [aPoint x];
|
|
|
|
y -= [aPoint y];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|