public class HandyRenderer
extends java.lang.Object
Constructor and Description |
---|
HandyRenderer(processing.core.PApplet parent)
Creates a new HandyRender capable of using standard Processing drawing commands
to render features in a sketchy hand-drawn style.
|
Modifier and Type | Method and Description |
---|---|
void |
arc(float x,
float y,
float w,
float h,
float start,
float stop)
Draws an arc along the outer edge of an ellipse defined by the x,y, w and h parameters.
|
void |
beginShape()
Starts a new shape of type
POLYGON . |
void |
beginShape(int mode)
Starts a new shape of the type specified in the mode parameter.
|
void |
box(float bSize)
Draws 3D cube with the given unit dimension.
|
void |
box(float bWidth,
float bHeight,
float bDepth)
Draws 3D box with the given dimensions.
|
static void |
copyGraphics(processing.core.PGraphics gSrc,
processing.core.PGraphics gDst)
Copies the settings from one graphics context to another.
|
void |
curveVertex(float x,
float y)
Adds a 2d vertex to a shape or line that has curved edges.
|
void |
curveVertex(float x,
float y,
float z)
Adds a 3d vertex to a shape or line that has curved edges.
|
void |
ellipse(float x,
float y,
float w,
float h)
Draws an ellipse using the given location and dimensions.
|
void |
endShape()
Ends a shape definition.
|
void |
endShape(int mode)
Ends a shape definition.
|
boolean |
isHandy()
Reports whether the renderer is currently set to draw in a sketchy style or not.
|
void |
line(float x1,
float y1,
float x2,
float y2)
Draws a 2D line between the given coordinate pairs.
|
void |
line(float x1,
float y1,
float z1,
float x2,
float y2,
float z2)
Draws a 3D line between the given coordinate triplets.
|
void |
point(float x,
float y)
Draws 2D point at the given location.
|
void |
point(float x,
float y,
float z)
Draws 3D point at the given location.
|
void |
polyLine(float[] xCoords,
float[] yCoords)
Draws a complex line that links the given coordinates.
|
void |
quad(float x1,
float y1,
float x2,
float y2,
float x3,
float y3,
float x4,
float y4)
Draws a quadrilateral shape.
|
void |
rect(float x,
float y,
float w,
float h)
Draws a rectangle using the given location and dimensions.
|
void |
resetStyles()
Resets the sketchy styles to default values.
|
void |
setBackgroundColour(int colour)
Sets the background colour for closed shapes.
|
void |
setBowing(float bowing)
Sets the amount of 'bowing' of lines (contols the degree to which a straigh line appears as an 'I' or 'C').
|
void |
setFillColour(int colour)
Sets the fill colour for closed shapes.
|
void |
setFillGap(float gap)
Determines the gap between fill lines.
|
void |
setFillWeight(float weight)
Determines the thickness of fill lines.
|
void |
setGraphics(processing.core.PGraphics graphics)
Sets the graphics context into which all output is directed.
|
void |
setHachureAngle(float degrees)
Sets the angle for shading hachures.
|
void |
setHachurePerturbationAngle(float degrees)
Sets the maximum random perturbation in hachure angle per object.
|
void |
setIsAlternating(boolean alternate)
Determines whether or not an alternating fill stroke is used to shade shapes.
|
void |
setIsHandy(boolean isHandy)
Determines whether or not the renderer applies a hand-drawn sketchy appearance.
|
void |
setOverrideFillColour(boolean override)
Determines whether or not to override the fill colour that would otherwise be determined by
the sketch's
fillColor setting. |
void |
setOverrideStrokeColour(boolean override)
Determines whether or not to override the stroke colour that would otherwise be determined by
the sketch's
strokeColor setting. |
void |
setRoughness(float roughness)
Sets the general roughness of the sketch.
|
void |
setSecondaryColour(int colour)
Sets the secondary colour for line filling.
|
void |
setSeed(long seed)
Sets the seed used for random offsets when drawing.
|
void |
setStrokeColour(int colour)
Sets the stroke colour for rendering features.
|
void |
setStrokeWeight(float weight)
Determines the thickness of outer lines.
|
void |
setUseSecondaryColour(boolean useSecondary)
Determines whether or not a secondary colour is used for filling lines.
|
void |
shape(float[] xCoords,
float[] yCoords)
Draws a closed 2d polygon based on the given arrays of vertices.
|
void |
shape(float[] xCoords,
float[] yCoords,
boolean closeShape)
Draws a 2d polygon based on the given arrays of vertices.
|
void |
shape(float[] xCoords,
float[] yCoords,
float[] zCoords)
Draws a closed 3d polygon based on the given arrays of vertices.
|
void |
shape(float[] xCoords,
float[] yCoords,
float[] zCoords,
boolean closeShape)
Draws a 3d polygon based on the given arrays of vertices.
|
static float[] |
toArray(java.util.List<java.lang.Float> list)
Converts an array list of numeric values into a floating point array.
|
void |
triangle(float x1,
float y1,
float x2,
float y2,
float x3,
float y3)
Draws a triangle through the three pairs of coordinates.
|
void |
vertex(float x,
float y)
Adds a 2d vertex to a shape that was started with a call to
beginShape()
or one of its variants. |
void |
vertex(float x,
float y,
float z)
Adds a 3d vertex to a shape that was started with a call to
beginShape()
or one of its variants. |
public HandyRenderer(processing.core.PApplet parent)
parent
- Parent sketch that will be drawn to.public void setGraphics(processing.core.PGraphics graphics)
graphics
- New graphics context in which to render.public static void copyGraphics(processing.core.PGraphics gSrc, processing.core.PGraphics gDst)
gSrc
- Source graphics context.gDst
- Destination graphics context.public void setSeed(long seed)
seed
- Random number seed. This can be any whole number, generating the same random variation
in rendering on each redraw.public void setIsHandy(boolean isHandy)
isHandy
- Sketchy appearance used if true, or normal Processing appearance if false.public boolean isHandy()
public void setHachureAngle(float degrees)
degrees
- Angle of hachures in degrees where 0 is vertical, 45 is NE-SW and 90 is horizontal.public void setHachurePerturbationAngle(float degrees)
degrees
- Maximum hachure perturbation angle.public void setBackgroundColour(int colour)
colour
- Background colour.public void setFillColour(int colour)
setOverrideFillColour()
is true.colour
- Fill colour to use.public void setOverrideFillColour(boolean override)
fillColor
setting. If overridden, the colour is instead chosen from the
value last provided to setFillColour()
.override
- If true the interior colour of features is determined by setFillColour
,
if not, it is determined by the parent sketch's fill colour setting.public void setStrokeColour(int colour)
setOverrideStrokeColour()
is true.colour
- Stroke colour to use.public void setOverrideStrokeColour(boolean override)
strokeColor
setting. If overridden, the colour is instead chosen from the
value last provided to setStrokeColour()
.override
- If true the stroke colour of features is determined by setStrokeColour
,
if not, it is determined by the parent sketch's stroke colour setting.public void setUseSecondaryColour(boolean useSecondary)
useSecondary
- If true a secondary colour is used.public void setSecondaryColour(int colour)
setUseSecondaryColour()
is true.colour
- Colour to tint line filling.public void setFillWeight(float weight)
weight
- Fill weight in pixel units. If zero or negative, fill weight is based on the sketch's strokeWeight setting.public void setStrokeWeight(float weight)
weight
- Stroke weight in pixel units. If zero or negative, stroke weight is based on the sketch's strokeWeight setting.public void setFillGap(float gap)
gap
- Gap between fill lines in pixel units. If zero, solid fill used; if negative, gap based on strokeWeight setting.public void setIsAlternating(boolean alternate)
alternate
- Zig-zag filling used if true, parallel lines if not.public void setRoughness(float roughness)
roughness
- The sketchiness of the rendering. The larger the number the more sketchy the rendering.public void setBowing(float bowing)
bowing
- The degree of bowing in the rendering if straight lines. The larger the number the more 'loopy' lines appear.public void resetStyles()
public void point(float x, float y)
x
- x coordinate of the point.y
- y coordinate of the point.public void point(float x, float y, float z)
x
- x coordinate of the point.y
- y coordinate of the point.z
- z coordinate of the point.public void ellipse(float x, float y, float w, float h)
x
- x coordinate of the ellipse's positiony
- y coordinate of the ellipse's position.w
- Width of the ellipse (but see modifications possible with ellipseMode())h
- Height of the ellipse (but see modifications possible with ellipseMode())public void rect(float x, float y, float w, float h)
x
- x coordinate of the rectangle positiony
- y coordinate of the rectangle position.w
- Width of the rectangle (but see modifications possible with rectMode())h
- Height of the rectangle (but see modifications possible with rectMode())public void triangle(float x1, float y1, float x2, float y2, float x3, float y3)
x1
- x coordinate of the first triangle vertex.y1
- y coordinate of the first triangle vertex.x2
- x coordinate of the second triangle vertex.y2
- y coordinate of the second triangle vertex.x3
- x coordinate of the third triangle vertex.y3
- y coordinate of the third triangle vertex.public void quad(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
x1
- x coordinate of the first quadrilateral vertex.y1
- y coordinate of the first quadrilateral vertex.x2
- x coordinate of the second quadrilateral vertex.y2
- y coordinate of the second quadrilateral vertex.x3
- x coordinate of the third quadrilateral vertex.y3
- y coordinate of the third quadrilateral vertex.x4
- x coordinate of the fourth quadrilateral vertex.y4
- y coordinate of the fourth quadrilateral vertex.public void arc(float x, float y, float w, float h, float start, float stop)
x
- x coordinate of the ellipse's position around which this arc is defined.y
- y coordinate of the ellipse's position around which this arc is definedw
- Width of the ellipse around which this arc is defined (but see modifications possible with ellipseMode())h
- Height of the ellipse around which this arc is defined (but see modifications possible with ellipseMode())start
- Angle to start the arc in radians.stop
- Angle to stop the arc in radians.public void beginShape()
POLYGON
. This must be paired with a call to
endShape()
or one of its variants.public void beginShape(int mode)
endShape()
or one of its variants.mode
- either POINTS, LINES, TRIANGLES, TRIANGLE_FAN, TRIANGLE_STRIP, QUADS, QUAD_STRIPpublic void vertex(float x, float y)
beginShape()
or one of its variants.x
- x coordinate of vertex to add.y
- y coordinate of vertex to add.public void vertex(float x, float y, float z)
beginShape()
or one of its variants.x
- x coordinate of vertex to add.y
- y coordinate of vertex to add.z
- z coordinate of vertex to add.public void curveVertex(float x, float y)
beginShape()
without any parameter.x
- x coordinate of vertex to add.y
- y coordinate of vertex to add.public void curveVertex(float x, float y, float z)
beginShape()
without any parameter.x
- x coordinate of vertex to add.y
- y coordinate of vertex to add.z
- z coordinate of vertex to add.public void endShape()
beginShape()
or one of its variants. Note that this version will not close the shape if the last vertex does
not match the first one.public void endShape(int mode)
beginShape()
or one of its variants. If the mode parameter CLOSE
the shape will be closed.mode
- Type of shape closure.public void box(float bSize)
bSize
- Size of each dimension of the cube.public void box(float bWidth, float bHeight, float bDepth)
bWidth
- Width of the box.bHeight
- Height of the box.bDepth
- Depth of the box.public void shape(float[] xCoords, float[] yCoords)
xCoords
- x coordinates of the shape.yCoords
- y coordinates of the shape.public void shape(float[] xCoords, float[] yCoords, float[] zCoords)
xCoords
- x coordinates of the shape.yCoords
- y coordinates of the shape.zCoords
- z coordinates of the shape.public void shape(float[] xCoords, float[] yCoords, boolean closeShape)
xCoords
- x coordinates of the shape.yCoords
- y coordinates of the shape.closeShape
- Boundary of shape will be closed if true.public void shape(float[] xCoords, float[] yCoords, float[] zCoords, boolean closeShape)
xCoords
- x coordinates of the shape.yCoords
- y coordinates of the shape.zCoords
- z coordinates of the shape.closeShape
- Boundary of shape will be closed if true.public void polyLine(float[] xCoords, float[] yCoords)
xCoords
- x coordinates of the line.yCoords
- y coordinates of the line.public void line(float x1, float y1, float x2, float y2)
x1
- x coordinate of the start of the line.y1
- y coordinate of the start of the line.x2
- x coordinate of the end of the line.y2
- y coordinate of the end of the line.public void line(float x1, float y1, float z1, float x2, float y2, float z2)
x1
- x coordinate of the start of the line.y1
- y coordinate of the start of the line.z1
- z coordinate of the start of the line.x2
- x coordinate of the end of the line.y2
- y coordinate of the end of the line.z2
- z coordinate of the end of the line.public static float[] toArray(java.util.List<java.lang.Float> list)
list
- List of numbers to convert.