From db5de88da2d80095118b45416c9ca9e20d70fd5a Mon Sep 17 00:00:00 2001 From: Mike Thomas Date: Thu, 8 Dec 2005 19:42:11 +0000 Subject: [PATCH] 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 --- src/java/com/threerings/media/util/ArcPath.java | 16 +++++++++++++++- src/java/com/threerings/media/util/LinePath.java | 16 +++++++++++++++- 2 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/java/com/threerings/media/util/ArcPath.java b/src/java/com/threerings/media/util/ArcPath.java index 24d621322..bfd563408 100644 --- a/src/java/com/threerings/media/util/ArcPath.java +++ b/src/java/com/threerings/media/util/ArcPath.java @@ -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 diff --git a/src/java/com/threerings/media/util/LinePath.java b/src/java/com/threerings/media/util/LinePath.java index a24e5176f..9f0ffb67b 100644 --- a/src/java/com/threerings/media/util/LinePath.java +++ b/src/java/com/threerings/media/util/LinePath.java @@ -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) {