Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## geomerative
Class RShape

    java.lang.Object
      geomerative.RGeomElem
          geomerative.RShape

    public class RShape

extends RGeomElem

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.

Field Summary
`RShape[]` | `children`
`RPath[]` | `paths` Array of RPath objects holding the paths of the polygon.
`int` | `type`

Fields inherited from class geomerative.RGeomElem
`COMMAND, CONTOUR, GROUP, MESH, name, POLYGON, SHAPE, SUBSHAPE, TRISTRIP, UNKNOWN`

Constructor Summary
`RShape()` Use this method to create a new empty shape.
`RShape(RPath newpath)`
`RShape(RPath[] newpaths)`
`RShape(RPoint[][] points)`
`RShape(RShape s)`

Method Summary
`void` | `adapt(RShape shp)`
`void` | `adapt(RShape shp, float wght, float lngthOffset)` Use this method to adapt a group of of figures to a shape.
`void` | `addBezierTo(float cp1x, float cp1y, float cp2x, float cp2y, float endx, float endy)` Use this method to add a new bezierTo command to the current path.
`void` | `addBezierTo(RPoint p1, RPoint p2, RPoint p3)`
`void` | `addChild()`
`void` | `addChild(RShape s)`
`void` | `addClose()`
`void` | `addLineTo(float endx, float endy)` Use this method to add a new lineTo command to the current path.
`void` | `addLineTo(RPoint p)`
`void` | `addMoveTo(float endx, float endy)` Use this method to add a new moveTo command to the shape.
`void` | `addMoveTo(RPoint p)`
`void` | `addPath()`
`void` | `addPath(RPath s)` Use this method to create a new path.
`void` | `addQuadTo(float cp1x, float cp1y, float endx, float endy)` Use this method to add a new quadTo command to the current path.
`void` | `addQuadTo(RPoint p1, RPoint p2)`
`void` | `addShape(RShape s)` Use this method to add a new shape.
`boolean` | `contains(float x, float y)` Use this to return a specific tangent on the curve.
`boolean` | `contains(RPoint p)` Use this to return a specific tangent on the curve.
`int` | `countChildren()`
`int` | `countPaths()` Use this method to count the number of paths in the polygon.
`static RShape` | `createCircle(float x, float y, float d)`
`static RShape` | `createEllipse(float x, float y, float w, float h)` Use this method to create a new elliptical shape.
`static RShape` | `createLine(float x1, float y1, float x2, float y2)` Use this method to create a new line.
`static RShape` | `createRectangle(float x, float y, float w, float h)` Use this method to create a new circle shape.
`static RShape` | `createRing(float x, float y, float widthBig, float widthSmall)` Use this method to create a new ring polygon.
`static RShape` | `createStar(float x, float y, float widthBig, float widthSmall, int spikes)` Use this method to create a new starform polygon.
`RShape` | `diff(RShape p)` Use this method to get the difference of the given polygon with the polygon passed as atribute.
`void` | `draw(processing.core.PApplet g)`
`void` | `draw(processing.core.PGraphics g)`
`RPoint` | `getCentroid()` Use this method to get the centroid of the element.
`RShape` | `getChild(java.lang.String target)` Extracts a shape by its name.
`RClosest` | `getClosest(RShape other)` Use this method to get the closest or intersection points of the shape with another shape passed as argument.
`RPoint[]` | `getHandles()` Use this to return the start, control and end points of the shape.
`RPoint[][]` | `getHandlesInPaths()`
`RPoint[]` | `getIntersections(RShape other)` Use this method to get the intersection points of the shape with another shape passed as argument.
`RPoint` | `getPoint(float t)` Use this to return a point on the curve given a certain advancement.
`RPoint[]` | `getPoints()` Use this to return the points on the curve of the shape.
`RPoint[][]` | `getPointsInPaths()` Use this to return the points of each path of the group.
`RPoint` | `getTangent(float t)` Use this to return a point on the curve given a certain advancement.
`RPoint[]` | `getTangents()` Use this to return the points on the curve of the shape.
`RPoint[][]` | `getTangentsInPaths()`
`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 shape.
`void` | `insertHandleInPaths(float t)` Use this to insert a split point into each command of the shape.
`RShape` | `intersection(RShape p)` Use this method to get the intersection of the given polygon with the polygon passed as atribute.
`void` | `polygonize()`
`void` | `print()`
`void` | `setPath(int indPath)` Use this method to set the current path.
`RShape[]` | `split(float t)`
`RShape[]` | `splitPaths(float t)`
`RMesh` | `toMesh()` Use this method to create a new mesh from a given polygon.
`RPolygon` | `toPolygon()` Use this method to create a new polygon from a given shape.
`RShape` | `toShape()`
`RShape` | `union(RShape p)` Use this method to get the union of the given polygon with the polygon passed as atribute.
`RShape` | `xor(RShape p)` Use this method to get the xor of the given polygon with the polygon passed as atribute.

Methods inherited from class geomerative.RGeomElem
`centerIn, centerIn, centerIn, contains, contains, containsBounds, containsHandles, draw, getArea, getBottomLeft, getBottomRight, getBounds, getBoundsPoints, getCenter, getCenteringTransf, getCenteringTransf, getCenteringTransf, 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`

Methods inherited from class java.lang.Object
`equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### type

    public int type

