PulpCore

pulpcore.math
Class Path

java.lang.Object
  extended by pulpcore.math.Path

public class Path
extends Object

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 a subset of the SVG path commands. Only M (absolute move-to), L (absolute line-to) and C (absolute curve to) commands are supported. 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");
Spaces are not required. Floating point values are accepted. See http://www.w3.org/TR/SVG/paths.html#PathData

Note, the Path class is not used for rendering paths or shapes. Also, the Path class may change substantially in future iterations of PulpCore.


Field Summary
static int X_AXIS
           
static int Y_AXIS
           
 
Constructor Summary
Path(int[] xPoints, int[] yPoints)
           
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)
           
 int getEndX()
           
 int getEndY()
           
 double getLength()
           
 int getStartX()
           
 int getStartY()
           
 double getX(double p)
           
 double getY(double p)
           
 void guide(Timeline timeline, Sprite sprite, double startP, double endP, int duration)
           
 void guide(Timeline timeline, Sprite sprite, double startP, double endP, int duration, Easing easing)
           
 void guide(Timeline timeline, Sprite sprite, double startP, double endP, int duration, Easing easing, int startDelay)
           
 void guide(Timeline timeline, Sprite sprite, int duration)
           
 void guide(Timeline timeline, Sprite sprite, int duration, Easing easing)
           
 void guide(Timeline timeline, Sprite sprite, int duration, Easing easing, int startDelay)
           
 void guideBackwards(Timeline timeline, Sprite sprite, int duration)
           
 void guideBackwards(Timeline timeline, Sprite sprite, int duration, Easing easing)
           
 void guideBackwards(Timeline timeline, Sprite sprite, int duration, Easing easing, int startDelay)
           
 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
 

Field Detail

X_AXIS

public static final int X_AXIS
See Also:
Constant Field Values

Y_AXIS

public static final int Y_AXIS
See Also:
Constant Field Values
Constructor Detail

Path

public Path(String svgPathData)
     throws IllegalArgumentException
Parse an SVG path data string. Only absolute move-to, line-to, and curve-to commands are supported. See http://www.w3.org/TR/SVG/paths.html#PathData

Throws:
IllegalArgumentException - If the path data string could not be parsed.

Path

public Path(int[] xPoints,
            int[] yPoints)
Method Detail

getLength

public double getLength()

translate

public void translate(double x,
                      double y)

getStartX

public int getStartX()

getStartY

public int getStartY()

getEndX

public int getEndX()

getEndY

public int getEndY()

getX

public double getX(double p)

getY

public double getY(double p)

getAngle

public double getAngle(double p)

place

public void place(Sprite sprite,
                  double p)
Places a Sprite at a position along the path.

Parameters:
sprite - The Sprite to place.
p - The position along the path to place the sprite, from 0 to 1.

guide

public void guide(Timeline timeline,
                  Sprite sprite,
                  int duration)

guide

public void guide(Timeline timeline,
                  Sprite sprite,
                  int duration,
                  Easing easing)

guide

public void guide(Timeline timeline,
                  Sprite sprite,
                  int duration,
                  Easing easing,
                  int startDelay)

guideBackwards

public void guideBackwards(Timeline timeline,
                           Sprite sprite,
                           int duration)

guideBackwards

public void guideBackwards(Timeline timeline,
                           Sprite sprite,
                           int duration,
                           Easing easing)

guideBackwards

public void guideBackwards(Timeline timeline,
                           Sprite sprite,
                           int duration,
                           Easing easing,
                           int startDelay)

guide

public void guide(Timeline timeline,
                  Sprite sprite,
                  double startP,
                  double endP,
                  int duration)

guide

public void guide(Timeline timeline,
                  Sprite sprite,
                  double startP,
                  double endP,
                  int duration,
                  Easing easing)

guide

public void guide(Timeline timeline,
                  Sprite sprite,
                  double startP,
                  double endP,
                  int duration,
                  Easing easing,
                  int startDelay)

draw

public void draw(CoreGraphics g,
                 boolean drawJoints)
Draws the segments of this path using the current color.

Parameters:
drawJoints - if true, draw rectangles at the joints between line segments

PulpCore

Copyright © 2007-2008 Interactive Pulp, LLC.