Added capability to get translated (in x and y) versions of Arc and Line Paths.
git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3779 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: ArcPath.java,v 1.5 2004/08/27 02:12:47 mdb Exp $
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -81,6 +81,20 @@ public class ArcPath extends TimedPath
|
||||
(int)(start.y - Math.round(Math.sin(sangle) * yradius)));
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a copy of the path, translated by the specified amounts.
|
||||
*/
|
||||
public Path getTranslatedInstance (int x, int y)
|
||||
{
|
||||
int startx =
|
||||
(int)(_center.x + Math.round(Math.cos(_sangle) * _xradius));
|
||||
int starty =
|
||||
(int)(_center.y + Math.round(Math.sin(_sangle) * _yradius));
|
||||
|
||||
return new ArcPath(new Point (startx + x, starty + y),
|
||||
_xradius, _yradius, _sangle, _delta, _duration, _orient);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the offset that is applied to the pathable whenever it is
|
||||
* oriented. This offset is in clockwise units whose granularity is
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
//
|
||||
// $Id: LinePath.java,v 1.14 2004/08/27 02:12:47 mdb Exp $
|
||||
// $Id$
|
||||
//
|
||||
// Narya library - tools for developing networked games
|
||||
// Copyright (C) 2002-2004 Three Rings Design, Inc., All Rights Reserved
|
||||
@@ -63,6 +63,20 @@ public class LinePath extends TimedPath
|
||||
this(null, dest, duration);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a copy of the path, translated by the specified amounts.
|
||||
*/
|
||||
public Path getTranslatedInstance (int x, int y)
|
||||
{
|
||||
if (_source == null) {
|
||||
return new LinePath(null, new Point(_dest.x + x, _dest.y + y),
|
||||
_duration);
|
||||
} else {
|
||||
return new LinePath(_source.x + x, _source.y + y, _dest.x + x,
|
||||
_dest.y + y, _duration);
|
||||
}
|
||||
}
|
||||
|
||||
// documentation inherited
|
||||
public void init (Pathable pable, long timestamp)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user