### paths

    public RPath[] paths

  Array of RPath objects holding the paths of the polygon.

### children

    public RShape[] children

Constructor Detail

### RShape

    public RShape()

  Use this method to create a new empty shape.

### RShape

    public RShape(RPath newpath)

### RShape

    public RShape(RPath[] newpaths)

### RShape

    public RShape(RPoint[][] points)

### RShape

    public RShape(RShape s)

Method Detail

### createLine

    public static RShape createLine(float x1,
                                    float y1,
                                    float x2,
                                    float y2)

  Use this method to create a new line.

  Parameters:
    `x1` - x coordinate of the first point of the line
    `y1` - y coordinate of the first point of the line
    `x2` - x coordinate of the last point of the line
    `y2` - y coordinate of the last point of the line
  Returns:
    RShape, the ring polygon newly created

### createRing

    public static RShape createRing(float x,
                                    float y,
                                    float widthBig,
                                    float widthSmall)

  Use this method to create a new ring polygon.

  Parameters:
    `x` - x coordinate of the center of the shape
    `y` - y coordinate of the center of the shape
    `widthBig` - the outter width of the ring polygon
    `widthSmall` - the inner width of the ring polygon
  Returns:
    RShape, the ring polygon newly created

### createStar

    public static RShape createStar(float x,
                                    float y,
                                    float widthBig,
                                    float widthSmall,
                                    int spikes)

  Use this method to create a new starform polygon.

  Parameters:
    `widthBig` - the outter width of the star polygon
    `widthSmall` - the inner width of the star polygon
    `spikes` - the amount of spikes on the star polygon
  Returns:
    RShape, the starform polygon newly created

### createRectangle

    public static RShape createRectangle(float x,
                                         float y,
                                         float w,
                                         float h)

  Use this method to create a new circle shape.

  Parameters:
    `x` - the x position of the rectangle
    `y` - the y position of the rectangle
    `w` - the width of the rectangle
    `h` - the height of the rectangle
  Returns:
    RShape, the rectangular shape just created

### createEllipse

    public static RShape createEllipse(float x,
                                       float y,
                                       float w,
                                       float h)

  Use this method to create a new elliptical shape.

  Parameters:
    `x` - the x position of the ellipse
    `y` - the y position of the ellipse
    `w` - the width of the ellipse
    `h` - the height of the ellipse
  Returns:
    RShape, the elliptical shape just created

### createCircle

    public static RShape createCircle(float x,
                                      float y,
                                      float d)

