HE_Mesh  5.1.0
geomerative.RShape Class Reference
+ Inheritance diagram for geomerative.RShape:

Public Member Functions

 RShape ()
 
 RShape (final RPath newpath)
 
 RShape (final RPath[] newpaths)
 
 RShape (final RPoint[][] points)
 
 RShape (final RShape s)
 
RShape getChild (final String target)
 
int countChildren ()
 
void addPath ()
 
void addChild ()
 
void addChild (final RShape s)
 
void addMoveTo (final RPoint p)
 
void addLineTo (final RPoint p)
 
void addQuadTo (final RPoint p1, final RPoint p2)
 
void addBezierTo (final RPoint p1, final RPoint p2, final RPoint p3)
 
void addClose ()
 
void polygonize ()
 
RShape toShape ()
 
RPoint[] getHandles ()
 
RPoint getPoint (final float t)
 
RPoint[] getPoints ()
 
RPoint getTangent (final float t)
 
boolean contains (final float x, final float y)
 
boolean contains (final RPoint p)
 
RPoint[] getTangents ()
 
RPoint[][] getPointsInPaths ()
 
RPoint[][] getHandlesInPaths ()
 
RPoint[][] getTangentsInPaths ()
 
RShape[] splitPaths (final float t)
 
void insertHandle (final float t)
 
void insertHandleInPaths (final float t)
 
RShape[] split (final float t)
 
RPoint[] getIntersections (final RShape other)
 
RClosest getClosest (final RShape other)
 
void adapt (final RShape shp, final float wght, final float lngthOffset) throws RuntimeException
 
void adapt (final RShape shp) throws RuntimeException
 
int getType ()
 
void print ()
 
void draw (final PGraphics g)
 
void draw (final PApplet g)
 
- Public Member Functions inherited from geomerative.RGeomElem
abstract void draw (PGraphics g)
 
abstract void draw (PApplet g)
 
void draw ()
 
abstract RPoint getPoint (float t)
 
abstract RPoint getTangent (float t)
 
abstract RPoint[] getHandles ()
 
abstract RPoint[] getPoints ()
 
abstract RPoint[] getTangents ()
 
abstract RPoint[][] getHandlesInPaths ()
 
abstract RPoint[][] getPointsInPaths ()
 
abstract RPoint[][] getTangentsInPaths ()
 
abstract boolean contains (RPoint p)
 
abstract int getType ()
 
abstract RShape toShape ()
 
void print ()
 
void setFill (boolean _fill)
 
void setFill (int _fillColor)
 
void setFill (String str)
 
void setStroke (boolean _stroke)
 
void setStroke (int _strokeColor)
 
void setStroke (String str)
 
void setStrokeWeight (float value)
 
void setStrokeWeight (String str)
 
void setStrokeCap (String str)
 
void setStrokeJoin (String str)
 
void setStrokeAlpha (int opacity)
 
void setStrokeAlpha (String str)
 
void setFillAlpha (int opacity)
 
void setFillAlpha (String str)
 
void setAlpha (float opacity)
 
void setAlpha (int opacity)
 
void setAlpha (String str)
 
RStyle getStyle ()
 
void setStyle (RStyle s)
 
void setName (String str)
 
float[] getCurveLengths ()
 
float getCurveLength ()
 
RPolygon toPolygon ()
 
RMesh toMesh ()
 
void transform (RMatrix m)
 
void transform (float x, float y, float w, float h)
 
boolean isIn (PGraphics g)
 
boolean isIn (PApplet g)
 
RMatrix getCenteringTransf (PGraphics g) throws RuntimeException
 
RMatrix getCenteringTransf (PGraphics g, float margin) throws RuntimeException
 
void centerIn (PGraphics g)
 
void centerIn (PGraphics g, float margin)
 
void centerIn (PGraphics g, float margin, float sclDamping, float trnsDamping) throws RuntimeException
 
void rotate (float angle)
 
void scale (float sx, float sy)
 
