geomerative
public class RG extends java.lang.Object implements processing.core.PConstants
Modifier and Type | Class and Description |
---|---|
static class |
RG.FontNotLoadedException |
static class |
RG.LibraryNotInitializedException |
static class |
RG.NoPathInitializedException |
Modifier and Type | Field and Description |
---|---|
static int |
ADAPTATIVE
ADAPTATIVE segmentator minimizes the number of segments avoiding perceptual artifacts like angles or cusps.
|
static int |
BYELEMENTINDEX
The adaptor adapts the shape to a particular shape by adapting each of the groups elements indices.
|
static int |
BYELEMENTPOSITION
The adaptor adapts the shape to a particular shape by adapting each of the groups elements positions.
|
static int |
BYPOINT
The adaptor adapts the shape to a particular shape by adapting each of the groups points.
|
static boolean |
ignoreStyles |
static int |
UNIFORMLENGTH
UNIFORMLENGTH segmentator is the slowest segmentator and it segments the curve on segments of equal length.
|
static int |
UNIFORMSTEP
UNIFORMSTEP segmentator is the fastest segmentator and it segments the curve based on a constant value of the step of the curve parameter, or on the number of segments wanted.
|
static boolean |
useFastClip |
ADD, ALPHA, ALT, AMBIENT, ARC, ARGB, ARROW, BACKSPACE, BASELINE, BEVEL, BEZIER_VERTEX, BLEND, BLUR, BOTTOM, BOX, BREAK, BURN, CENTER, CHATTER, CHORD, CLAMP, CLOSE, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CURVE_VERTEX, CUSTOM, DARKEST, DEG_TO_RAD, DELETE, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_DEPTH_MASK, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_NATIVE_FONTS, DISABLE_OPENGL_ERRORS, DISABLE_OPTIMIZED_STROKE, DISABLE_RETINA_PIXELS, DISABLE_STROKE_PERSPECTIVE, DISABLE_STROKE_PURE, DISABLE_TEXTURE_MIPMAPS, DODGE, DOWN, DXF, ELLIPSE, ENABLE_DEPTH_MASK, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_ERRORS, ENABLE_OPTIMIZED_STROKE, ENABLE_RETINA_PIXELS, ENABLE_STROKE_PERSPECTIVE, ENABLE_STROKE_PURE, ENABLE_TEXTURE_MIPMAPS, ENTER, EPSILON, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, GIF, GRAY, GROUP, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LANDSCAPE, LEFT, LIGHTEST, LINE, LINE_LOOP, LINE_STRIP, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MODELVIEW, MOVE, MULTIPLY, NORMAL, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, PIE, platformNames, POINT, POINTS, POLYGON, PORTRAIT, POSTERIZE, PROBLEM, PROJECT, PROJECTION, QUAD, QUAD_BEZIER_VERTEX, QUAD_STRIP, QUADS, QUARTER_PI, RAD_TO_DEG, RADIUS, RECT, REPEAT, REPLACE, RETURN, RGB, RIGHT, ROUND, SCREEN, SHAPE, SHIFT, SOFT_LIGHT, SPHERE, SPOT, SQUARE, SUBTRACT, TAB, TARGA, TAU, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, UP, VERTEX, WAIT, WHITESPACE, WINDOWS, X, Y, Z
Constructor and Description |
---|
RG() |
Modifier and Type | Method and Description |
---|---|
static RShape |
adapt(RShape shp,
RShape path)
Adapt a shape along the curve of another shape.
|
static void |
beginShape()
Begin to create a shape.
|
static void |
bezierVertex(float cx1,
float cy1,
float cx2,
float cy2,
float x,
float y)
Add a bezierVertex to the shape.
|
static void |
breakShape() |
static void |
breakShape(int endMode)
Begin a new path in the current shape.
|
static RShape |
centerIn(RShape grp,
processing.core.PGraphics g) |
static RShape |
centerIn(RShape grp,
processing.core.PGraphics g,
float margin) |
static RShape |
createShape(RPoint[][] points)
Create a shape from an array of point arrays.
|
static RShape |
diff(RShape a,
RShape b)
Binary difference between two shapes.
|
static void |
endShape() |
static void |
endShape(processing.core.PGraphics g)
End the shape being created and draw it to the screen or the PGraphics passed as parameter.
|
static RShape |
getEllipse(float x,
float y,
float w) |
static RShape |
getEllipse(float x,
float y,
float w,
float h)
Get an ellipse as a shape object.
|
static RShape |
getLine(float x1,
float y1,
float x2,
float y2)
Get a line as a shape object.
|
static RShape |
getRect(float x,
float y,
float w) |
static RShape |
getRect(float x,
float y,
float w,
float h)
Get an rectangle as a shape object.
|
static RShape |
getRing(float x,
float y,
float widthBig,
float widthSmall)
Get a ring as a shape object.
|
static RShape |
getShape()
End the shape being created and get it as an object.
|
static RShape |
getStar(float x,
float y,
float widthBig,
float widthSmall,
int spikes)
Get a star as a shape object.
|
static RShape |
getText(java.lang.String text) |
static RShape |
getText(java.lang.String text,
java.lang.String font,
int size,
int align)
Get the shape corresponding to a text.
|
static void |
ignoreStyles() |
static void |
ignoreStyles(boolean value)
Ignore the styles of the shapes when drawing and use the Processing style methods.
|
static void |
init(processing.core.PApplet _parent)
Initialize the library.
|
static boolean |
initialized() |
static RShape |
intersection(RShape a,
RShape b)
Binary intersection between two shapes.
|
static RFont |
loadFont(java.lang.String fontFile)
Load and get the font object that can be used in the textFont method.
|
static RShape |
loadShape(java.lang.String filename)
Load a shape object from a file.
|
static RShape |
polygonize(RShape shp)
Polygonize a shape.
|
static void |
saveShape(java.lang.String filename,
RShape shape)
Save a shape object to a file.
|
static void |
setAdaptor(int adptorType)
Use this to set the adaptor type.
|
static void |
setAdaptorLengthOffset(float adptorLengthOffset)
Use this to set the adaptor length offset.
|
static void |
setAdaptorScale(float adptorScale)
Use this to set the adaptor scaling.
|
static void |
setDpi(int _dpi)
Use this to set the resolution of the display.
|
static void |
setPolygonizer(int segmenterMethod)
Use this to set the polygonizer type.
|
static void |
setPolygonizerAngle(float angle)
Use this to set the segmentator angle tolerance for the ADAPTATIVE segmentator and set the segmentator to ADAPTATIVE.
|
static void |
setPolygonizerLength(float length)
Use this to set the segmentator length for the UNIFORMLENGTH segmentator and set the segmentator to UNIFORMLENGTH.
|
static void |
setPolygonizerStep(float step)
Use this to set the segmentator step for the UNIFORMSTEP segmentator and set the segmentator to UNIFORMSTEP.
|
static void |
shape(RShape shp) |
static void |
shape(RShape shp,
float x,
float y) |
static void |
shape(RShape shp,
float x,
float y,
float w,
float h)
Draw a shape to a given position on the screen.
|
static RShape[] |
split(RShape shp,
float t)
Split a shape along the curve length in two parts.
|
static void |
text(java.lang.String text)
Draw text to the screen using the font set using the textFont method.
|
static void |
textFont(RFont font,
int size)
Set the font object to be used in all text calls.
|
static RShape |
union(RShape a,
RShape b)
Binary union between two shapes.
|
static void |
vertex(float x,
float y)
Add a vertex to the shape.
|
static RShape |
xor(RShape a,
RShape b)
Binary xor between two shapes.
|
public static boolean ignoreStyles
public static boolean useFastClip
public static final int BYPOINT
public static final int BYELEMENTPOSITION
public static final int BYELEMENTINDEX
public static int ADAPTATIVE
public static int UNIFORMLENGTH
public static int UNIFORMSTEP
public static RFont loadFont(java.lang.String fontFile)
fontFile
- the filename of the font to be loadedpublic static void text(java.lang.String text)
text
- the string to be drawn on the screenpublic static void textFont(RFont font, int size)
font
- the font object to be setsize
- the size of the fontpublic static RShape getText(java.lang.String text, java.lang.String font, int size, int align)
font
- the filename of the font to be loadedtext
- the string to be createdsize
- the size of the font to be usedalign
- the alignment. Use RG.CENTER, RG.LEFT or RG.RIGHTpublic static RShape getText(java.lang.String text)
public static void shape(RShape shp, float x, float y, float w, float h)
shp
- the shape to be drawnx
- the horizontal coordinatey
- the vertical coordinatew
- the width with which we draw the shapeh
- the height with which we draw the shapepublic static void shape(RShape shp, float x, float y)
public static void shape(RShape shp)
public static RShape createShape(RPoint[][] points)
public static RShape loadShape(java.lang.String filename)
filename
- the SVG file to be loaded. Must be in the data directorypublic static void saveShape(java.lang.String filename, RShape shape)
filename
- the SVG file to be saved.shape
- the shape to be saved.public static void beginShape()
public static void breakShape(int endMode)
endMode
- if called with RG.CLOSE it closes the current path before starting the new one.public static void breakShape()
public static void vertex(float x, float y)
x
- the x coordinate of the vertexy
- the y coordinate of the vertexpublic static void bezierVertex(float cx1, float cy1, float cx2, float cy2, float x, float y)
cx1
- the x coordinate of the first control pointcy1
- the y coordinate of the first control pointcx2
- the x coordinate of the second control pointcy2
- the y coordinate of the second control pointx
- the x coordinate of the end pointy
- the y coordinate of the end pointpublic static void endShape(processing.core.PGraphics g)
g
- the canvas on which to draw. By default it draws on the screenpublic static void endShape()
public static RShape getShape()
public static RShape getEllipse(float x, float y, float w, float h)
x
- x coordinate of the center of the shapey
- y coordinate of the center of the shapew
- width of the ellipseh
- height of the ellipsepublic static RShape getEllipse(float x, float y, float w)
public static RShape getLine(float x1, float y1, float x2, float y2)
x1
- x coordinate of the first point of the liney1
- y coordinate of the first point of the linex2
- x coordinate of the last point of the liney2
- y coordinate of the last point of the linepublic static RShape getRect(float x, float y, float w, float h)
x
- x coordinate of the top left corner of the shapey
- y coordinate of the top left of the shapew
- width of the rectangleh
- height of the rectanglepublic static RShape getRect(float x, float y, float w)
public static RShape getStar(float x, float y, float widthBig, float widthSmall, int spikes)
x
- x coordinate of the center of the shapey
- y coordinate of the center of the shapewidthBig
- the outter width of the star polygonwidthSmall
- the inner width of the star polygonspikes
- the amount of spikes on the star polygonpublic static RShape getRing(float x, float y, float widthBig, float widthSmall)
x
- x coordinate of the center of the shapey
- y coordinate of the center of the shapewidthBig
- the outter width of the ring polygonwidthSmall
- the inner width of the ring polygonpublic static RShape[] split(RShape shp, float t)
shp
- the shape to be splitedt
- the proportion (a value from 0 to 1) along the curve where to splitpublic static RShape adapt(RShape shp, RShape path)
shp
- the shape to be adaptedpath
- the shape which curve will be followedpublic static RShape polygonize(RShape shp)
shp
- the shape to be polygonizedpublic static void init(processing.core.PApplet _parent)
public static boolean initialized()
public static void setDpi(int _dpi)
_dpi
- the dots per inch of the displaypublic static RShape diff(RShape a, RShape b)
a
- first shape to operate onb
- second shape to operate onpublic static RShape union(RShape a, RShape b)
a
- first shape to operate onb
- second shape to operate onpublic static RShape intersection(RShape a, RShape b)
a
- first shape to operate onb
- second shape to operate onpublic static RShape xor(RShape a, RShape b)
a
- first shape to operate onb
- second shape to operate onpublic static void ignoreStyles(boolean value)
value
- value to which the ignoreStyles state should be setpublic static void ignoreStyles()
public static void setAdaptor(int adptorType)
adptorType
- it can be RG.BYPOINT, RG.BYELEMENTPOSITION or RG.BYELEMENTINDEXpublic static void setAdaptorScale(float adptorScale)
adptorScale
- the scaling coefficientpublic static void setAdaptorLengthOffset(float adptorLengthOffset) throws java.lang.RuntimeException
adptorLengthOffset
- the offset along the curve of the shape. Must be a value between 0 and 1;java.lang.RuntimeException
public static void setPolygonizer(int segmenterMethod)
segmenterMethod
- can be RG.ADAPTATIVE, RG.UNIFORMLENGTH or RG.UNIFORMSTEP.public static void setPolygonizerAngle(float angle)
angle
- an angle from 0 to PI/2 it defines the maximum angle between segments.public static void setPolygonizerLength(float length)
length
- the length of each resulting segment.public static void setPolygonizerStep(float step)
step
- if a float from +0.0 to 1.0 is passed it's considered as the step, else it's considered as the number of steps. When a value of 0.0 is used the steps will be calculated automatically depending on an estimation of the length of the curve. The special value -1 is the same as 0.0 but also turning of the segmentation of lines (faster segmentation).Geomerative by Ricard Marxer, http://www.ricardmarxer.com/geomerative/