### getChild

    public RShape getChild(java.lang.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

### getCentroid

    public RPoint getCentroid()

  Use this method to get the centroid of the element.

  Overrides:
    `getCentroid` in class `RGeomElem`
  Returns:
    RPoint, the centroid point of the element

### countPaths

    public int countPaths()

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

  Returns:
    int, the number countours in the polygon.

### countChildren

    public int countChildren()

### addShape

    public void addShape(RShape s)

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

  Parameters:
    `s` - RShape, the shape to be added.

### addPath

    public void addPath(RPath s)

  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.

  Parameters:
    `s` - the path to be added.

### addPath

    public void addPath()

### addChild

    public void addChild()

### addChild

    public void addChild(RShape s)

### setPath

    public void setPath(int indPath)

  Use this method to set the current path.

### addMoveTo

    public void addMoveTo(float endx,
                          float endy)

  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.

  Parameters:
    `endx` - the x coordinate of the first point for the new path.
    `endy` - the y coordinate of the first point for the new path.

### addMoveTo

    public void addMoveTo(RPoint p)

### addLineTo

    public void addLineTo(float endx,
                          float endy)

  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.

  Parameters:
    `endx` - the x coordinate of the ending point of the line.
    `endy` - the y coordinate of the ending point of the line.

### addLineTo

    public void addLineTo(RPoint p)

### addQuadTo

    public void addQuadTo(float cp1x,
                          float cp1y,
                          float endx,
                          float endy)

  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.

  Parameters:
    `cp1x` - the x coordinate of the control point of the bezier.
    `cp1y` - the y coordinate of the control point of the bezier.
    `endx` - the x coordinate of the ending point of the bezier.
    `endy` - the y coordinate of the ending point of the bezier.

### addQuadTo

    public void addQuadTo(RPoint p1,
                          RPoint p2)

### addBezierTo

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

  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.

  Parameters:
    `cp1x` - the x coordinate of the first control point of the bezier.
    `cp1y` - the y coordinate of the first control point of the bezier.
    `cp2x` - the x coordinate of the second control point of the bezier.
    `cp2y` - the y coordinate of the second control point of the bezier.
    `endx` - the x coordinate of the ending point of the bezier.
    `endy` - the y coordinate of the ending point of the bezier.

### addBezierTo

    public void addBezierTo(RPoint p1,
                            RPoint p2,
                            RPoint p3)

### addClose

    public void addClose()

### toMesh

    public RMesh toMesh()

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

  Overrides:
    `toMesh` in class `RGeomElem`
  Returns:
    RMesh, the mesh made of tristrips resulting of a tesselation of the polygonization followd by tesselation of the shape.

### toPolygon

    public RPolygon toPolygon()

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

  Overrides:
    `toPolygon` in class `RGeomElem`
  Returns:
    RPolygon, the polygon resulting of the segmentation of the commands in each path.

### polygonize

    public void polygonize()

### toShape

    public RShape toShape()

  Specified by:
    `toShape` in class `RGeomElem`

### intersection

    public RShape intersection(RShape p)

  Use this method to get the intersection of the given polygon with the polygon passed as atribute.

  Parameters:
    `p` - RShape, the polygon with which to perform the intersection
  Returns:
    RShape, the intersection of the two polygons

### union

    public RShape union(RShape p)

  Use this method to get the union of the given polygon with the polygon passed as atribute.

  Parameters:
    `p` - RShape, the polygon with which to perform the union
  Returns:
    RShape, the union of the two polygons

### xor

    public RShape xor(RShape p)

  Use this method to get the xor of the given polygon with the polygon passed as atribute.

  Parameters:
    `p` - RShape, the polygon with which to perform the xor
  Returns:
    RShape, the xor of the two polygons

### diff

    public RShape diff(RShape p)

  Use this method to get the difference of the given polygon with the polygon passed as atribute.

  Parameters:
    `p` - RShape, the polygon with which to perform the difference
  Returns:
    RShape, the difference of the two polygons

### getHandles

    public RPoint[] getHandles()

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

  Specified by:
    `getHandles` in class `RGeomElem`
  Returns:
    RPoint[], the start, control and end points returned in an array.

### getPoint

    public RPoint getPoint(float t)

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

  Specified by:
    `getPoint` in class `RGeomElem`
  Returns:
    RPoint[], the point on the curve.

### getPoints

    public RPoint[] getPoints()

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

  Specified by:
    `getPoints` in class `RGeomElem`
  Returns:
    RPoint[], the points returned in an array.

### getTangent

    public RPoint getTangent(float t)

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

  Specified by:
    `getTangent` in class `RGeomElem`
  Returns:
    RPoint[], the point on the curve.

### contains

    public boolean contains(float x,
                            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:
    `x` - the X coordinate of the point for which to test containement.
    `y` - the Y coordinate of the point for which to test containement.
  Returns:
    boolean, true if the point is in the path.

### 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 shape. Implementation taken from: http://www.ecse.rpi.edu/Homepages/wrf/Research/Short_Notes/pnpoly.html

  Specified by:
    `contains` in class `RGeomElem`
  Parameters:
    `p` - the point for which to test containement..
  Returns:
    boolean, true if the point is in the path.

### getTangents

    public RPoint[] getTangents()

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

  Specified by:
    `getTangents` in class `RGeomElem`
  Returns:
    RPoint[], the points returned in an array.

### getPointsInPaths

    public RPoint[][] getPointsInPaths()

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

  Specified by:
    `getPointsInPaths` in class `RGeomElem`
  Returns:
    RPoint[], the points returned in an array.

### getHandlesInPaths

    public RPoint[][] getHandlesInPaths()

  Specified by:
    `getHandlesInPaths` in class `RGeomElem`

### getTangentsInPaths

    public RPoint[][] getTangentsInPaths()

  Specified by:
    `getTangentsInPaths` in class `RGeomElem`

### splitPaths

    public RShape[] splitPaths(float t)

### insertHandle

    public void insertHandle(float t)

  Use this to insert a split point into the shape.

  Parameters:
    `t` - 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 shape.

  Parameters:
    `t` - the parameter of advancement on the curve. t must have values between 0 and 1.

### split

    public RShape[] split(float t)

### getIntersections

    public RPoint[] getIntersections(RShape other)

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

  Parameters:
    `other` - the path with which to check for intersections

### getClosest

    public RClosest getClosest(RShape other)

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

  Parameters:
    `other` - the path with which to check for intersections

### adapt

    public void adapt(RShape shp,
                      float wght,
                      float lngthOffset)
               throws java.lang.RuntimeException

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

  Parameters:
    `shp` - the path to which to adapt
  Throws:
    `java.lang.RuntimeException`

### adapt

    public void adapt(RShape shp)
               throws java.lang.RuntimeException

  Throws:
    `java.lang.RuntimeException`

### getType

    public int getType()

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

  Specified by:
    `getType` in class `RGeomElem`
  Returns:
    int, will allways return RGeomElem.SHAPE

### print

    public void print()

  Overrides:
    `print` in class `RGeomElem`

### draw

    public void draw(processing.core.PGraphics g)

  Specified by:
    `draw` in class `RGeomElem`

### draw

    public void draw(processing.core.PApplet g)

  Specified by:
    `draw` in class `RGeomElem`

Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Geomerative by Ricard Marxer, http://www.ricardmarxer.com/geomerative/