void scale (float s)
 

Static Public Member Functions

static RShape createLine (final float x1, final float y1, final float x2, final float y2)
 
static RShape createRing (final float x, final float y, final float widthBig, final float widthSmall)
 
static RShape createStar (final float x, final float y, final float widthBig, final float widthSmall, final int spikes)
 
static RShape createRectangle (final float x, final float y, final float w, final float h)
 
static RShape createEllipse (final float x, final float y, final float w, final float h)
 
static RShape createCircle (final float x, final float y, final float d)
 

Public Attributes

int type = RGeomElem.SHAPE
 
RShape[] children = null
 
- Public Attributes inherited from geomerative.RGeomElem
float width
 
float height
 
String name = ""
 

Protected Member Functions

void calculateCurveLengths ()
 
- Protected Member Functions inherited from geomerative.RGeomElem
void saveContext (PGraphics g)
 
void saveContext (PApplet p)
 
void saveContext ()
 
void restoreContext (PGraphics g)
 
void restoreContext (PApplet p)
 
void restoreContext ()
 
void setContext (PGraphics g)
 
void setContext (PApplet p)
 
void setContext ()
 
void setStyle (RGeomElem p)
 
void setStyle (String styleString)
 
void calculateCurveLengths ()
 
void updateOrigParams ()
 

Protected Attributes

int currentPath = 0
 
int currentChild
 
- Protected Attributes inherited from geomerative.RGeomElem
float[] lenCurves
 
float lenCurve = -1F
 
RStyle style = new RStyle()
 

Private Member Functions

void drawPaths (final PGraphics g)
 
void drawPaths (final PApplet g)
 
float[] indAndAdvAt (final float t)
 
void appendChild (final RShape nextshape)
 
void append (final RPath nextpath)
 
void drawUsingInternalTesselator (final PGraphics g)
 
void drawUsingInternalTesselator (final PApplet p)
 
void drawUsingBreakShape (final PGraphics g)
 
void drawUsingBreakShape (final PApplet g)
 

Related Functions

(Note that these are not member functions.)

RPath[] paths = null
 
RPoint getCentroid ()
 
int countPaths ()
 
void addShape (final RShape s)
 
void addPath (final RPath s)
 
void setPath (final int indPath)
 
void addMoveTo (final float endx, final float endy)
 
void addLineTo (final float endx, final float endy)
 
void addQuadTo (final float cp1x, final float cp1y, final float endx, final float endy)
 
void addBezierTo (final float cp1x, final float cp1y, final float cp2x, final float cp2y, final float endx, final float endy)
 
RMesh toMesh ()
 
RPolygon toPolygon ()
 
RShape intersection (final RShape p)
 
RShape union (final RShape p)
 
RShape xor (final RShape p)
 
RShape diff (final RShape p)
 

Additional Inherited Members

- Static Public Attributes inherited from geomerative.RGeomElem
static final int SHAPE = 0
 
static final int SUBSHAPE = 1
 
static final int COMMAND = 2
 
static final int POLYGON = 3
 
static final int CONTOUR = 4
 
static final int MESH = 5
 
static final int TRISTRIP = 6
 
static final int GROUP = 7
 
static final int UNKNOWN = 8
 

Detailed Description

RShape is a reduced interface for creating, holding and drawing complex shapes. Shapes are groups of one or more paths (RPath). Shapes can be selfintersecting and can contain holes. This interface also allows you to transform shapes into polygons by segmenting the curves forming the shape.

RShape Geometry

Constructor & Destructor Documentation

geomerative.RShape.RShape ( )

Use this method to create a new empty shape.

RShape

geomerative.RShape.RShape ( final RPath  newpath)
geomerative.RShape.RShape ( final RPath[]  newpaths)
geomerative.RShape.RShape ( final RPoint  points[][])
geomerative.RShape.RShape ( final RShape  s)

Member Function Documentation

void geomerative.RShape.adapt ( final RShape  shp,
final float  wght,
final float  lngthOffset 
) throws RuntimeException

Use this method to adapt a group of of figures to a shape.

RGroup_adapt

Parameters
shpthe path to which to adapt
void geomerative.RShape.adapt ( final RShape  shp) throws RuntimeException
void geomerative.RShape.addBezierTo ( final RPoint  p1,
final RPoint  p2,
final RPoint  p3 
)
void geomerative.RShape.addChild ( )
void geomerative.RShape.addChild ( final RShape  s)
void geomerative.RShape.addClose ( )
void geomerative.RShape.addLineTo ( final RPoint  p)
void geomerative.RShape.addMoveTo ( final RPoint  p)
void geomerative.RShape.addPath ( )
void geomerative.RShape.addQuadTo ( final RPoint  p1,
final RPoint  p2 
)
void geomerative.RShape.append ( final RPath  nextpath)
private
void geomerative.RShape.appendChild ( final RShape  nextshape)
private
void geomerative.RShape.calculateCurveLengths ( )
protected
boolean geomerative.RShape.contains ( final float  x,
final float  y 
)

Use this to return a specific tangent on the curve. It returns true if the point passed as a parameter is inside the shape. Implementation taken from: http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html

Parameters
xthe X coordinate of the point for which to test containment.
ythe Y coordinate of the point for which to test containment.
Returns
boolean, true if the point is in the path.
boolean geomerative.RShape.contains ( final 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 shape. Implementation taken from: http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html

Parameters
pthe point for which to test containment.
Returns
boolean, true if the point is in the path.
int geomerative.RShape.countChildren ( )
static RShape geomerative.RShape.createCircle ( final float  x,
final float  y,
final float  d 
)
static
static RShape geomerative.RShape.createEllipse ( final float  x,
final float  y,
final float  w,
final float  h 
)
static

Use this method to create a new elliptical shape.

createEllipse

Parameters
xthe x position of the ellipse
ythe y position of the ellipse
wthe width of the ellipse
hthe height of the ellipse
Returns
RShape, the elliptical shape just created
static RShape geomerative.RShape.createLine ( final float  x1,
final float  y1,
final float  x2,
final float  y2 
)
static

Use this method to create a new line.

createRing

Parameters
x1x coordinate of the first point of the line
y1y coordinate of the first point of the line
x2x coordinate of the last point of the line
y2y coordinate of the last point of the line
Returns
RShape, the ring polygon newly created
static RShape geomerative.RShape.createRectangle ( final float  x,
final float  y,
final float  w,
final float  h 
)
static

Use this method to create a new circle shape.

createRectangle

Parameters
xthe x position of the rectangle
ythe y position of the rectangle
wthe width of the rectangle
hthe height of the rectangle
Returns
RShape, the rectangular shape just created
static RShape geomerative.RShape.createRing ( final float  x,
final float  y,
final float  widthBig,
final float  widthSmall 
)
static

Use this method to create a new ring polygon.

createRing

Parameters
xx coordinate of the center of the shape
yy coordinate of the center of the shape
widthBigthe outer width of the ring polygon
widthSmallthe inner width of the ring polygon
Returns
RShape, the ring polygon newly created
static RShape geomerative.RShape.createStar ( final float  x,
final float  y,
final float  widthBig,
final float  widthSmall,
final int  spikes 
)
static

Use this method to create a new starform polygon.

createStar

Parameters
widthBigthe outer width of the star polygon
widthSmallthe inner width of the star polygon
spikesthe amount of spikes on the star polygon
Returns
RShape, the starform polygon newly created
void geomerative.RShape.draw ( final PGraphics  g)
void geomerative.RShape.draw ( final PApplet  g)
void geomerative.RShape.drawPaths ( final PGraphics  g)
private

Use this method to draw the shape.

drawShape

Parameters
gPGraphics, the graphics object on which to draw the shape
void geomerative.RShape.drawPaths ( final PApplet  g)
private
void geomerative.RShape.drawUsingBreakShape ( final PGraphics  g)
private
void geomerative.RShape.drawUsingBreakShape ( final PApplet  g)
private
void geomerative.RShape.drawUsingInternalTesselator ( final PGraphics  g)
private
void geomerative.RShape.drawUsingInternalTesselator ( final PApplet  p)
private
RShape geomerative.RShape.getChild ( final String  target)

Extracts a shape by its name. The shape is returned as an RShape object, or null is returned if no shape with the name has been found.

Returns
RShape or null, the target shape or null if not found
RClosest geomerative.RShape.getClosest ( final RShape  other)

Use this method to get the closest or intersection points of the shape with another shape passed as argument.

Parameters
otherthe path with which to check for intersections
RPoint [] geomerative.RShape.getHandles ( )

Use this to return the start, control and end points of the shape. It returns the points as an array of RPoint.

RShape_getHandles

Returns
RPoint[], the start, control and end points returned in an array.
RPoint [][] geomerative.RShape.getHandlesInPaths ( )
RPoint [] geomerative.RShape.getIntersections ( final RShape  other)

Use this method to get the points of intersection between this shape and another shape passed in as a parameter.

Parameters
otherthe path with which to check for intersections
RPoint geomerative.RShape.getPoint ( final float  t)

Use this to return a point on the curve given a certain advancement. It returns the point as an RPoint.

RShape_getPoints

Returns
RPoint[], the point on the curve.
RPoint [] geomerative.RShape.getPoints ( )

Use this to return the points on the curve of the shape. It returns the points as an array of RPoint.

RShape_getPoints

Returns
RPoint[], the points returned in an array.
RPoint [][] geomerative.RShape.getPointsInPaths ( )

Use this to return the points of each path of the group. It returns the points as an array of arrays of RPoint.

RGroup_getPoints

Returns
RPoint[], the points returned in an array.
RPoint geomerative.RShape.getTangent ( final float  t)

Use this to return a point on the curve given a certain advancement. It returns the point as an RPoint.

RShape_getTangents

Returns
RPoint[], the point on the curve.
RPoint [] geomerative.RShape.getTangents ( )

Use this to return the points on the curve of the shape. It returns the point as an RPoint.

RShape_getTangents

Returns
RPoint[], the points returned in an array.
RPoint [][] geomerative.RShape.getTangentsInPaths ( )
int geomerative.RShape.getType ( )

Use this method to get the type of element this is.

RShape_getType

Returns
int, will allways return RGeomElem.SHAPE
float [] geomerative.RShape.indAndAdvAt ( final float  t)
private
void geomerative.RShape.insertHandle ( final float  t)

Use this to insert a split point into the shape.

insertHandle

Parameters
tthe parameter of advancement on the curve. t must have values between 0 and 1.
void geomerative.RShape.insertHandleInPaths ( final float  t)

Use this to insert a split point into each command of the shape.

insertHandleInPaths

Parameters
tthe parameter of advancement on the curve. t must have values between 0 and 1.
void geomerative.RShape.polygonize ( )
void geomerative.RShape.print ( )
RShape [] geomerative.RShape.split ( final float  t)
RShape [] geomerative.RShape.splitPaths ( final float  t)
RShape geomerative.RShape.toShape ( )

Friends And Related Function Documentation

void addBezierTo ( final float  cp1x,
final float  cp1y,
final float  cp2x,
final float  cp2y,
final float  endx,
final float  endy 
)
related

Use this method to add a new bezierTo command to the current path. This will add a cubic bezier from the last point added with the control and ending points passed as arguments.

addArcTo

Parameters
cp1xthe x coordinate of the first control point of the bezier.
cp1ythe y coordinate of the first control point of the bezier.
cp2xthe x coordinate of the second control point of the bezier.
cp2ythe y coordinate of the second control point of the bezier.
endxthe x coordinate of the ending point of the bezier.
endythe y coordinate of the ending point of the bezier. ( ) ( ) ( ) ( ) ( )
void addLineTo ( final float  endx,
final float  endy 
)
related

Use this method to add a new lineTo command to the current path. This will add a line from the last point added to the point passed as argument.

addLineTo

Parameters
endxthe x coordinate of the ending point of the line.
endythe y coordinate of the ending point of the line. ( ) ( ) ( ) ( ) ( )
void addMoveTo ( final float  endx,
final float  endy 
)
related

Use this method to add a new moveTo command to the shape. The command moveTo acts different to normal commands, in order to make a better analogy to its borthers classes Polygon and Mesh. MoveTo creates a new path in the shape. It's similar to adding a new contour to a polygon.

addMoveTo

Parameters
endxthe x coordinate of the first point for the new path.
endythe y coordinate of the first point for the new path. ( ) ( ) ( ) ( ) ( )
void addPath ( final RPath  s)
related

Use this method to create a new path. The first point of the new path will be set to (0,0). Use addMoveTo ( ) in order to add a new path with a different first point.

addPath

Parameters
sthe path to be added. ( ) ( )
void addQuadTo ( final float  cp1x,
final float  cp1y,
final float  endx,
final float  endy 
)
related

Use this method to add a new quadTo command to the current path. This will add a quadratic bezier from the last point added with the control and ending points passed as arguments.

addQuadTo

Parameters
cp1xthe x coordinate of the control point of the bezier.
cp1ythe y coordinate of the control point of the bezier.
endxthe x coordinate of the ending point of the bezier.
endythe y coordinate of the ending point of the bezier. ( ) ( ) ( ) ( ) ( )
void addShape ( final RShape  s)
related

Use this method to add a new shape. The paths of the shape we are adding will simply be added to the current shape.

addShape

Parameters
sRShape, the shape to be added. ( ) ( )
int countPaths ( )
related

Use this method to count the number of paths in the shape.

countPaths ( )

RShape diff ( final RShape  p)
related

Use this method to get the difference between this polygon and the polygon passed in as a parameter.

diff

Parameters
pRShape, the polygon with which to perform the difference
Returns
RShape, the difference of the two polygons ( ) ( ) ( )
RPoint getCentroid ( )
related

Use this method to get the centroid of the element.

RGroup_getCentroid

Returns
RPoint, the centroid point of the element ( ) ( )
RShape intersection ( final RShape  p)
related

Use this method to get the intersection of this polygon with the polygon passed in as a parameter.

intersection

Parameters
pRShape, the polygon with which to perform the intersection
Returns
RShape, the intersection of the two polygons ( ) ( ) ( )
RPath [] paths = null
related

Array of RPath objects holding the paths of the polygon.

paths

( ) ( )

void setPath ( final int  indPath)
related

Use this method to set the current path.

setPath ( ) ( ) ( ) ( ) ( )

RMesh toMesh ( )
related

Use this method to create a new mesh from a given polygon.

toMesh

Returns
RMesh, the mesh made of tristrips resulting of a tesselation of the polygonization followed by tesselation of the shape. ( )
RPolygon toPolygon ( )
related

Use this method to create a new polygon from a given shape.

toPolygon

Returns
RPolygon, the polygon resulting of the segmentation of the commands in each path. ( )
RShape union ( final RShape  p)
related

Use this method to get the union of this polygon with the polygon passed in as a parameter.

union

Parameters
pRShape, the polygon with which to perform the union
Returns
RShape, the union of the two polygons ( ) ( ) ( )
RShape xor ( final RShape  p)
related

Use this method to get the xor of this polygon with the polygon passed in as a parameter.

xor

Parameters
pRShape, the polygon with which to perform the xor
Returns
RShape, the xor of the two polygons ( ) ( ) ( )

Member Data Documentation

RShape [] geomerative.RShape.children = null
int geomerative.RShape.currentChild
protected
int geomerative.RShape.currentPath = 0
protected
int geomerative.RShape.type = RGeomElem.SHAPE

The documentation for this class was generated from the following file: