|
PulpCore | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object pulpcore.math.Path
public class Path
The Path class is a series of straight lines and curves that a Sprite can animate along.
Paths points are immutable, but the path can be translated to another location.
Paths are created from SVG path commands. For example, a triangle path:
path = new Path("M 100 100 L 300 100 L 200 300 L 100 100");A simple curve:
path = new Path("M100,200 C100,100 400,100 400,200");See http://www.w3.org/TR/SVG/paths.html#PathData. All SVG commands are supported, however, move-to commands in the middle of a path are treated as line-to commands. That is, subpaths are concatenated together to form one path.
Note, the Path class is not used for rendering paths or shapes.
Constructor Summary | |
---|---|
Path(float[] xPoints,
float[] yPoints)
Creates a new Path with the specified points. |
|
Path(String svgPathData)
Parse an SVG path data string. |
Method Summary | |
---|---|
void |
draw(CoreGraphics g,
boolean drawJoints)
Draws the segments of this path using the current color. |
double |
getAngle(double p)
Gets the angle of point p on the path, where p is typically from 0 (start of the path) to 1 (end of the path). |
int |
getEndX()
|
int |
getEndY()
|
double |
getLength()
|
int |
getStartX()
|
int |
getStartY()
|
double |
getX(double p)
Gets the x location of point p on the path, where p is typically from 0 (start of the path) to 1 (end of the path). |
double |
getY(double p)
Gets the y location of point p on the path, where p is typically from 0 (start of the path) to 1 (end of the path). |
void |
guide(Timeline timeline,
Sprite sprite,
double startP,
double endP,
int duration)
Deprecated. |
void |
guide(Timeline timeline,
Sprite sprite,
double startP,
double endP,
int duration,
Easing easing)
Deprecated. |
void |
guide(Timeline timeline,
Sprite sprite,
double startP,
double endP,
int duration,
Easing easing,
int startDelay)
Deprecated. |
void |
guide(Timeline timeline,
Sprite sprite,
int duration)
Deprecated. |
void |
guide(Timeline timeline,
Sprite sprite,
int duration,
Easing easing)
Deprecated. |
void |
guide(Timeline timeline,
Sprite sprite,
int duration,
Easing easing,
int startDelay)
Deprecated. |
void |
guideBackwards(Timeline timeline,
Sprite sprite,
int duration)
Deprecated. |
void |
guideBackwards(Timeline timeline,
Sprite sprite,
int duration,
Easing easing)
Deprecated. |
void |
guideBackwards(Timeline timeline,
Sprite sprite,
int duration,
Easing easing,
int startDelay)
Deprecated. |
boolean |
isClosed()
Returns true if the path is closed, that is, the first point and the last point are identical. |
void |
move(Sprite sprite,
double startP,
double endP,
int duration)
Moves a sprite along this path. |
void |
move(Sprite sprite,
double startP,
double endP,
int duration,
Easing easing)
Moves a sprite along this path. |
void |
move(Sprite sprite,
double startP,
double endP,
int duration,
Easing easing,
int startDelay)
Moves a sprite along this path. |
void |
moveAndRotate(Sprite sprite,
double startP,
double endP,
int duration)
Moves a sprite along this path, rotating the sprite so that it is tangent to the path at all times. |
void |
moveAndRotate(Sprite sprite,
double startP,
double endP,
int duration,
Easing easing)
Moves a sprite along this path, rotating the sprite so that it is tangent to the path at all times. |
void |
moveAndRotate(Sprite sprite,
double startP,
double endP,
int duration,
Easing easing,
int startDelay)
Moves a sprite along this path, rotating the sprite so that it is tangent to the path at all times. |
void |
moveAndRotateOnTimeline(Timeline timeline,
Sprite sprite,
double startP,
double endP,
int duration,
Easing easing,
int startDelay)
Moves a sprite along this path, rotating the sprite so that it is tangent to the path at all times. |
void |
moveOnTimeline(Timeline timeline,
Sprite sprite,
double startP,
double endP,
int duration,
Easing easing,
int startDelay)
Moves a sprite along this path. |
void |
place(Sprite sprite,
double p)
Places a Sprite at a position along the path. |
void |
translate(double x,
double y)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public Path(String svgPathData) throws IllegalArgumentException
IllegalArgumentException
- If the path data string could not be parsed.public Path(float[] xPoints, float[] yPoints)
Method Detail |
---|
public boolean isClosed()
public double getLength()
public void translate(double x, double y)
public int getStartX()
public int getStartY()
public int getEndX()
public int getEndY()
public double getX(double p)
p
- The position along the path to place the sprite, from 0 to 1.public double getY(double p)
p
- The position along the path to place the sprite, from 0 to 1.public double getAngle(double p)
p
- The position along the path to place the sprite, from 0 to 1.public void place(Sprite sprite, double p)
sprite
- The Sprite to place.p
- The position along the path to place the sprite, from 0 to 1.public void move(Sprite sprite, double startP, double endP, int duration)
If the path is open (isClosed()
returns false), the position is clamped from
0 to 1. Otherwise, if the path is open, the position wraps. For example, for a closed path,
moving from 0 to 1.5 is the same as moving from 0 to 1 and then from 0 to 0.5.
sprite
- The spritestartP
- The start position along the path, typically from 0 to 1.endP
- The start position along the path, typically from 0 to 1.duration
- The animation duration.Timeline.move(pulpcore.sprite.Sprite, pulpcore.math.Path, double, double, int)
public void moveAndRotate(Sprite sprite, double startP, double endP, int duration)
If the path is open (isClosed()
returns false), the position is clamped from
0 to 1. Otherwise, if the path is open, the position wraps. For example, for a closed path,
moving from 0 to 1.5 is the same as moving from 0 to 1 and then from 0 to 0.5.
sprite
- The spritestartP
- The start position along the path, typically from 0 to 1.endP
- The start position along the path, typically from 0 to 1.duration
- The animation duration.Timeline.moveAndRotate(pulpcore.sprite.Sprite, pulpcore.math.Path, double, double, int)
public void move(Sprite sprite, double startP, double endP, int duration, Easing easing)
If the path is open (isClosed()
returns false), the position is clamped from
0 to 1. Otherwise, if the path is open, the position wraps. For example, for a closed path,
moving from 0 to 1.5 is the same as moving from 0 to 1 and then from 0 to 0.5.
sprite
- The spritestartP
- The start position along the path, typically from 0 to 1.endP
- The start position along the path, typically from 0 to 1.duration
- The animation duration.easing
- The animation easing.Timeline.move(pulpcore.sprite.Sprite, pulpcore.math.Path, double, double, int, pulpcore.animation.Easing)
public void moveAndRotate(Sprite sprite, double startP, double endP, int duration, Easing easing)
If the path is open (isClosed()
returns false), the position is clamped from
0 to 1. Otherwise, if the path is open, the position wraps. For example, for a closed path,
moving from 0 to 1.5 is the same as moving from 0 to 1 and then from 0 to 0.5.
sprite
- The spritestartP
- The start position along the path, typically from 0 to 1.endP
- The start position along the path, typically from 0 to 1.duration
- The animation duration.easing
- The animation easing.Timeline.moveAndRotate(pulpcore.sprite.Sprite, pulpcore.math.Path, double, double, int, pulpcore.animation.Easing)
public void move(Sprite sprite, double startP, double endP, int duration, Easing easing, int startDelay)
If the path is open (isClosed()
returns false), the position is clamped from
0 to 1. Otherwise, if the path is open, the position wraps. For example, for a closed path,
moving from 0 to 1.5 is the same as moving from 0 to 1 and then from 0 to 0.5.
sprite
- The spritestartP
- The start position along the path, typically from 0 to 1.endP
- The start position along the path, typically from 0 to 1.duration
- The animation duration.easing
- The animation easing.startDelay
- The animation start delay.Timeline.move(pulpcore.sprite.Sprite, pulpcore.math.Path, double, double, int, pulpcore.animation.Easing, int)
public void moveAndRotate(Sprite sprite, double startP, double endP, int duration, Easing easing, int startDelay)
If the path is open (isClosed()
returns false), the position is clamped from
0 to 1. Otherwise, if the path is open, the position wraps. For example, for a closed path,
moving from 0 to 1.5 is the same as moving from 0 to 1 and then from 0 to 0.5.
sprite
- The spritestartP
- The start position along the path, typically from 0 to 1.endP
- The start position along the path, typically from 0 to 1.duration
- The animation duration.easing
- The animation easing.startDelay
- The animation start delay.Timeline.moveAndRotate(pulpcore.sprite.Sprite, pulpcore.math.Path, double, double, int, pulpcore.animation.Easing, int)
public void moveOnTimeline(Timeline timeline, Sprite sprite, double startP, double endP, int duration, Easing easing, int startDelay)
If the path is open (isClosed()
returns false), the position is clamped from
0 to 1. Otherwise, if the path is open, the position wraps. For example, for a closed path,
moving from 0 to 1.5 is the same as moving from 0 to 1 and then from 0 to 0.5.
sprite
- The spritestartP
- The start position along the path, typically from 0 to 1.endP
- The start position along the path, typically from 0 to 1.duration
- The animation duration.easing
- The animation easing.startDelay
- The animation start delay.Timeline.move(pulpcore.sprite.Sprite, pulpcore.math.Path, double, double, int, pulpcore.animation.Easing, int)
public void moveAndRotateOnTimeline(Timeline timeline, Sprite sprite, double startP, double endP, int duration, Easing easing, int startDelay)
If the path is open (isClosed()
returns false), the position is clamped from
0 to 1. Otherwise, if the path is open, the position wraps. For example, for a closed path,
moving from 0 to 1.5 is the same as moving from 0 to 1 and then from 0 to 0.5.
sprite
- The spritestartP
- The start position along the path, typically from 0 to 1.endP
- The start position along the path, typically from 0 to 1.duration
- The animation duration.easing
- The animation easing.startDelay
- The animation start delay.Timeline.moveAndRotate(pulpcore.sprite.Sprite, pulpcore.math.Path, double, double, int, pulpcore.animation.Easing, int)
public void guide(Timeline timeline, Sprite sprite, int duration)
public void guide(Timeline timeline, Sprite sprite, int duration, Easing easing)
public void guide(Timeline timeline, Sprite sprite, int duration, Easing easing, int startDelay)
public void guideBackwards(Timeline timeline, Sprite sprite, int duration)
public void guideBackwards(Timeline timeline, Sprite sprite, int duration, Easing easing)
public void guideBackwards(Timeline timeline, Sprite sprite, int duration, Easing easing, int startDelay)
public void guide(Timeline timeline, Sprite sprite, double startP, double endP, int duration)
public void guide(Timeline timeline, Sprite sprite, double startP, double endP, int duration, Easing easing)
public void guide(Timeline timeline, Sprite sprite, double startP, double endP, int duration, Easing easing, int startDelay)
public void draw(CoreGraphics g, boolean drawJoints)
drawJoints
- if true, draw rectangles at the joints between line segments
|
PulpCore | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |