Package geomerative
Class RPath
- java.lang.Object
-
- geomerative.RGeomElem
-
- geomerative.RPath
-
public class RPath extends RGeomElem
RPath is a reduced interface for creating, holding and drawing contours. Paths are ordered lists of commands (RCommand) which define the outlines of shapes. Paths can be self-intersecting.
-
-
Constructor Summary
Constructors Constructor Description RPath()
Create a new empty path.RPath(float x, float y)
Create a new path, given the coordinates of the first point.RPath(RCommand c)
RPath(RPath s)
Copy a path.RPath(RPoint p)
Create a new path, given the first point.RPath(RPoint[] points)
Create a new path, given an array of points.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addBezierTo(float cp1x, float cp1y, float cp2x, float cp2y, float endx, float endy)
Add a new cubic bezier to the path.void
addBezierTo(RPoint cp1, RPoint cp2, RPoint end)
Add a new cubic bezier to the path.void
addClose()
void
addCommand(RCommand p)
Use this method to add new commands to the contour.void
addLineTo(float endx, float endy)
Add a new line to the path.void
addLineTo(RPoint end)
Add a new line to the path.void
addQuadTo(float cp1x, float cp1y, float endx, float endy)
Add a new quadratic bezier to the path.void
addQuadTo(RPoint cp1, RPoint end)
Add a new quadratic bezier to the path.RClosest
closestPoints(RCommand other)
Use this to find the closest or intersection points between this path and a command.RClosest
closestPoints(RPath other)
Use this to return the intersection points between two paths.boolean
contains(RPoint p)
Use this to return a specific tangent on the curve.int
countCommands()
Use this method to count the number of commands in the contour.void
draw(processing.core.PApplet g)
void
draw(processing.core.PGraphics g)
Use this method to draw the path.RPoint[]
getHandles()
Use this to return the start, control and end points of the path.RPoint[][]
getHandlesInPaths()
Use this to return the handles of each path of the path.RPoint
getPoint(float t)
Return a specific point on the curve.RPoint[]
getPoints()
Use this to return the points on the curve.RPoint[][]
getPointsInPaths()
Use this to return the points of each path of the path.RPoint
getTangent(float t)
Use this to return a specific tangent on the curve.RPoint[]
getTangents()
Use this to return the tangents on the curve.RPoint[][]
getTangentsInPaths()
Use this to return the tangents of each path of the path.int
getType()
Use this method to get the type of element this is.void
insertHandle(float t)
Use this to insert a split point into the path.void
insertHandleInPaths(float t)
Use this to insert a split point into each command of the path.RPoint[]
intersectionPoints(RCommand other)
Use this to return the intersection points between this path and a command.RPoint[]
intersectionPoints(RPath other)
Use this to return the intersection points between two paths.void
polygonize()
void
print()
RPath[]
split(float t)
Use this to split a path into two separate new paths.RMesh
toMesh()
RPolygon
toPolygon()
RShape
toShape()
-
Methods inherited from class geomerative.RGeomElem
centerIn, centerIn, centerIn, contains, contains, containsBounds, containsHandles, draw, getArea, getBottomLeft, getBottomRight, getBounds, getBoundsPoints, getCenter, getCenteringTransf, getCenteringTransf, getCenteringTransf, getCentroid, getCurveLength, getCurveLengths, getHeight, getOrigHeight, getOrigWidth, getStyle, getTopLeft, getTopRight, getWidth, getX, getY, intersects, intersects, intersectsBounds, intersectsHandles, isIn, isIn, rotate, rotate, rotate, scale, scale, scale, scale, scale, scale, setAlpha, setAlpha, setAlpha, setFill, setFill, setFill, setFillAlpha, setFillAlpha, setName, setStroke, setStroke, setStroke, setStrokeAlpha, setStrokeAlpha, setStrokeCap, setStrokeJoin, setStrokeWeight, setStrokeWeight, setStyle, shear, skewX, skewY, transform, transform, transform, translate, translate
-
-
-
-
Constructor Detail
-
RPath
public RPath()
Create a new empty path.
-
RPath
public RPath(RPoint[] points)
Create a new path, given an array of points.- Parameters:
points
- the points of the new path
-
RPath
public RPath(float x, float y)
Create a new path, given the coordinates of the first point.- Parameters:
x
- x coordinate of the first point of the new pathy
- y coordinate of the first point of the new path
-
RPath
public RPath(RPoint p)
Create a new path, given the first point.- Parameters:
p
- first point of the new path
-
RPath
public RPath(RPath s)
Copy a path.- Parameters:
s
- path to be copied
-
RPath
public RPath(RCommand c)
-
-
Method Detail
-
countCommands
public int countCommands()
Use this method to count the number of commands in the contour.- Returns:
- int, the number commands in the contour
-
getHandles
public RPoint[] getHandles()
Use this to return the start, control and end points of the path. It returns the points in the way of an array of RPoint.- Specified by:
getHandles
in classRGeomElem
- Returns:
- RPoint[], the start, control and end points returned in an array.
-
getPoints
public RPoint[] getPoints()
Use this to return the points on the curve. It returns the points in the way of an array of RPoint.
-
getPointsInPaths
public RPoint[][] getPointsInPaths()
Use this to return the points of each path of the path. It returns the points in the way of an array of array of RPoint.- Specified by:
getPointsInPaths
in classRGeomElem
- Returns:
- RPoint[], the points returned in an array.
-
getHandlesInPaths
public RPoint[][] getHandlesInPaths()
Use this to return the handles of each path of the path. It returns the handles in the way of an array of array of RPoint.- Specified by:
getHandlesInPaths
in classRGeomElem
- Returns:
- RPoint[], the handles returned in an array.
-
getTangentsInPaths
public RPoint[][] getTangentsInPaths()
Use this to return the tangents of each path of the path. It returns the tangents in the way of an array of array of RPoint.- Specified by:
getTangentsInPaths
in classRGeomElem
- Returns:
- RPoint[], the tangents returned in an array.
-
getTangents
public RPoint[] getTangents()
Use this to return the tangents on the curve. It returns the vectors in the way of an array of RPoint.- Specified by:
getTangents
in classRGeomElem
- Returns:
- RPoint[], the tangent vectors returned in an array.
-
intersectionPoints
public RPoint[] intersectionPoints(RCommand other)
Use this to return the intersection points between this path and a command. Returns null if no intersection exists.- Returns:
- RPoint[], the intersection points returned in an array.
-
intersectionPoints
public RPoint[] intersectionPoints(RPath other)
Use this to return the intersection points between two paths. Returns null if no intersection exists.- Returns:
- RPoint[], the intersection points returned in an array.
-
closestPoints
public RClosest closestPoints(RCommand other)
Use this to find the closest or intersection points between this path and a command.- Returns:
- RPoint[], the intersection points returned in an array.
-
closestPoints
public RClosest closestPoints(RPath other)
Use this to return the intersection points between two paths. Returns null if no intersection exists.- Returns:
- RPoint[], the intersection points returned in an array.
-
getPoint
public RPoint getPoint(float t)
Return a specific point on the curve. It returns the RPoint for a given advancement parameter t on the curve.
-
getTangent
public RPoint getTangent(float t)
Use this to return a specific tangent on the curve. It returns the RPoint tangent for a given advancement parameter t on the curve.- Specified by:
getTangent
in classRGeomElem
- Parameters:
t
- float, the parameter of advancement on the curve. t must have values between 0 and 1.- Returns:
- RPoint, the vertice returned.
-
contains
public boolean contains(RPoint p)
Use this to return a specific tangent on the curve. It returns true if the point passed as a parameter is inside the path. Implementation taken from: http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html
-
insertHandle
public void insertHandle(float t)
Use this to insert a split point into the path.- Parameters:
t
- float, the parameter of advancement on the curve. t must have values between 0 and 1.
-
insertHandleInPaths
public void insertHandleInPaths(float t)
Use this to insert a split point into each command of the path.- Parameters:
t
- float, the parameter of advancement on the curve. t must have values between 0 and 1.
-
split
public RPath[] split(float t)
Use this to split a path into two separate new paths.- Parameters:
t
- float, the parameter of advancement on the curve. t must have values between 0 and 1.- Returns:
- RPath[], an array of two RPath.
-
polygonize
public void polygonize()
-
draw
public void draw(processing.core.PGraphics g)
Use this method to draw the path.
-
addCommand
public void addCommand(RCommand p)
Use this method to add new commands to the contour.
-
addBezierTo
public void addBezierTo(RPoint cp1, RPoint cp2, RPoint end)
Add a new cubic bezier to the path. The first point of the bezier will be the last point added to the path.- Parameters:
cp1
- first control pointcp2
- second control pointend
- end point
-
addBezierTo
public void addBezierTo(float cp1x, float cp1y, float cp2x, float cp2y, float endx, float endy)
Add a new cubic bezier to the path. The first point of the bezier will be the last point added to the path.- Parameters:
cp1x
- the x coordinate of the first control pointcp1y
- the y coordinate of the first control pointcp2x
- the x coordinate of the second control pointcp2y
- the y coordinate of the second control pointendx
- the x coordinate of the end pointendy
- the y coordinate of the end point
-
addQuadTo
public void addQuadTo(RPoint cp1, RPoint end)
Add a new quadratic bezier to the path. The first point of the bezier will be the last point added to the path.- Parameters:
cp1
- first control pointend
- end point
-
addQuadTo
public void addQuadTo(float cp1x, float cp1y, float endx, float endy)
Add a new quadratic bezier to the path. The first point of the bezier will be the last point added to the path.- Parameters:
cp1x
- the x coordinate of the first control pointcp1y
- the y coordinate of the first control pointendx
- the x coordinate of the end pointendy
- the y coordinate of the end point
-
addLineTo
public void addLineTo(RPoint end)
Add a new line to the path. The first point of the line will be the last point added to the path.- Parameters:
end
- end point
-
addLineTo
public void addLineTo(float endx, float endy)
Add a new line to the path. The first point of the line will be the last point added to the path.- Parameters:
endx
- the x coordinate of the end pointendy
- the y coordinate of the end point
-
addClose
public void addClose()
-
getType
public int getType()
Use this method to get the type of element this is.
-
-