Members
__frameRate
Remapped variables.
- Source:
__keyPressed
Remapped variables.
- Source:
__mousePressed
Remapped variables.
- Source:
abs
Calculates the absolute value (magnitude) of a number.
The absolute value of a number is always positive.
- Source:
acos
The inverse of cos(), returns the arc cosine of a value.
This function expects the values in the range of -1 to 1
and values are returned in the range 0 to PI
(3.1415927).
- Source:
- See:
ambient
Sets the ambient reflectance for shapes drawn to the
screen. This is combined with the ambient light
component of environment. The color components set
through the parameters define the reflectance. For
example in the default color mode, setting v1=255,
v2=126, v3=0, would cause all the red light to reflect
and half of the green light to reflect. Used in
combination with emissive(), specular(),
and shininess() in setting the materal properties
of shapes.
- Source:
- See:
ambientLight
Adds an ambient light. Ambient light doesn't come from a
specific direction, the rays have light have bounced
around so much that objects are evenly lit from all
sides. Ambient lights are almost always used in
combination with other types of lights. Lights need to
be included in the draw() to remain persistent in
a looping program. Placing them in the setup()
of a looping program will cause them to only have an
effect the first time through the loo The effect of the
parameters is determined by the current color mode.
- Source:
- See:
ArrayList
An ArrayList stores a variable number of objects.
- Source:
asin
The inverse of sin(), returns the arc sine of a value.
This function expects the values in the range of -1 to 1
and values are returned in the range -PI/2 to PI/2.
- Source:
- See:
atan
The inverse of tan(), returns the arc tangent of a
value. This function expects the values in the range of
-Infinity to Infinity (exclusive) and values are
returned in the range -PI/2 to PI/2 .
- Source:
- See:
atan2
Calculates the angle (in radians) from a specified point
to the coordinate origin as measured from the positive
x-axis. Values are returned as a float in the range from
PI to -PI. The atan2() function is most often used for
orienting geometry to the position of the cursor. Note:
The y-coordinate of the point is the first parameter and
the x-coordinate is the second due the the structure of
calculating the tangent.
- Source:
- See:
beginDraw
These functions exist only for compatibility with P5
- Source:
box
The box() function renders a box. A box is an extruded
rectangle. A box with equal dimension on all sides is a
cube. Calling this function with only one parameter will
create a cube.
- Source:
ceil
Calculates the closest int value that is greater than or
equal to the value of the parameter. For example,
ceil(9.03) returns the value 10.
- Source:
- See:
cos
Calculates the cosine of an angle. This function expects
the values of the angle parameter to be provided in
radians (values from 0 to PI*2). Values are returned in
the range -1 to 1.
- Source:
- See:
debug
- Source:
directionalLight
Adds a directional light. Directional light comes from
one direction and is stronger when hitting a surface
squarely and weaker if it hits at a gentle angle. After
hitting a surface, a directional lights scatters in all
directions. Lights need to be included in the
draw() to remain persistent in a looping program.
Placing them in the setup() of a looping program
will cause them to only have an effect the first time
through the loo The affect of the r, g,
and b parameters is determined by the current
color mode. The nx, ny, and
nz parameters specify the direction the light is
facing. For example, setting ny to -1 will cause
the geometry to be lit from below (the light is facing
directly upward).
- Source:
- See:
draw
Draw loop.
- Source:
emissive
Sets the emissive color of the material used for drawing
shapes drawn to the screen. Used in combination with
ambient(), specular(), and shininess() in setting the
material properties of shapes. Can be called in the
following ways: emissive(gray)
- Source:
- See:
endDraw
These functions exist only for compatibility with P5
- Source:
exp
Returns Euler's number e (2.71828...) raised to the
power of the value parameter.
- Source:
externals
PJS specific (non-p5) methods and properties to
externalize
- Source:
floor
Calculates the closest int value that is less than or
equal to the value of the parameter.
- Source:
- See:
focused
Confirms if a Processing program is "focused", meaning
that it is active and will accept input from mouse or
keyboard. This variable is "true" if it is focused and
"false" if not. This variable is often used when you
want to warn people they need to click on the browser
before it will work.
- Source:
glyphTable
Glyph path storage for textFonts
- Source:
HashMap
A HashMap stores a collection of objects, each
referenced by a key. This is similar to an Array, only
instead of accessing elements with a numeric index, a
String is used. (If you are familiar with associative
arrays from other languages, this is the same idea.)
- Source:
height
The height of the canvas.
- Source:
key
Event handler.
- Source:
keyCode
Event handler.
- Source:
keyIsPressed
Key is pressed.
- Source:
keyPressed
Event handler.
- Source:
keyReleased
Event handler.
- Source:
keyTyped
Event handler.
- Source:
lightFalloff
Sets the falloff rates for point lights, spot lights,
and ambient lights. The parameters are used to determine
the falloff with the following equation: d = distance
from light position to vertex position falloff = 1 /
(CONSTANT + d * LINEAR + (d*d) * QUADRATIC) Like
fill(), it affects only the elements which are
created after it in the code. The default value if
LightFalloff(1.0, 0.0, 0.0). Thinking about an
ambient light with a falloff can be tricky. It is used,
for example, if you wanted a region of your scene to be
lit ambiently one color and another region to be lit
ambiently by another color, you would use an ambient
light with location and falloff. You can think of it as
a point light that doesn't care which direction a
surface is facing.
- Source:
- See:
lightSpecular
Sets the specular color for lights. Like fill(),
it affects only the elements which are created after it
in the code. Specular refers to light which bounces off
a surface in a perferred direction (rather than bouncing
in all directions like a diffuse light) and is used for
creating highlights. The specular quality of a light
interacts with the specular material qualities set
through the specular() and
shininess() functions.
- Source:
- See:
log
Calculates the natural logarithm (the base-e logarithm)
of a number. This function expects the values greater
than 0.0.
- Source:
modes
These are internal blending modes used for BlendColor()
- Source:
- See:
-
- BlendColor
- Blend
mouseButton
Mouse button pressed
- Source:
mouseClicked
Event handler.
- Source:
mouseDragged
Event handler.
- Source:
mouseIsPressed
Mouse is pressed.
- Source:
mouseMoved
Event handler.
- Source:
mouseOut
Event handler.
- Source:
mouseOver
Event handler.
- Source:
mousePressed
Event handler.
- Source:
mouseReleased
Event handler.
- Source:
mouseScroll
Mouse scrolled
- Source:
mouseScrolled
Event handler.
- Source:
mouseX
Mouse coordinate
- Source:
mouseY
Mouse coordinate
- Source:
name
Set Processing defaults / environment variables
- Source:
noLights
Disable all lighting. Lighting is turned off by default
and enabled with the lights() method. This function can
be used to disable lighting so that 2D geometry (which
does not require lighting) can be drawn after a set of
lighted 3D geometry.
- Source:
- See:
PConstants
NOTE: in releases we replace symbolic PConstants.* names
with their values. Using PConstants.* in code below is
fine. See tools/rewrite-pconstants.js.
- Source:
pixels
Array containing the values for all the pixels in the
display window. These values are of the color datatype.
This array is the size of the display window. For
example, if the image is 100x100 pixels, there will be
10000 values and if the window is 200x300 pixels, there
will be 60000 values. The index value defines the
position of a value within the array. For example, the
statment color b = pixels[230] will set the variable b
to be equal to the value at that location in the array.
Before accessing this array, the data must loaded with
the loadPixels() function. After the array data has been
modified, the updatePixels() function must be run to
update the changes.
- Source:
- See:
pmouseX
Previous mouseX
- Source:
pmouseY
Previous mouseY
- Source:
pointLight
Adds a point light. Lights need to be included in the
draw() to remain persistent in a looping program.
Placing them in the setup() of a looping program
will cause them to only have an effect the first time
through the loo The affect of the r, g,
and b parameters is determined by the current
color mode. The x, y, and z
parameters set the position of the light.
- Source:
- See:
pow
Facilitates exponential expressions. The pow() function
is an efficient way of multiplying numbers by themselves
(or their reciprocal) in large quantities. For example,
pow(3, 5) is equivalent to the expression 3*3*3*3*3 and
pow(3, -5) is equivalent to 1 / 3*3*3*3*3.
- Source:
- See:
PVector
PVector
- Source:
requestImage
This function load images on a separate thread so that
your sketch does not freeze while images load during
setup(). While the image is loading, its width and
height will be 0. If an error occurs while loading the
image, its width and height will be set to -1. You'll
know when the image has loaded properly because its
width and height will be greater than 0. Asynchronous
image loading (particularly when downloading from a
server) can dramatically improve performance. The
extension parameter is used to determine the image type
in cases where the image filename does not end with a
proper extension. Specify the extension as the second
parameter to requestImage().
- Source:
- See:
round
Calculates the integer closest to the value parameter.
For example, round(9.2) returns the value 9.
- Source:
- See:
setup
Setup.
- Source:
shared
shared variables for blit_resize(),
filter_new_scanline(), filter_bilinear(), filter()
change this in the future to not be exposed to p
- Source:
shininess
Sets the amount of gloss in the surface of shapes. Used
in combination with
ambient(), specular(), and
emissive() in setting the material properties of
shapes.
- Source:
sin
Calculates the sine of an angle. This function expects
the values of the angle parameter to be provided in
radians (values from 0 to 6.28). Values are returned in
the range -1 to 1.
- Source:
- See:
specular
Sets the specular color of the materials used for shapes
drawn to the screen, which sets the color of
hightlights. Specular refers to light which bounces off
a surface in a perferred direction (rather than bouncing
in all directions like a diffuse light). Used in
combination with emissive(), ambient(), and shininess()
in setting the material properties of shapes. Can be
called in the following ways: specular(gray)
- Source:
- See:
sphere
The sphere() function draws a sphere with radius r
centered at coordinate 0, 0, 0. A sphere is a hollow
ball made from tessellated triangles.
- Source:
spotLight
Adds a spot light. Lights need to be included in the
draw() to remain persistent in a looping program.
Placing them in the setup() of a looping program
will cause them to only have an effect the first time
through the loo The affect of the r, g,
and b parameters is determined by the current
color mode. The x, y, and
z parameters specify the position of the light
and nx, ny, nz specify the
direction or light. The angle parameter affects
angle of the spotlight cone.
- Source:
- See:
sqrt
Calculates the square root of a number. The square root
of a number is always positive, even though there may be
a valid negative root. The square root s of number a is
such that s*s = a. It is the opposite of squaring.
- Source:
- See:
tan
Calculates the ratio of the sine and cosine of an angle.
This function expects the values of the angle parameter
to be provided in radians (values from 0 to PI*2).
Values are returned in the range infinity to -infinity.
- Source:
- See:
touchCancel
Event handler.
- Source:
touchEnd
Event handler.
- Source:
touchMove
Event handler.
- Source:
touchStart
Event handler.
- Source:
use3DContext
Default '2d' canvas context
- Source:
width
The width of the canvas.
- Source:
Methods
__codePointAt(idx) → {String}
The codePointAt() function returns the unicode value of
the character at a given index of a string.
Parameters:
Name | Type | Description |
---|---|---|
idx |
int | the index of the character |
- Source:
Returns:
code the String containing the unicode value of the
character
- Type
- String
__contains(The) → {boolean}
The contains(string) function returns true if the string
passed in the parameter is a substring of this string.
It returns false if the string passed in the parameter
is not a substring of this string.
Parameters:
Name | Type | Description |
---|---|---|
The |
String | string to look for in the current string |
- Source:
Returns:
returns true if this string contains the string passed
as parameter. returns false, otherwise.
- Type
- boolean
__endsWith(suffix) → {boolean}
The endsWith() function tests if a string ends with the
specified suffix. If the suffix is the empty String,
endsWith() will also return true.
Parameters:
Name | Type | Description |
---|---|---|
suffix |
String | the String used to compare against the end of the subject String. |
- Source:
Returns:
true if the subject String starts with the prefix.
- Type
- boolean
__equals(subject, other) → {boolean}
The __equals() function compares two strings (or
objects) to see if they are the same. This method is
necessary because it's not possible to compare strings
using the equality operator (==). Returns true if the
strings are the same and false if they are not.
Parameters:
Name | Type | Description |
---|---|---|
subject |
String | a string used for comparison |
other |
String | a string used for comparison with |
- Source:
Returns:
true is the strings are the same false otherwise
- Type
- boolean
__equalsIgnoreCase(subject, other) → {boolean}
The __equalsIgnoreCase() function compares two strings
to see if they are the same. Returns true if the strings
are the same, either when forced to all lower case or
all upper case.
Parameters:
Name | Type | Description |
---|---|---|
subject |
String | a string used for comparison |
other |
String | a string used for comparison with |
- Source:
Returns:
true is the strings are the same, ignoring case. false
otherwise
- Type
- boolean
__hashCode(subject) → {int}
The returns hash code of the.
Parameters:
Name | Type | Description |
---|---|---|
subject |
Object | The string |
- Source:
Returns:
a hash code
- Type
- int
__instanceof(obj, type)
Parameters:
Name | Type | Description |
---|---|---|
obj |
* | |
type |
* |
- Source:
__int_cast(val)
Parameters:
Name | Type | Description |
---|---|---|
val |
* |
- Source:
__printStackTrace(subject)
The __printStackTrace() prints stack trace to the
console.
Parameters:
Name | Type | Description |
---|---|---|
subject |
Exception | The error |
- Source:
__replace(subject, what, replacement) → {String}
The __replace() function searches all matches between a
substring and a string, and replaces the matched
substring with a new substring
Parameters:
Name | Type | Description |
---|---|---|
subject |
String | a substring |
what |
String | a substring to find |
replacement |
String | the string to replace the found value |
- Source:
Returns:
returns result
- Type
- String
__replaceAll(subject, regex, replace) → {String}
The __replaceAll() function searches all matches between
a substring (or regular expression) and a string, and
replaces the matched substring with a new substring
Parameters:
Name | Type | Description |
---|---|---|
subject |
String | a substring |
regex |
String | a substring or a regular expression |
replace |
String | the string to replace the found value |
- Source:
- See:
Returns:
returns result
- Type
- String
__replaceFirst(subject, regex, replace) → {String}
The __replaceFirst() function searches first matche
between a substring (or regular expression) and a
string, and replaces the matched substring with a new
substring
Parameters:
Name | Type | Description |
---|---|---|
subject |
String | a substring |
regex |
String | a substring or a regular expression |
replace |
String | the string to replace the found value |
- Source:
- See:
Returns:
returns result
- Type
- String
__split(subject, regexp, limit) → {Array.<String>}
The __split() function splits a string using the regex
delimiter specified. If limit is specified, the
resultant array will have number of elements equal to or
less than the limit.
Parameters:
Name | Type | Description |
---|---|---|
subject |
String | string to be split |
regexp |
String | regex string used to split the subject |
limit |
int | max number of tokens to be returned |
- Source:
Returns:
an array of tokens from the split string
- Type
- Array.<String>
__startsWith(prefix, toffset) → {boolean}
The startsWith() function tests if a string starts with
the specified prefix. If the prefix is the empty String
or equal to the subject String, startsWith() will also
return true.
Parameters:
Name | Type | Description |
---|---|---|
prefix |
String | the String used to compare against the start of the subject String. |
toffset |
int | (optional) an offset into the subject String where searching should begin. |
- Source:
Returns:
true if the subject String starts with the prefix.
- Type
- boolean
__toCharArray(subject) → {Array.<Char>}
The __toCharArray() function splits the string into a
char array.
Parameters:
Name | Type | Description |
---|---|---|
subject |
String | The string |
- Source:
Returns:
a char array
- Type
- Array.<Char>
_clearLogs()
Clears logs, if logger has been initialized
- Source:
alpha(aColor) → {float}
Extracts the alpha value from a color, scaled to match
current colorMode(). This value is always returned as a
float so be careful not to assign it to an int value.
Parameters:
Name | Type | Description |
---|---|---|
aColor |
color | any value of the color datatype |
- Source:
- See:
-
- red
- green
- blue
- >> right shift
- hue
- saturation
- brightness
Returns:
The alpha color value.
- Type
- float
append(array, element)
Expands an array by one element and adds data to the new
position. The datatype of the element parameter must be
the same as the datatype of the array. When using an
array of objects, the data returned from the function
must be cast to the object array's data type. For
example: SomeClass[] items = (SomeClass[])
append(originalArray, element).
Parameters:
Name | Type | Description |
---|---|---|
array |
||
element |
- Source:
- See:
Returns:
Array (the same datatype as the input)
applyMatrix(n00-n15)
Multiplies the current matrix by the one specified
through the parameters. This is very slow because it
will try to calculate the inverse of the transform, so
avoid it whenever possible. The equivalent function in
OpenGL is glMultMatrix().
Parameters:
Name | Type | Description |
---|---|---|
n00-n15 |
int | float | numbers which define the 4x4 matrix to be multiplied |
- Source:
- See:
Returns:
none
arc(a, b, c, d, start, stop)
The arc() function draws an arc in the display window.
Arcs are drawn along the outer edge of an ellipse
defined by the
x, y, width and
height parameters. The origin or the arc's
ellipse may be changed with the
ellipseMode() function. The start and
stop parameters specify the angles at which to
draw the arc.
Parameters:
Name | Type | Description |
---|---|---|
a |
float | x-coordinate of the arc's ellipse |
b |
float | y-coordinate of the arc's ellipse |
c |
float | width of the arc's ellipse |
d |
float | height of the arc's ellipse |
start |
float | angle to start the arc, specified in radians |
stop |
float | angle to stop the arc, specified in radians |
- Source:
- See:
arrayCopy(src, dest, srcPos, destPos, length)
Copies an array (or part of an array) to another array.
The src array is copied to the dst array, beginning at
the position specified by srcPos and into the position
specified by dstPos. The number of elements to copy is
determined by length. The simplified version with two
arguments copies an entire array to another of the same
size. It is equivalent to "arrayCopy(src, 0, dst, 0,
src.length)". This function is far more efficient for
copying array data than iterating through a for and
copying each element.
Parameters:
Name | Type | Description |
---|---|---|
src |
Array | an array of any data type: the source array |
dest |
Array | an array of any data type (as long as it's the same as src): the destination array |
srcPos |
int | starting position in the source array |
destPos |
int | starting position in the destination array |
length |
int | number of array elements to be copied |
- Source:
Returns:
none
ArrayList(i) → {Object}
ArrayList.get() Returns the element at the specified
position in this list.
Parameters:
Name | Type | Description |
---|---|---|
i |
int | index of element to return |
- Source:
Returns:
the element at the specified position in this list.
- Type
- Object
ArrayList(item) → {boolean}
ArrayList.contains() Returns true if this list contains
the specified element.
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | element whose presence in this List is to be tested. |
- Source:
Returns:
true if the specified element is present; false
otherwise.
- Type
- boolean
ArrayList(item) → {int}
ArrayList.indexOf() Returns the position this element
takes in the list, or -1 if the element is not found.
Parameters:
Name | Type | Description |
---|---|---|
item |
Object | element whose position in this List is to be tested. |
- Source:
Returns:
the list position that the first match for this element
holds in the list, or -1 if it is not in the list.
- Type
- int
ArrayList(index, object)
ArrayList.add() Adds the specified element to this list.
Parameters:
Name | Type | Description |
---|---|---|
index |
int | optional index at which the specified element is to be inserted |
object |
Object | element to be added to the list |
- Source:
ArrayList(Optional;, Any)
ArrayList.addAll(collection) appends all of the elements
in the specified Collection to the end of this list, in
the order that they are returned by the specified
Collection's Iterator. When called as addAll(index,
collection) the elements are inserted into this list at
the position indicated by index.
Parameters:
Name | Type | Description |
---|---|---|
Optional; |
index | specifies the position the colletion should be inserted at |
Any |
collection | iterable object (ArrayList, HashMakeySet(), etc.) |
- Source:
Throws:
out of bounds error for negative index, or index greater
than list size.
ArrayList(index, object)
ArrayList.set() Replaces the element at the specified
position in this list with the specified element.
Parameters:
Name | Type | Description |
---|---|---|
index |
int | index of element to replace |
object |
Object | element to be stored at the specified position |
- Source:
ArrayList() → {int}
ArrayList.size() Returns the number of elements in this
list.
- Source:
Returns:
the number of elements in this list
- Type
- int
ArrayList()
ArrayList.clear() Removes all of the elements from this
list. The list will be empty after this call returns.
- Source:
ArrayList(item) → {Object|boolean}
ArrayList.remove() Removes an element either based on
index, if the argument is a number, or by equality
check, if the argument is an object.
Parameters:
Name | Type | Description |
---|---|---|
item |
int | Object | either the index of the element to be removed, or the element itself. |
- Source:
Returns:
If removal is by index, the element that was removed, or
null if nothing was removed. If removal is by object,
true if removal occurred, otherwise false.
- Type
- Object | boolean
ArrayList() → {boolean}
ArrayList.isEmpty() Tests if this list has no elements.
- Source:
Returns:
true if this list has no elements; false otherwise
- Type
- boolean
ArrayList() → {ArrayList}
ArrayList.clone() Returns a shallow copy of this
ArrayList instance. (The elements themselves are not
copied.)
- Source:
Returns:
a clone of this ArrayList instance
- Type
- ArrayList
ArrayList() → {Array.<Object>}
ArrayList.toArray() Returns an array containing all of
the elements in this list in the correct order.
- Source:
Returns:
Returns an array containing all of the elements in this
list in the correct order
- Type
- Array.<Object>
background(gray, value1, value2, value3, alpha, color, hex, image)
The background() function sets the color used for the
background of the Processing window. The default
background is light gray. In the draw() function,
the background color is used to clear the display window
at the beginning of each frame. An image can also be
used as the background for a sketch, however its width
and height must be the same size as the sketch window.
To resize an image 'b' to the size of the sketch window,
use b.resize(width, height). Images used as background
will ignore the current tint() setting. For the
main drawing surface, the alpha value will be ignored.
However, alpha can be used on PGraphics objects from
createGraphics(). This is the only way to set all
the pixels partially transparent, for instance. If the
'gray' parameter is passed in the function sets the
background to a grayscale value, based on the current
colorMode.
Note that background() should be called before any transformations occur, because some implementations may require the current transformation matrix to be identity before drawing.
Parameters:
Name | Type | Description |
---|---|---|
gray |
int | float | specifies a value between white and black |
value1 |
int | float | red or hue value (depending on the current color mode) |
value2 |
int | float | green or saturation value (depending on the current color mode) |
value3 |
int | float | blue or brightness value (depending on the current color mode) |
alpha |
int | float | opacity of the background |
color |
Color | any value of the color datatype |
hex |
int | color value in hexadecimal notation (i.e. #FFCC00 or 0xFFFFCC00) |
image |
PImage | an instance of a PImage to use as a background |
- Source:
- See:
beginCamera()
The beginCamera() and
endCamera() functions enable advanced
customization of the camera space. The functions are
useful if you want to more control over camera movement,
however for most users, the camera() function
will be sufficient.
The camera functions will replace any transformations (such as rotate() or translate()) that occur before them in draw(), but they will not automatically replace the camera transform itself. For this reason, camera functions should be placed at the beginning of draw() (so that transformations happen afterwards), and the camera() function can be used after beginCamera() if you want to reset the camera before applying transformations.
This function sets the matrix mode to the camera matrix so calls such as translate(), rotate(), applyMatrix() and resetMatrix() affect the camera. beginCamera() should always be used with a following endCamera() and pairs of beginCamera() and endCamera() cannot be nested.
The camera functions will replace any transformations (such as rotate() or translate()) that occur before them in draw(), but they will not automatically replace the camera transform itself. For this reason, camera functions should be placed at the beginning of draw() (so that transformations happen afterwards), and the camera() function can be used after beginCamera() if you want to reset the camera before applying transformations.
This function sets the matrix mode to the camera matrix so calls such as translate(), rotate(), applyMatrix() and resetMatrix() affect the camera. beginCamera() should always be used with a following endCamera() and pairs of beginCamera() and endCamera() cannot be nested.
- Source:
- See:
beginShape(MODE)
Using the beginShape() and
endShape() functions allow creating more complex
forms. beginShape() begins recording vertices for
a shape and endShape() stops recording. The value
of the MODE parameter tells it which types of
shapes to create from the provided vertices. With no
mode specified, the shape can be any irregular polygon.
After calling the beginShape() function, a series
of vertex() commands must follow. To stop drawing
the shape, call endShape(). The
vertex() function with two parameters specifies a
position in 2D and the vertex()
function with three parameters specifies a position in
3D. Each shape will be outlined with the current stroke
color and filled with the fill color.
Parameters:
Name | Type | Description |
---|---|---|
MODE |
int | either POINTS, LINES, TRIANGLES, TRIANGLE_FAN, TRIANGLE_STRIP, QUADS, and QUAD_STRI |
- Source:
- See:
bezier(x1,y1,z1, cx1,cy1,cz1, cx2,cy2,cz2, x2,y2,z2)
Draws a Bezier curve on the screen. These curves are
defined by a series of anchor and control points. The
first two parameters specify the first anchor point and
the last two parameters specify the other anchor point.
The middle parameters specify the control points which
define the shape of the curve. Bezier curves were
developed by French engineer Pierre Bezier. Using the 3D
version of requires rendering with P3D or OPENGL (see
the Environment reference for more information).
Parameters:
Name | Type | Description |
---|---|---|
x1,y1,z1 |
int | float | coordinates for the first anchor point |
cx1,cy1,cz1 |
int | float | coordinates for the first control point |
cx2,cy2,cz2 |
int | float | coordinates for the second control point |
x2,y2,z2 |
int | float | coordinates for the second anchor point |
- Source:
- See:
bezierDetail(detail)
Sets the resolution at which Beziers display. The
default value is 20. This function is only useful when
using the P3D or OPENGL renderer as the default (JAVA2D)
renderer does not use this information.
Parameters:
Name | Type | Description |
---|---|---|
detail |
int | resolution of the curves |
- Source:
- See:
bezierPoint(a, b, c, d, t)
The bezierPoint() function evalutes quadratic bezier at
point t for points a, b, c, d. The parameter t varies
between 0 and 1. The a and d parameters are the on-curve
points, b and c are the control points. To make a
two-dimensional curve, call this function once with the
x coordinates and a second time with the y coordinates
to get the location of a bezier curve at t.
Parameters:
Name | Type | Description |
---|---|---|
a |
float | coordinate of first point on the curve |
b |
float | coordinate of first control point |
c |
float | coordinate of second control point |
d |
float | coordinate of second point on the curve |
t |
float | value between 0 and 1 |
- Source:
- See:
bezierTangent(a, b, c, d, t)
The bezierTangent() function calculates the tangent of a
point on a Bezier curve. There is a good definition of
"tangent" at Wikipedia:
http://en.wikipedia.org/wiki/Tangent
Parameters:
Name | Type | Description |
---|---|---|
a |
float | coordinate of first point on the curve |
b |
float | coordinate of first control point |
c |
float | coordinate of second control point |
d |
float | coordinate of second point on the curve |
t |
float | value between 0 and 1 |
- Source:
- See:
bezierVertex(cx1, cy1, cz1, cx2, cy2, cz2, x, y, z)
Specifies vertex coordinates for Bezier curves. Each
call to bezierVertex() defines the position of
two control points and one anchor point of a Bezier
curve, adding a new segment to a line or shape. The
first time bezierVertex() is used within a
beginShape() call, it must be prefaced with a
call to vertex() to set the first anchor point.
This function must be used between
beginShape() and endShape() and only when
there is no MODE parameter specified to
beginShape(). Using the 3D version of requires
rendering with P3D or OPENGL (see the Environment
reference for more information).
NOTE: Fill does not work properly yet.
NOTE: Fill does not work properly yet.
Parameters:
Name | Type | Description |
---|---|---|
cx1 |
float | int | The x-coordinate of 1st control point |
cy1 |
float | int | The y-coordinate of 1st control point |
cz1 |
float | int | The z-coordinate of 1st control point |
cx2 |
float | int | The x-coordinate of 2nd control point |
cy2 |
float | int | The y-coordinate of 2nd control point |
cz2 |
float | int | The z-coordinate of 2nd control point |
x |
float | int | The x-coordinate of the anchor point |
y |
float | int | The y-coordinate of the anchor point |
z |
float | int | The z-coordinate of the anchor point |
- Source:
- See:
binary(num, numBits) → {String}
Converts a byte, char, int, or color to a String
containing the equivalent binary notation. For example
color(0, 102, 153, 255) will convert to the String
"11111111000000000110011010011001". This function can
help make your geeky debugging sessions much happier.
Parameters:
Name | Type | Description |
---|---|---|
num |
byte | char | int | color | byte, char, int, color: value to convert |
numBits |
int | number of digits to return |
- Source:
- See:
Returns:
- Type
- String
blend(x, y, width, height, dx, dy, dwidth, dheight, srcImg, MODE)
Blends a region of pixels from one image into another
(or in itself again) with full alpha channel support.
There is a choice of the following modes to blend the
source pixels (A) with the ones of pixels in the
destination image (B): BLEND - linear interpolation of
colours: C = A*factor + B ADD - additive blending with
white clip: C = min(A*factor + B, 255) SUBTRACT -
subtractive blending with black clip: C = max(B -
A*factor, 0) DARKEST - only the darkest colour succeeds:
C = min(A*factor, B) LIGHTEST - only the lightest colour
succeeds: C = max(A*factor, B) DIFFERENCE - subtract
colors from underlying image. EXCLUSION - similar to
DIFFERENCE, but less extreme. MULTIPLY - Multiply the
colors, result will always be darker. SCREEN - Opposite
multiply, uses inverse values of the colors. OVERLAY - A
mix of MULTIPLY and SCREEN. Multiplies dark values, and
screens light values. HARD_LIGHT - SCREEN when greater
than 50% gray, MULTIPLY when lower. SOFT_LIGHT - Mix of
DARKEST and LIGHTEST. Works like OVERLAY, but not as
harsh. DODGE - Lightens light tones and increases
contrast, ignores darks. Called "Color Dodge" in
Illustrator and Photosho BURN - Darker areas are
applied, increasing contrast, ignores lights. Called
"Color Burn" in Illustrator and Photosho All modes use
the alpha information (highest byte) of source image
pixels as the blending factor. If the source and
destination regions are different sizes, the image will
be automatically resized to match the destination size.
If the srcImg parameter is not used, the display window
is used as the source image. This function ignores
imageMode().
Parameters:
Name | Type | Description |
---|---|---|
x |
int | X coordinate of the source's upper left corner |
y |
int | Y coordinate of the source's upper left corner |
width |
int | source image width |
height |
int | source image height |
dx |
int | X coordinate of the destination's upper left corner |
dy |
int | Y coordinate of the destination's upper left corner |
dwidth |
int | destination image width |
dheight |
int | destination image height |
srcImg |
PImage | image variable referring to the source image |
MODE |
PImage | Either BLEND, ADD, SUBTRACT, LIGHTEST, DARKEST, DIFFERENCE, EXCLUSION, MULTIPLY, SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, BURN |
- Source:
- See:
blendColor(c1, c2, MODE) → {float}
Blends two color values together based on the blending
mode given as the MODE parameter. The possible modes are
described in the reference for the blend() function.
Parameters:
Name | Type | Description |
---|---|---|
c1 |
color | color: the first color to blend |
c2 |
color | color: the second color to blend |
MODE |
MODE | Either BLEND, ADD, SUBTRACT, DARKEST, LIGHTEST, DIFFERENCE, EXCLUSION, MULTIPLY, SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, or BURN |
- Source:
- See:
Returns:
The blended color.
- Type
- float
blit_resize(img, srcX1, srcY1, srcX2, srcY2, destPixels, screenW, screenH, destX1, destY1, destX2, destY2, mode)
Parameters:
Name | Type | Description |
---|---|---|
img |
* | |
srcX1 |
* | |
srcY1 |
* | |
srcX2 |
* | |
srcY2 |
* | |
destPixels |
* | |
screenW |
* | |
screenH |
* | |
destX1 |
* | |
destY1 |
* | |
destX2 |
* | |
destY2 |
* | |
mode |
* |
- Source:
blue(aColor) → {float}
Extracts the blue value from a color, scaled to match
current colorMode(). This value is always returned as a
float so be careful not to assign it to an int value.
Parameters:
Name | Type | Description |
---|---|---|
aColor |
color | any value of the color datatype |
- Source:
- See:
-
- red
- green
- alpha
- >> right shift
- hue
- saturation
- brightness
Returns:
The blue color value.
- Type
- float
brightness(colInt) → {float}
Extracts the brightness value from a color.
Parameters:
Name | Type | Description |
---|---|---|
colInt |
color | any value of the color datatype |
- Source:
- See:
Returns:
The brightness color value.
- Type
- float
camera(eyeX, eyeY, eyeZ, centerX, centerY, centerZ, upX, upY, upZ)
Sets the position of the camera through setting the eye
position, the center of the scene, and which axis is
facing upward. Moving the eye position and the direction
it is pointing (the center of the scene) allows the
images to be seen from different angles. The version
without any parameters sets the camera to the default
position, pointing to the center of the display window
with the Y axis as u The default values are
camera(width/2.0, height/2.0, (height/2.0) / tan(PI*60.0
/ 360.0), width/2.0, height/2.0, 0, 0, 1, 0). This
function is similar to gluLookAt() in OpenGL, but it
first clears the current camera settings.
Parameters:
Name | Type | Description |
---|---|---|
eyeX |
float | x-coordinate for the eye |
eyeY |
float | y-coordinate for the eye |
eyeZ |
float | z-coordinate for the eye |
centerX |
float | x-coordinate for the center of the scene |
centerY |
float | y-coordinate for the center of the scene |
centerZ |
float | z-coordinate for the center of the scene |
upX |
float | usually 0.0, 1.0, -1.0 |
upY |
float | usually 0.0, 1.0, -1.0 |
upZ |
float | usually 0.0, 1.0, -1.0 |
- Source:
- See:
Character(chr)
Parameters:
Name | Type | Description |
---|---|---|
chr |
* |
- Source:
Returns:
Character()
- Source:
Character()
- Source:
color(aValue1, aValue2, aValue3, aValue4) → {color}
Creates colors for storing in variables of the color
datatype. The parameters are interpreted as RGB or HSB
values depending on the current colorMode(). The default
mode is RGB values from 0 to 255 and therefore, the
function call color(255, 204, 0) will return a bright
yellow color. More about how colors are stored can be
found in the reference for the color datatype.
Parameters:
Name | Type | Description |
---|---|---|
aValue1 |
int | float | red or hue or grey values relative to the current color range. Also can be color value in hexadecimal notation (i.e. #FFCC00 or 0xFFFFCC00) |
aValue2 |
int | float | green or saturation values relative to the current color range |
aValue3 |
int | float | blue or brightness values relative to the current color range |
aValue4 |
int | float | relative to current color range. Represents alpha |
- Source:
- See:
Returns:
the color
- Type
- color
colorMode(mode, range, range1, range2, range3, range4)
Changes the way Processing interprets color data. By
default, fill(), stroke(), and background() colors are
set by values between 0 and 255 using the RGB color
model. It is possible to change the numerical range used
for specifying colors and to switch color systems. For
example, calling colorMode(RGB, 1.0) will specify that
values are specified between 0 and 1. The limits for
defining colors are altered by setting the parameters
range1, range2, range3, and range 4.
Parameters:
Name | Type | Description |
---|---|---|
mode |
MODE | Either RGB or HSB, corresponding to Red/Green/Blue and Hue/Saturation/Brightness |
range |
int | float | range for all color elements |
range1 |
int | float | range for the red or hue depending on the current color mode |
range2 |
int | float | range for the green or saturation depending on the current color mode |
range3 |
int | float | range for the blue or brightness depending on the current color mode |
range4 |
int | float | range for the alpha |
- Source:
- See:
Returns:
none
concat(array1, array2)
Concatenates two arrays. For example, concatenating the
array { 1, 2, 3 } and the array { 4, 5, 6 } yields { 1,
2, 3, 4, 5, 6 }. Both parameters must be arrays of the
same datatype. When using an array of objects, the data
returned from the function must be cast to the object
array's data type. For example: SomeClass[] items =
(SomeClass[]) concat(array1, array2).
Parameters:
Name | Type | Description |
---|---|---|
array1 |
||
array2 |
- Source:
- See:
Returns:
Array (the same datatype as the input)
constrain(value, value, value) → {int|float}
Constrains a value to not exceed a maximum and minimum
value.
Parameters:
Name | Type | Description |
---|---|---|
value |
int | float | the value to constrain |
value |
int | float | minimum limit |
value |
int | float | maximum limit |
- Source:
- See:
Returns:
- Type
- int | float
copy(x, y, width, height, dx, dy, dwidth, dheight, srcImg)
Copies a region of pixels from the display window to
another area of the display window and copies a region
of pixels from an image used as the srcImg parameter
into the display window. If the source and destination
regions aren't the same size, it will automatically
resize the source pixels to fit the specified target
region. No alpha information is used in the process,
however if the source image has an alpha channel set, it
will be copied as well. This function ignores
imageMode().
Parameters:
Name | Type | Description |
---|---|---|
x |
int | X coordinate of the source's upper left corner |
y |
int | Y coordinate of the source's upper left corner |
width |
int | source image width |
height |
int | source image height |
dx |
int | X coordinate of the destination's upper left corner |
dy |
int | Y coordinate of the destination's upper left corner |
dwidth |
int | destination image width |
dheight |
int | destination image height |
srcImg |
PImage | image variable referring to the source image |
- Source:
- See:
createFont(name, size, smooth, charset) → {PFont}
createFont() Loads a font into a variable of type PFont.
Smooth and charset are ignored in Processing.js.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | filename of the font to load |
size |
int | float | font size in pixels |
smooth |
boolean | not used in Processing.js |
charset |
Array.<char> | not used in Processing.js |
- Source:
- See:
Returns:
new PFont object
- Type
- PFont
createGraphics(width, height, renderer, filename)
Creates and returns a new PGraphics object of the
types P2D, P3D, and JAVA2D. Use this class if you need
to draw into an off-screen graphics buffer. It's not
possible to use createGraphics() with OPENGL,
because it doesn't allow offscreen use. The DXF and PDF
renderers require the filename parameter.
It's important to call any drawing commands between beginDraw() and endDraw() statements. This is also true for any commands that affect drawing, such as smooth() or colorMode().
Unlike the main drawing surface which is completely opaque, surfaces created with createGraphics() can have transparency. This makes it possible to draw into a graphics and maintain the alpha channel.
It's important to call any drawing commands between beginDraw() and endDraw() statements. This is also true for any commands that affect drawing, such as smooth() or colorMode().
Unlike the main drawing surface which is completely opaque, surfaces created with createGraphics() can have transparency. This makes it possible to draw into a graphics and maintain the alpha channel.
Parameters:
Name | Type | Description |
---|---|---|
width |
int | width in pixels |
height |
int | height in pixels |
renderer |
int | Either P2D, P3D, JAVA2D, PDF, DXF |
filename |
String | the name of the file (not supported yet) |
- Source:
createImage(width, height, format) → {PImage}
Creates a new PImage (the datatype for storing images).
This provides a fresh buffer of pixels to play with. Set
the size of the buffer with the width and height
parameters. The format parameter defines how the pixels
are stored. See the PImage reference for more
information. Be sure to include all three parameters,
specifying only the width and height (but no format)
will produce a strange error. Advanced users please note
that createImage() should be used instead of the syntax
new PImage().
Parameters:
Name | Type | Description |
---|---|---|
width |
int | image width |
height |
int | image height |
format |
MODE | Either RGB, ARGB, ALPHA (grayscale alpha channel) |
- Source:
- See:
-
- PImage
- PGraphics
Returns:
- Type
- PImage
cursor(MODE, image, x, y)
Sets the cursor to a predefined symbol, an image, or
turns it on if already hidden. If you are trying to set
an image as the cursor, it is recommended to make the
size 16x16 or 32x32 pixels. It is not possible to load
an image as the cursor if you are exporting your program
for the Web. The values for parameters x and y must be
less than the dimensions of the image.
Parameters:
Name | Type | Description |
---|---|---|
MODE |
MODE | either ARROW, CROSS, HAND, MOVE, TEXT, WAIT |
image |
PImage | any variable of type PImage |
x |
int | the horizonal active spot of the cursor |
y |
int | the vertical active spot of the cursor |
- Source:
- See:
Returns:
none
curve(x1, y1, z1, x2, y2, z2, x3, y3, z3, x4, y4, z4)
The curve() function draws a curved line on the screen.
The first and second parameters specify the beginning
control point and the last two parameters specify the
ending control point. The middle parameters specify the
start and stop of the curve. Longer curves can be
created by putting a series of
curve() functions together or using
curveVertex(). An additional function called
curveTightness() provides control for the visual
quality of the curve. The curve() function is an
implementation of Catmull-Rom splines. Using the 3D
version of requires rendering with P3D or OPENGL (see
the Environment reference for more information).
Parameters:
Name | Type | Description |
---|---|---|
x1 |
int | float | coordinates for the beginning control point |
y1 |
int | float | coordinates for the beginning control point |
z1 |
int | float | coordinates for the beginning control point |
x2 |
int | float | coordinates for the first point |
y2 |
int | float | coordinates for the first point |
z2 |
int | float | coordinates for the first point |
x3 |
int | float | coordinates for the second point |
y3 |
int | float | coordinates for the second point |
z3 |
int | float | coordinates for the second point |
x4 |
int | float | coordinates for the ending control point |
y4 |
int | float | coordinates for the ending control point |
z4 |
int | float | coordinates for the ending control point |
- Source:
- See:
curveDetail(detail)
The curveDetail() function sets the resolution at which
curves display. The default value is 20. This function
is only useful when using the P3D or OPENGL renderer.
Parameters:
Name | Type | Description |
---|---|---|
detail |
int | resolution of the curves |
- Source:
- See:
-
- curve()
- curveVertex()
- curveTightness()
curvePoint(a, b, c, d, t)
The curvePoint() function evalutes the Catmull-Rom curve
at point t for points a, b, c, d. The parameter t varies
between 0 and 1, a and d are points on the curve, and b
and c are the control points. This can be done once with
the x coordinates and a second time with the y
coordinates to get the location of a curve at t.
Parameters:
Name | Type | Description |
---|---|---|
a |
int | float | coordinate of first point on the curve |
b |
int | float | coordinate of second point on the curve |
c |
int | float | coordinate of third point on the curve |
d |
int | float | coordinate of fourth point on the curve |
t |
float | value between 0 and 1 |
- Source:
- See:
curveTangent(a, b, c, d, t)
The curveTangent() function calculates the tangent of a
point on a Catmull-Rom curve. There is a good definition
of "tangent" at Wikipedia:
http://en.wikipedia.org/wiki/Tangent.
Parameters:
Name | Type | Description |
---|---|---|
a |
int | float | coordinate of first point on the curve |
b |
int | float | coordinate of first control point |
c |
int | float | coordinate of second control point |
d |
int | float | coordinate of second point on the curve |
t |
float | value between 0 and 1 |
- Source:
- See:
curveTightness(tightness)
The curveTightness() function modifies the quality of
forms created with curve() and
curveVertex(). The parameter
squishy determines how the curve fits to the
vertex points. The value 0.0 is the default value for
squishy (this value defines the curves to be
Catmull-Rom splines) and the value 1.0 connects all the
points with straight lines. Values within the range -5.0
and 5.0 will deform the curves but will leave them
recognizable and as values increase in magnitude, they
will continue to deform.
Parameters:
Name | Type | Description |
---|---|---|
tightness |
float | amount of deformation from the original vertices |
- Source:
- See:
curveVertex(x, y, z)
Specifies vertex coordinates for curves. This function
may only be used between beginShape() and
endShape() and only when there is no MODE
parameter specified to beginShape(). The first
and last points in a series of
curveVertex() lines will be used to guide the
beginning and end of a the curve. A minimum of four
points is required to draw a tiny curve between the
second and third points. Adding a fifth point with
curveVertex() will draw the curve between the
second, third, and fourth points. The
curveVertex() function is an implementation of
Catmull-Rom splines. Using the 3D version of requires
rendering with P3D or OPENGL (see the Environment
reference for more information).
NOTE: Fill does not work properly yet.
NOTE: Fill does not work properly yet.
Parameters:
Name | Type | Description |
---|---|---|
x |
float | int | The x-coordinate of the vertex |
y |
float | int | The y-coordinate of the vertex |
z |
float | int | The z-coordinate of the vertex |
- Source:
- See:
day() → {float}
Processing communicates with the clock on your computer.
The day() function returns the current day as a value
from 1 - 31.
Returns:
The current day.
- Type
- float
degrees(value) → {float}
Converts a radian measurement to its corresponding value
in degrees. Radians and degrees are two ways of
measuring the same thing. There are 360 degrees in a
circle and 2*PI radians in a circle. For example, 90
degrees = PI/2 = 1.5707964. All trigonometric methods in
Processing require their parameters to be specified in
radians.
Parameters:
Name | Type | Description |
---|---|---|
value |
int | float | an angle in radians |
- Source:
- See:
Returns:
- Type
- float
disableContextMenu()
Disables context menu.
- Source:
dist(x1, y1, z1, x2, y2, z2) → {float}
Calculates the distance between two points.
Parameters:
Name | Type | Description |
---|---|---|
x1 |
int | float | int or float: x-coordinate of the first point |
y1 |
int | float | int or float: y-coordinate of the first point |
z1 |
int | float | int or float: z-coordinate of the first point |
x2 |
int | float | int or float: x-coordinate of the second point |
y2 |
int | float | int or float: y-coordinate of the second point |
z2 |
int | float | int or float: z-coordinate of the second point |
- Source:
Returns:
- Type
- float
ellipse(x, y, width, height)
Draws an ellipse (oval) in the display window. An
ellipse with an equal width and height is
a circle. The first two parameters set the location, the
third sets the width, and the fourth sets the height.
The origin may be changed with the
ellipseMode() function.
Parameters:
Name | Type | Description |
---|---|---|
x |
float | int | x-coordinate of the ellipse |
y |
float | int | y-coordinate of the ellipse |
width |
float | int | width of the ellipse |
height |
float | int | height of the ellipse |
- Source:
- See:
ellipseMode(MODE)
The origin of the ellipse is modified by the
ellipseMode() function. The default configuration is
ellipseMode(CENTER), which specifies the location of the
ellipse as the center of the shape. The RADIUS mode is
the same, but the width and height parameters to
ellipse() specify the radius of the ellipse, rather than
the diameter. The CORNER mode draws the shape from the
upper-left corner of its bounding box. The CORNERS mode
uses the four parameters to ellipse() to set two
opposing corners of the ellipse's bounding box. The
parameter must be written in "ALL CAPS" because
Processing is a case sensitive language.
Parameters:
Name | Type | Description |
---|---|---|
MODE |
MODE | Either CENTER, RADIUS, CORNER, or CORNERS. |
- Source:
- See:
enableContextMenu()
Enables context menu.
- Source:
endCamera()
The beginCamera() and
endCamera() functions enable advanced
customization of the camera space. Please see the
reference for beginCamera() for a description of
how the functions are used.
- Source:
- See:
endShape(MODE)
The endShape() function is the companion to beginShape()
and may only be called after beginShape(). When
endshape() is called, all of image data defined since
the previous call to beginShape() is written into the
image buffer.
Parameters:
Name | Type | Description |
---|---|---|
MODE |
int | Use CLOSE to close the shape |
- Source:
- See:
exit()
Quits/stops/exits the program. Programs without a draw()
function exit automatically after the last line has run,
but programs with draw() run continuously until the
program is manually stopped or exit() is run. Rather
than terminating immediately, exit() will cause the
sketch to exit after draw() has completed (or after
setup() completes if called during the setup() method).
- Source:
Returns:
none
expand(ary, newSize)
Increases the size of an array. By default, this
function doubles the size of the array, but the optional
newSize parameter provides precise control over the
increase in size. When using an array of objects, the
data returned from the function must be cast to the
object array's data type. For example: SomeClass[] items
= (SomeClass[]) expand(originalArray).
Parameters:
Name | Type | Description |
---|---|---|
ary |
||
newSize |
int | positive int: new size for the array |
- Source:
- See:
-
- contract
Returns:
Array (the same datatype as the input)
fill(gray, value1, value2, value3, alpha, color, hex)
The fill() function sets the color used to fill shapes.
For example, if you run fill(204, 102, 0), all
subsequent shapes will be filled with orange. This color
is either specified in terms of the RGB or HSB color
depending on the current colorMode()
(the default color space is RGB, with each value in the
range from 0 to 255).
When using hexadecimal notation to specify a color, use "#" or "0x" before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six digits to specify a color (the way colors are specified in HTML and CSS). When using the hexadecimal notation starting with "0x", the hexadecimal value must be specified with eight characters; the first two characters define the alpha component and the remainder the red, green, and blue components.
The value for the parameter "gray" must be less than or equal to the current maximum value as specified by colorMode(). The default maximum value is 255.
To change the color of an image (or a texture), use tint().
When using hexadecimal notation to specify a color, use "#" or "0x" before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six digits to specify a color (the way colors are specified in HTML and CSS). When using the hexadecimal notation starting with "0x", the hexadecimal value must be specified with eight characters; the first two characters define the alpha component and the remainder the red, green, and blue components.
The value for the parameter "gray" must be less than or equal to the current maximum value as specified by colorMode(). The default maximum value is 255.
To change the color of an image (or a texture), use tint().
Parameters:
Name | Type | Description |
---|---|---|
gray |
int | float | number specifying value between white and black |
value1 |
int | float | red or hue value |
value2 |
int | float | green or saturation value |
value3 |
int | float | blue or brightness value |
alpha |
int | float | opacity of the fill |
color |
Color | any value of the color datatype |
hex |
int | color value in hexadecimal notation (i.e. #FFCC00 or 0xFFFFCC00) |
- Source:
- See:
filter(MODE, level)
Filters the display window as defined by one of the
following modes: THRESHOLD - converts the image to black
and white pixels depending if they are above or below
the threshold defined by the level parameter. The level
must be between 0.0 (black) and 1.0(white). If no level
is specified, 0.5 is used. GRAY - converts any colors in
the image to grayscale equivalents INVERT - sets each
pixel to its inverse value POSTERIZE - limits each
channel of the image to the number of colors specified
as the level parameter BLUR - executes a Guassian blur
with the level parameter specifying the extent of the
blurring. If no level parameter is used, the blur is
equivalent to Guassian blur of radius 1. OPAQUE - sets
the alpha channel to entirely opaque. ERODE - reduces
the light areas with the amount defined by the level
parameter. DILATE - increases the light areas with the
amount defined by the level parameter.
Parameters:
Name | Type | Description |
---|---|---|
MODE |
MODE | Either THRESHOLD, GRAY, INVERT, POSTERIZE, BLUR, OPAQUE, ERODE, or DILATE |
level |
int | float | defines the quality of the filter |
- Source:
- See:
frameRate(aRate)
Specifies the number of frames to be displayed every
second. If the processor is not fast enough to maintain
the specified rate, it will not be achieved. For
example, the function call frameRate(30) will attempt to
refresh 30 times a second. It is recommended to set the
frame rate within setup(). The default rate is 60 frames
per second.
Parameters:
Name | Type | Description |
---|---|---|
aRate |
int | number of frames per second. |
- Source:
- See:
-
- delay
Returns:
none
frustum(left, right, bottom, top, near, far)
Sets a perspective matrix defined through the
parameters. Works like glFrustum, except it wipes out
the current perspective matrix rather than muliplying
itself with it.
Parameters:
Name | Type | Description |
---|---|---|
left |
float | left coordinate of the clipping plane |
right |
float | right coordinate of the clipping plane |
bottom |
float | bottom coordinate of the clipping plane |
top |
float | top coordinate of the clipping plane |
near |
float | near coordinate of the clipping plane |
far |
float | far coordinate of the clipping plane |
- Source:
- See:
get(x, y, width, height) → {Color|PImage}
Reads the color of any pixel or grabs a section of an
image. If no parameters are specified, the entire image
is returned. Get the value of one pixel by specifying an
x,y coordinate. Get a section of the display window by
specifying an additional width and height parameter. If
the pixel requested is outside of the image window,
black is returned. The numbers returned are scaled
according to the current color ranges, but only RGB
values are returned by this function. For example, even
though you may have drawn a shape with colorMode(HSB),
the numbers returned will be in RGB. Getting the color
of a single pixel with get(x, y) is easy, but not as
fast as grabbing the data directly from pixels[]. The
equivalent statement to "get(x, y)" using pixels[] is
"pixels[y*width+x]". Processing requires calling
loadPixels() to load the display window data into the
pixels[] array before getting the values. This function
ignores imageMode().
Parameters:
Name | Type | Description |
---|---|---|
x |
int | x-coordinate of the pixel |
y |
int | y-coordinate of the pixel |
width |
int | width of pixel rectangle to get |
height |
int | height of pixel rectangle to get |
- Source:
- See:
Returns:
- Type
- Color | PImage
glyphLook(font, chr)
A lookup table for characters that can not be referenced
by Object
Parameters:
Name | Type | Description |
---|---|---|
font |
* | |
chr |
* |
- Source:
Returns:
green(aColor) → {float}
Extracts the green value from a color, scaled to match
current colorMode(). This value is always returned as a
float so be careful not to assign it to an int value.
Parameters:
Name | Type | Description |
---|---|---|
aColor |
color | any value of the color datatype |
- Source:
- See:
-
- red
- blue
- alpha
- >> right shift
- hue
- saturation
- brightness
Returns:
The green color value.
- Type
- float
HashMap(initialCapacity, loadFactor, m)
A HashMap stores a collection of objects, each
referenced by a key. This is similar to an Array, only
instead of accessing elements with a numeric index, a
String is used. (If you are familiar with associative
arrays from other languages, this is the same idea.)
Parameters:
Name | Type | Description |
---|---|---|
initialCapacity
|
int | defines the initial capacity of the map, it's 16 by default |
loadFactor |
float | the load factor for the map, the default is 0.75 |
m |
Map | gives the new HashMap the same mappings as this Map |
- Source:
hex(value, digits) → {String}
Converts a byte, char, int, or color to a String
containing the equivalent hexadecimal notation. For
example color(0, 102, 153, 255) will convert to the
String "FF006699". This function can help make your
geeky debugging sessions much happier.
Parameters:
Name | Type | Description |
---|---|---|
value |
byte | char | int | Color | the value to turn into a hex string |
digits |
int | the number of digits to return |
- Source:
- See:
Returns:
- Type
- String
hint(item)
Set various hints and hacks for the renderer. This is
used to handle obscure rendering features that cannot be
implemented in a consistent manner across renderers.
Many options will often graduate to standard features
instead of hints over time.
hint(ENABLE_OPENGL_4X_SMOOTH) - Enable 4x anti-aliasing
for OpenGL. This can help force anti-aliasing if it has
not been enabled by the user. On some graphics cards,
this can also be set by the graphics driver's control
panel, however not all cards make this available. This
hint must be called immediately after the size() command
because it resets the renderer, obliterating any
settings and anything drawn (and like size(), re-running
the code that came before it again).
hint(DISABLE_OPENGL_2X_SMOOTH) - In Processing 1.0,
Processing always enables 2x smoothing when the OpenGL
renderer is used. This hint disables the default 2x
smoothing and returns the smoothing behavior found in
earlier releases, where smooth() and noSmooth() could be
used to enable and disable smoothing, though the quality
was inferior. hint(ENABLE_NATIVE_FONTS) - Use the native
version fonts when they are installed, rather than the
bitmapped version from a .vlw file. This is useful with
the JAVA2D renderer setting, as it will improve font
rendering speed. This is not enabled by default, because
it can be misleading while testing because the type will
look great on your machine (because you have the font
installed) but lousy on others' machines if the
identical font is unavailable. This option can only be
set per-sketch, and must be called before any use of
textFont(). hint(DISABLE_DEPTH_TEST) - Disable the
zbuffer, allowing you to draw on top of everything at
will. When depth testing is disabled, items will be
drawn to the screen sequentially, like a painting. This
hint is most often used to draw in 3D, then draw in 2D
on top of it (for instance, to draw GUI controls in 2D
on top of a 3D interface). Starting in release 0149,
this will also clear the depth buffer. Restore the
default with hint(ENABLE_DEPTH_TEST), but note that with
the depth buffer cleared, any 3D drawing that happens
later in draw() will ignore existing shapes on the
screen. hint(ENABLE_DEPTH_SORT) - Enable primitive
z-sorting of triangles and lines in P3D and OPENGL. This
can slow performance considerably, and the algorithm is
not yet perfect. Restore the default with
hint(DISABLE_DEPTH_SORT).
hint(DISABLE_OPENGL_ERROR_REPORT) - Speeds up the OPENGL
renderer setting by not checking for errors while
running. Undo with hint(ENABLE_OPENGL_ERROR_REPORT). As
of release 0149, unhint() has been removed in favor of
adding additional ENABLE/DISABLE constants to reset the
default behavior. This prevents the double negatives,
and also reinforces which hints can be enabled or
disabled.
Parameters:
Name | Type | Description |
---|---|---|
item |
MODE | constant: name of the hint to be enabled or disabled |
- Source:
- See:
-
- PGraphics
- createGraphics
- size
hour() → {float}
Processing communicates with the clock on your computer.
The hour() function returns the current hour as a value
from 0 - 23.
Returns:
The current hour.
- Type
- float
hue(colInt) → {float}
Extracts the hue value from a color.
Parameters:
Name | Type | Description |
---|---|---|
colInt |
color | any value of the color datatype |
- Source:
- See:
Returns:
The hue color value.
- Type
- float
image(img, x, y, width, height)
Displays images to the screen. The images must be in the
sketch's "data" directory to load correctly. Select "Add
file..." from the "Sketch" menu to add the image.
Processing currently works with GIF, JPEG, and Targa
images. The color of an image may be modified with the
tint() function and if a GIF has transparency, it will
maintain its transparency. The img parameter specifies
the image to display and the x and y parameters define
the location of the image from its upper-left corner.
The image is displayed at its original size unless the
width and height parameters specify a different size.
The imageMode() function changes the way the parameters
work. A call to imageMode(CORNERS) will change the width
and height parameters to define the x and y values of
the opposite corner of the image.
Parameters:
Name | Type | Description |
---|---|---|
img |
PImage | the image to display |
x |
int | float | x-coordinate of the image |
y |
int | float | y-coordinate of the image |
width |
int | float | width to display the image |
height |
int | float | height to display the image |
- Source:
- See:
imageMode(MODE)
Modifies the location from which images draw. The
default mode is imageMode(CORNER), which specifies the
location to be the upper left corner and uses the fourth
and fifth parameters of image() to set the image's width
and height. The syntax imageMode(CORNERS) uses the
second and third parameters of image() to set the
location of one corner of the image and uses the fourth
and fifth parameters to set the opposite corner. Use
imageMode(CENTER) to draw images centered at the given x
and y position. The parameter to imageMode() must be
written in ALL CAPS because Processing is a case
sensitive language.
Parameters:
Name | Type | Description |
---|---|---|
MODE |
MODE | Either CORNER, CORNERS, or CENTER |
- Source:
- See:
initSphere()
The initSphere() function is a helper function used by
sphereDetail()
This function creates and stores sphere vertices every
time the user changes sphere detail.
- Source:
- See:
intersect(sx1, sy1, sx2, sy2, dx1, dy1, dx2, dy2)
Parameters:
Name | Type | Description |
---|---|---|
sx1 |
* | |
sy1 |
* | |
sx2 |
* | |
sy2 |
* | |
dx1 |
* | |
dy1 |
* | |
dx2 |
* | |
dy2 |
* |
- Source:
Returns:
Iterator()
Checks if the Iterator has more items
- Source:
Iterator()
Return the next Item
- Source:
Iterator()
Remove the current item
- Source:
join(array, separator) → {String}
Combines an array of Strings into one String, each
separated by the character(s) used for the separator
parameter. To join arrays of ints or floats, it's
necessary to first convert them to strings using nf() or
nfs().
Parameters:
Name | Type | Description |
---|---|---|
array |
Array | array of Strings |
separator |
char | String | char or String to be placed between each item |
Returns:
The combined string
- Type
- String
lerp(value1, value2, amt) → {float}
Calculates a number between two numbers at a specific
increment. The amt parameter is the amount to
interpolate between the two values where 0.0 equal to
the first point, 0.1 is very near the first point, 0.5
is half-way in between, etc. The lerp function is
convenient for creating motion along a straight path and
for drawing dotted lines.
Parameters:
Name | Type | Description |
---|---|---|
value1 |
int | float | float or int: first value |
value2 |
int | float | float or int: second value |
amt |
int | float | float: between 0.0 and 1.0 |
- Source:
- See:
Returns:
- Type
- float
lerpColor(c1, c2, amt) → {float}
Calculates a color or colors between two colors at a
specific increment. The amt parameter is the amount to
interpolate between the two values where 0.0 equal to
the first point, 0.1 is very near the first point, 0.5
is half-way in between, etc.
Parameters:
Name | Type | Description |
---|---|---|
c1 |
color | interpolate from this color |
c2 |
color | interpolate to this color |
amt |
float | between 0.0 and 1.0 |
- Source:
- See:
Returns:
The blended color.
- Type
- float
lights()
Sets the default ambient light, directional light,
falloff, and specular values. The defaults are
ambientLight(128, 128, 128) and directionalLight(128,
128, 128, 0, 0, -1), lightFalloff(1, 0, 0), and
lightSpecular(0, 0, 0). Lights need to be included in
the draw() to remain persistent in a looping program.
Placing them in the setup() of a looping program will
cause them to only have an effect the first time through
the loo
- Source:
- See:
Returns:
none
line(x1, y1, z1, x2, y2, z2)
Draws a line (a direct path between two points) to the
screen. The version of line() with four parameters draws
the line in 2D. To color a line, use the stroke()
function. A line cannot be filled, therefore the fill()
method will not affect the color of a line. 2D lines are
drawn with a width of one pixel by default, but this can
be changed with the strokeWeight() function. The version
with six parameters allows the line to be placed
anywhere within XYZ space. Drawing this shape in 3D
using the z parameter requires the P3D or OPENGL
parameter in combination with size.
Parameters:
Name | Type | Description |
---|---|---|
x1 |
int | float | x-coordinate of the first point |
y1 |
int | float | y-coordinate of the first point |
z1 |
int | float | z-coordinate of the first point |
x2 |
int | float | x-coordinate of the second point |
y2 |
int | float | y-coordinate of the second point |
z2 |
int | float | z-coordinate of the second point |
- Source:
- See:
link(href, target)
Links to a webpage either in the same window or in a new
window. The complete URL must be specified.
Parameters:
Name | Type | Description |
---|---|---|
href |
String | complete url as a String in quotes |
target |
String | name of the window to load the URL as a string in quotes |
- Source:
Returns:
none
loadBytes(filename) → {Array.<byte>}
Reads the contents of a file or url and places it in a
byte array. If a file is specified, it must be located
in the localStorage. The filename parameter can also be
a URL to a file found online.
Parameters:
Name | Type | Description |
---|---|---|
filename |
String | name of a file in the localStorage or a URL. |
- Source:
- See:
-
- loadStrings
- saveStrings
- saveBytes
Returns:
- Type
- Array.<byte>
loadFont(name, size) → {PFont}
loadFont() Loads a font into a variable of type PFont.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | filename of the font to load |
size |
int | float | option font size (used internally) |
- Source:
- See:
Returns:
new PFont object
- Type
- PFont
loadGlyphs(url)
Load Batik SVG Fonts and parse to pre-def objects for
quick rendering
Parameters:
Name | Type | Description |
---|---|---|
url |
* |
- Source:
loadImage(filename, extension) → {PImage}
Loads an image into a variable of type PImage. Four
types of images ( .gif, .jpg, .tga, .png) images may be
loaded. To load correctly, images must be located in the
data directory of the current sketch. In most cases,
load all images in setup() to preload them at the start
of the program. Loading images inside draw() will reduce
the speed of a program. The filename parameter can also
be a URL to a file found online. For security reasons, a
Processing sketch found online can only download files
from the same server from which it came. Getting around
this restriction requires a signed applet. The extension
parameter is used to determine the image type in cases
where the image filename does not end with a proper
extension. Specify the extension as the second parameter
to loadImage(), as shown in the third example on this
page. If an image is not loaded successfully, the null
value is returned and an error message will be printed
to the console. The error message does not halt the
program, however the null value may cause a
NullPointerException if your code does not check whether
the value returned from loadImage() is null. Depending
on the type of error, a PImage object may still be
returned, but the width and height of the image will be
set to -1. This happens if bad image data is returned or
cannot be decoded properly. Sometimes this happens with
image URLs that produce a 403 error or that redirect to
a password prompt, because loadImage() will attempt to
interpret the HTML as image data.
Parameters:
Name | Type | Description |
---|---|---|
filename |
String | name of file to load, can be .gif, .jpg, .tga, or a handful of other image types depending on your platform. |
extension |
String | the type of image to load, for example "png", "gif", "jpg" |
- Source:
- See:
Returns:
- Type
- PImage
loadPixels()
Loads the pixel data for the display window into the
pixels[] array. This function must always be called
before reading from or writing to pixels[]. Certain
renderers may or may not seem to require loadPixels() or
updatePixels(). However, the rule is that any time you
want to manipulate the pixels[] array, you must first
call loadPixels(), and after changes have been made,
call updatePixels(). Even if the renderer may not seem
to use this function in the current Processing release,
this will always be subject to change.
- Source:
- See:
-
- pixels[]
- updatePixels
loadShape(filename) → {PShape}
The loadShape() function loads vector shapes into a
variable of type PShape. Currently, only SVG files may
be loaded. In most cases, loadShape() should be
used inside setup() because loading shapes inside
draw() will reduce the speed of a sketch.
Parameters:
Name | Type | Description |
---|---|---|
filename |
String | an SVG file |
- Source:
- See:
-
- PShape
- PApplet#shape()
- PApplet#shapeMode()
Returns:
a object of type PShape or null
- Type
- PShape
loadStrings(filename) → {Array.<String>}
Reads the contents of a file or url and creates a String
array of its individual lines. The filename parameter
can also be a URL to a file found online. If the file is
not available or an error occurs, null will be returned
and an error message will be printed to the console. The
error message does not halt the program.
Parameters:
Name | Type | Description |
---|---|---|
filename |
String | name of the file or url to load |
- Source:
- See:
-
- loadBytes
- saveStrings
- saveBytes
Returns:
- Type
- Array.<String>
loop()
Causes Processing to continuously execute the code
within draw(). If noLoop() is called, the code in draw()
stops executing.
- Source:
- See:
Returns:
none
mag(a, b, c) → {float}
Calculates the magnitude (or length) of a vector. A
vector is a direction in space commonly used in computer
graphics and linear algebra. Because it has no "start"
position, the magnitude of a vector can be thought of as
the distance from coordinate (0,0) to its (x,y) value.
Therefore, mag() is a shortcut for writing "dist(0, 0,
x, y)".
Parameters:
Name | Type | Description |
---|---|---|
a |
int | float | float or int: first value |
b |
int | float | float or int: second value |
c |
int | float | float or int: third value |
- Source:
- See:
Returns:
- Type
- float
map(value, istart, istop, ostart, ostop) → {float}
Re-maps a number from one range to another. In the
example above, the number '25' is converted from a value
in the range 0..100 into a value that ranges from the
left edge (0) to the right edge (width) of the screen.
Numbers outside the range are not clamped to 0 and 1,
because out-of-range values are often intentional and
useful.
Parameters:
Name | Type | Description |
---|---|---|
value |
float | The incoming value to be converted |
istart |
float | Lower bound of the value's current range |
istop |
float | Upper bound of the value's current range |
ostart |
float | Lower bound of the value's target range |
ostop |
float | Upper bound of the value's target range |
- Source:
- See:
Returns:
- Type
- float
match(str, regexp) → {Array.<String>}
The match() function matches a string with a regular
expression, and returns the match as an array. The first
index is the matching expression, and array elements [1]
and higher represent each of the groups (sequences found
in parens).
Parameters:
Name | Type | Description |
---|---|---|
str |
String | the String to be searched |
regexp |
String | the regexp to be used for matching |
- Source:
Returns:
an array of matching strings
- Type
- Array.<String>
matchAll(aString, aRegExp) → {Array.<String>}
The matchAll() function is identical to match(), except
that it returns an array of all matches in the specified
String, rather than just the first.
Parameters:
Name | Type | Description |
---|---|---|
aString |
String | the String to search inside |
aRegExp |
String | the regexp to be used for matching |
- Source:
- See:
Returns:
returns an array of matches
- Type
- Array.<String>
max(value1, value2, value3, array) → {int|float}
Determines the largest value in a sequence of numbers.
Parameters:
Name | Type | Description |
---|---|---|
value1 |
int | float | int or float |
value2 |
int | float | int or float |
value3 |
int | float | int or float |
array |
int | float | int or float array |
- Source:
- See:
Returns:
- Type
- int | float
millis() → {long}
Returns the number of milliseconds (thousandths of a
second) since starting a sketch. This information is
often used for timing animation sequences.
Returns:
The number of milliseconds since starting the sketch.
- Type
- long
min(value1, value2, value3, array) → {int|float}
Determines the smallest value in a sequence of numbers.
Parameters:
Name | Type | Description |
---|---|---|
value1 |
int | float | int or float |
value2 |
int | float | int or float |
value3 |
int | float | int or float |
array |
int | float | int or float array |
- Source:
- See:
Returns:
- Type
- int | float
minute() → {float}
Processing communicates with the clock on your computer.
The minute() function returns the current minute as a
value from 0 - 59.
Returns:
The current minute.
- Type
- float
mix(a, b, f)
Helper function for internal blending modes
Parameters:
Name | Type | Description |
---|---|---|
a |
* | |
b |
* | |
f |
* |
- Source:
modelX(x, y, z) → {float}
Returns the three-dimensional X, Y, Z position in model
space. This returns the X value for a given coordinate
based on the current set of transformations (scale,
rotate, translate, etc.) The X value can be used to
place an object in space relative to the location of the
original point once the transformations are no longer in
use.
Parameters:
Name | Type | Description |
---|---|---|
x |
int | float | 3D x coordinate to be mapped |
y |
int | float | 3D y coordinate to be mapped |
z |
int | float | 3D z coordinate to be mapped |
- Source:
- See:
Returns:
- Type
- float
modelY(x, y, z) → {float}
Returns the three-dimensional X, Y, Z position in model
space. This returns the Y value for a given coordinate
based on the current set of transformations (scale,
rotate, translate, etc.) The Y value can be used to
place an object in space relative to the location of the
original point once the transformations are no longer in
use.
Parameters:
Name | Type | Description |
---|---|---|
x |
int | float | 3D x coordinate to be mapped |
y |
int | float | 3D y coordinate to be mapped |
z |
int | float | 3D z coordinate to be mapped |
- Source:
- See:
Returns:
- Type
- float
modelZ(x, y, z) → {float}
Returns the three-dimensional X, Y, Z position in model
space. This returns the Z value for a given coordinate
based on the current set of transformations (scale,
rotate, translate, etc.) The Z value can be used to
place an object in space relative to the location of the
original point once the transformations are no longer in
use.
Parameters:
Name | Type | Description |
---|---|---|
x |
int | float | 3D x coordinate to be mapped |
y |
int | float | 3D y coordinate to be mapped |
z |
int | float | 3D z coordinate to be mapped |
- Source:
- See:
Returns:
- Type
- float
month() → {float}
Processing communicates with the clock on your computer.
The month() function returns the current month as a
value from 1 - 12.
Returns:
The current month.
- Type
- float
nf(value, left, right)
Utility function for formatting numbers into strings.
There are two versions, one for formatting floats and
one for formatting ints. The values for the digits,
left, and right parameters should always be positive
integers. As shown in the above example, nf() is used to
add zeros to the left and/or right of a number. This is
typically for aligning a list of numbers. To remove
digits from a floating-point number, use the int(),
ceil(), floor(), or round() functions.
Parameters:
Name | Type | Description |
---|---|---|
value |
int | Array.<int> | float | Array.<float> | the number(s) to format |
left |
int | number of digits to the left of the decimal point |
right |
int | number of digits to the right of the decimal point |
- Source:
- See:
Returns:
nfc(value, left, right)
Utility function for formatting numbers into strings and
placing appropriate commas to mark units of 1000. There
are two versions, one for formatting ints and one for
formatting an array of ints. The value for the digits
parameter should always be a positive integer.
Parameters:
Name | Type | Description |
---|---|---|
value |
int | Array.<int> | float | Array.<float> | the number(s) to format |
left |
int | number of digits to the left of the decimal point |
right |
int | number of digits to the right of the decimal point |
- Source:
- See:
Returns:
nfp(value, left, right)
Utility function for formatting numbers into strings.
Similar to nf() but puts a "+" in front of positive
numbers and a "-" in front of negative numbers. There
are two versions, one for formatting floats and one for
formatting ints. The values for the digits, left, and
right parameters should always be positive integers.
Parameters:
Name | Type | Description |
---|---|---|
value |
int | Array.<int> | float | Array.<float> | the number(s) to format |
left |
int | number of digits to the left of the decimal point |
right |
int | number of digits to the right of the decimal point |
- Source:
- See:
Returns:
nfs(value, left, right)
Utility function for formatting numbers into strings.
Similar to nf() but leaves a blank space in front of
positive numbers so they align with negative numbers in
spite of the minus symbol. There are two versions, one
for formatting floats and one for formatting ints. The
values for the digits, left, and right parameters should
always be positive integers.
Parameters:
Name | Type | Description |
---|---|---|
value |
int | Array.<int> | float | Array.<float> | the number(s) to format |
left |
int | number of digits to the left of the decimal point |
right |
int | number of digits to the right of the decimal point |
- Source:
- See:
Returns:
noCursor()
Hides the cursor from view.
- Source:
- See:
Returns:
none
noFill()
The noFill() function disables filling geometry. If both
noStroke() and noFill()
are called, no shapes will be drawn to the screen.
- Source:
- See:
noise(x, y, z) → {float}
Returns the Perlin noise value at specified coordinates.
Perlin noise is a random sequence generator producing a
more natural ordered, harmonic succession of numbers
compared to the standard random() function. It was
invented by Ken Perlin in the 1980s and been used since
in graphical applications to produce procedural
textures, natural motion, shapes, terrains etc. The main
difference to the random() function is that Perlin noise
is defined in an infinite n-dimensional space where each
pair of coordinates corresponds to a fixed semi-random
value (fixed only for the lifespan of the program). The
resulting value will always be between 0.0 and 1.0.
Processing can compute 1D, 2D and 3D noise, depending on
the number of coordinates given. The noise value can be
animated by moving through the noise space as
demonstrated in the example above. The 2nd and 3rd
dimension can also be interpreted as time. The actual
noise is structured similar to an audio signal, in
respect to the function's use of frequencies. Similar to
the concept of harmonics in physics, perlin noise is
computed over several octaves which are added together
for the final result. Another way to adjust the
character of the resulting sequence is the scale of the
input coordinates. As the function works within an
infinite space the value of the coordinates doesn't
matter as such, only the distance between successive
coordinates does (eg. when using noise() within a loop).
As a general rule the smaller the difference between
coordinates, the smoother the resulting noise sequence
will be. Steps of 0.005-0.03 work best for most
applications, but this will differ depending on use.
Parameters:
Name | Type | Description |
---|---|---|
x |
float | x coordinate in noise space |
y |
float | y coordinate in noise space |
z |
float | z coordinate in noise space |
- Source:
- See:
Returns:
- Type
- float
noiseDetail(octaves, falloff)
Adjusts the character and level of detail produced by
the Perlin noise function. Similar to harmonics in
physics, noise is computed over several octaves. Lower
octaves contribute more to the output signal and as such
define the overal intensity of the noise, whereas higher
octaves create finer grained details in the noise
sequence. By default, noise is computed over 4 octaves
with each octave contributing exactly half than its
predecessor, starting at 50% strength for the 1st
octave. This falloff amount can be changed by adding an
additional function parameter. Eg. a falloff factor of
0.75 means each octave will now have 75% impact (25%
less) of the previous lower octave. Any value between
0.0 and 1.0 is valid, however note that values greater
than 0.5 might result in greater than 1.0 values
returned by noise(). By changing these parameters, the
signal created by the noise() function can be adapted to
fit very specific needs and characteristics.
Parameters:
Name | Type | Description |
---|---|---|
octaves |
int | number of octaves to be used by the noise() function |
falloff |
float | falloff factor for each octave |
- Source:
- See:
noiseSeed(seed) → {float}
Sets the seed value for noise(). By default, noise()
produces different results each time the program is run.
Set the value parameter to a constant to return the same
pseudo-random numbers each time the software is run.
Parameters:
Name | Type | Description |
---|---|---|
seed |
int | int |
- Source:
- See:
-
- random
- radomSeed
- noise
- noiseDetail
Returns:
- Type
- float
noLoop()
Stops Processing from continuously executing the code
within draw(). If loop() is called, the code in draw()
begin to run continuously again. If using noLoop() in
setup(), it should be the last line inside the block.
When noLoop() is used, it's not possible to manipulate
or access the screen inside event handling functions
such as mousePressed() or keyPressed(). Instead, use
those functions to call redraw() or loop(), which will
run draw(), which can update the screen properly. This
means that when noLoop() has been called, no drawing can
happen, and functions like saveFrame() or loadPixels()
may not be used. Note that if the sketch is resized,
redraw() will be called to update the sketch, even after
noLoop() has been specified. Otherwise, the sketch would
enter an odd state until loop() was called.
- Source:
- See:
Returns:
none
norm(aNumber, low, high) → {float}
Normalizes a number from another range into a value
between 0 and 1. Identical to map(value, low, high, 0,
1); Numbers outside the range are not clamped to 0 and
1, because out-of-range values are often intentional and
useful.
Parameters:
Name | Type | Description |
---|---|---|
aNumber |
float | The incoming value to be converted |
low |
float | Lower bound of the value's current range |
high |
float | Upper bound of the value's current range |
- Source:
- See:
Returns:
- Type
- float
normal(nx, ny, nz)
Sets the current normal vector. This is for drawing
three dimensional shapes and surfaces and specifies a
vector perpendicular to the surface of the shape which
determines how lighting affects it. Processing attempts
to automatically assign normals to shapes, but since
that's imperfect, this is a better option when you want
more control. This function is identical to glNormal3f()
in OpenGL.
Parameters:
Name | Type | Description |
---|---|---|
nx |
float | x direction |
ny |
float | y direction |
nz |
float | z direction |
- Source:
- See:
noSmooth()
The noSmooth() function draws all geometry with jagged
(aliased) edges.
- Source:
- See:
noStroke()
The noStroke() function disables drawing the stroke
(outline). If both noStroke() and
noFill() are called, no shapes will be drawn to
the screen.
- Source:
- See:
noTint()
The noTint() function removes the current fill value for
displaying images and reverts to displaying images with
their original hues.
- Source:
- See:
ObjectIterator(obj)
A ObjectIterator is an iterator wrapper for objects. If
passed object contains the iterator method, the object
instance will be replaced by the result returned by this
method call. If passed object is an array, the
ObjectIterator instance iterates through its items.
Parameters:
Name | Type | Description |
---|---|---|
obj |
Object | The object to be iterated. |
- Source:
ortho(left, right, bottom, top, near, far)
Sets an orthographic projection and defines a parallel
clipping volume. All objects with the same dimension
appear the same size, regardless of whether they are
near or far from the camera. The parameters to this
function specify the clipping volume where left and
right are the minimum and maximum x values, top and
bottom are the minimum and maximum y values, and near
and far are the minimum and maximum z values. If no
parameters are given, the default is used: ortho(0,
width, 0, height, -10, 10).
Parameters:
Name | Type | Description |
---|---|---|
left |
float | left plane of the clipping volume |
right |
float | right plane of the clipping volume |
bottom |
float | bottom plane of the clipping volume |
top |
float | top plane of the clipping volume |
near |
float | maximum distance from the origin to the viewer |
far |
float | maximum distance from the origin away from the viewer |
- Source:
param(name) → {String}
Gets the sketch parameter value. The parameter can be
defined as the canvas attribute with the
"data-processing-" prefix or provided in the pjs
directive (e.g. param-test="52"). The function tries the
canvas attributes, then the pjs directive content.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | The name of the param to read. |
- Source:
Returns:
The parameter value, or null if parameter is not
defined.
- Type
- String
parseBoolean(val) → {boolean|Array.<boolean>}
Converts the passed parameter to the function to its
boolean value. It will return an array of booleans if an
array is passed in.
Parameters:
Name | Type | Description |
---|---|---|
val |
||
|
- Source:
Returns:
returns a boolean or an array of booleans
- Type
- boolean | Array.<boolean>
parseByte(what) → {byte|Array.<byte>}
Converts the passed parameter to the function to its
byte value. A byte is a number between -128 and 127. It
will return an array of bytes if an array is passed in.
Parameters:
Name | Type | Description |
---|---|---|
what |
||
|
- Source:
Returns:
returns a byte or an array of bytes
- Type
- byte | Array.<byte>
parseChar(key) → {char|Array.<char>}
Converts the passed parameter to the function to its
char value. It will return an array of chars if an array
is passed in.
Parameters:
Name | Type | Description |
---|---|---|
key |
||
|
- Source:
Returns:
returns a char or an array of chars
- Type
- char | Array.<char>
parseFloat(val) → {float|Array.<float>}
Converts the passed parameter to the function to its
float value. It will return an array of floats if an
array is passed in.
Parameters:
Name | Type | Description |
---|---|---|
val |
||
|
- Source:
Returns:
returns a float or an array of floats
- Type
- float | Array.<float>
parseInt(val, radix, radix) → {int|Array.<int>}
Converts the passed parameter to the function to its int
value. It will return an array of ints if an array is
passed in.
Parameters:
Name | Type | Description |
---|---|---|
val |
||
radix |
||
radix |
int | optional the radix of the number (for js compatibility) |
- Source:
Returns:
returns a int or an array of ints
- Type
- int | Array.<int>
peg(n)
Helper function for internal blending modes
Parameters:
Name | Type | Description |
---|---|---|
n |
* |
- Source:
perspective(fov, aspect, zNear, zFar)
Sets a perspective projection applying foreshortening,
making distant objects appear smaller than closer ones.
The parameters define a viewing volume with the shape of
truncated pyramid. Objects near to the front of the
volume appear their actual size, while farther objects
appear smaller. This projection simulates the
perspective of the world more accurately than
orthographic projection. The version of perspective
without parameters sets the default perspective and the
version with four parameters allows the programmer to
set the area precisely. The default values are:
perspective(PI/3.0, width/height, cameraZ/10.0,
cameraZ*10.0) where cameraZ is ((height/2.0) /
tan(PI*60.0/360.0));
Parameters:
Name | Type | Description |
---|---|---|
fov |
float | field-of-view angle (in radians) for vertical direction |
aspect |
float | ratio of width to height |
zNear |
float | z-position of nearest clipping plane |
zFar |
float | z-positions of farthest clipping plane |
- Source:
PFont(name, size)
Defines system (non-SVG) font.
Parameters:
Name | Type | Description |
---|---|---|
name |
* | |
size |
* |
- Source:
PImage(width, height, format) → {PImage}
Datatype for storing images. Processing can display
.gif, .jpg, .tga, and .png images. Images may be
displayed in 2D and 3D space. Before an image is used,
it must be loaded with the loadImage() function. The
PImage object contains fields for the width and height
of the image, as well as an array called pixels[] which
contains the values for every pixel in the image. A
group of methods, described below, allow easy access to
the image's pixels and alpha channel and simplify the
process of compositing. Before using the pixels[] array,
be sure to use the loadPixels() method on the image to
make sure that the pixel data is properly loaded. To
create a new image, use the createImage() function (do
not use new PImage()).
Parameters:
Name | Type | Description |
---|---|---|
width |
int | image width |
height |
int | image height |
format |
MODE | Either RGB, ARGB, ALPHA (grayscale alpha channel) |
- Source:
- See:
Returns:
- Type
- PImage
PImage()
Updates the image with the data in its pixels[] array.
Use in conjunction with loadPixels(). If you're only
reading pixels from the array, there's no need to call
updatePixels(). Certain renderers may or may not seem to
require loadPixels() or updatePixels(). However, the
rule is that any time you want to manipulate the
pixels[] array, you must first call loadPixels(), and
after changes have been made, call updatePixels(). Even
if the renderer may not seem to use this function in the
current Processing release, this will always be subject
to change. Currently, none of the renderers use the
additional parameters to updatePixels().
- Source:
PImage(x, y, color)
Changes the color of any pixel or writes an image
directly into the image. The x and y parameter specify
the pixel or the upper-left corner of the image. The
color parameter specifies the color value. Setting the
color of a single pixel with set(x, y) is easy, but not
as fast as putting the data directly into pixels[]. The
equivalent statement to "set(x, y, #000000)" using
pixels[] is "pixels[y*width+x] = #000000". Processing
requires calling loadPixels() to load the display window
data into the pixels[] array before getting the values
and calling updatePixels() to update the window.
Parameters:
Name | Type | Description |
---|---|---|
x |
int | x-coordinate of the pixel or upper-left corner of the image |
y |
int | y-coordinate of the pixel or upper-left corner of the image |
color |
color | any value of the color datatype |
- Source:
- See:
PImage(x, y, width, height, dx, dy, dwidth, dheight, srcImg, MODE)
Blends a region of pixels into the image specified by
the img parameter. These copies utilize full alpha
channel support and a choice of the following modes to
blend the colors of source pixels (A) with the ones of
pixels in the destination image (B): BLEND - linear
interpolation of colours: C = A*factor + B ADD -
additive blending with white clip: C = min(A*factor + B,
255) SUBTRACT - subtractive blending with black clip: C
= max(B - A*factor, 0) DARKEST - only the darkest colour
succeeds: C = min(A*factor, B) LIGHTEST - only the
lightest colour succeeds: C = max(A*factor, B)
DIFFERENCE - subtract colors from underlying image.
EXCLUSION - similar to DIFFERENCE, but less extreme.
MULTIPLY - Multiply the colors, result will always be
darker. SCREEN - Opposite multiply, uses inverse values
of the colors. OVERLAY - A mix of MULTIPLY and SCREEN.
Multiplies dark values, and screens light values.
HARD_LIGHT - SCREEN when greater than 50% gray, MULTIPLY
when lower. SOFT_LIGHT - Mix of DARKEST and LIGHTEST.
Works like OVERLAY, but not as harsh. DODGE - Lightens
light tones and increases contrast, ignores darks.
Called "Color Dodge" in Illustrator and Photosho BURN -
Darker areas are applied, increasing contrast, ignores
lights. Called "Color Burn" in Illustrator and Photosho
All modes use the alpha information (highest byte) of
source image pixels as the blending factor. If the
source and destination regions are different sizes, the
image will be automatically resized to match the
destination size. If the srcImg parameter is not used,
the display window is used as the source image. This
function ignores imageMode().
Parameters:
Name | Type | Description |
---|---|---|
x |
int | X coordinate of the source's upper left corner |
y |
int | Y coordinate of the source's upper left corner |
width |
int | source image width |
height |
int | source image height |
dx |
int | X coordinate of the destinations's upper left corner |
dy |
int | Y coordinate of the destinations's upper left corner |
dwidth |
int | destination image width |
dheight |
int | destination image height |
srcImg |
PImage | an image variable referring to the source image |
MODE |
MODE | Either BLEND, ADD, SUBTRACT, LIGHTEST, DARKEST, DIFFERENCE, EXCLUSION, MULTIPLY, SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, BURN |
- Source:
- See:
PImage(sx, sy, swidth, sheight, dx, dy, dwidth, dheight, srcImg)
Copies a region of pixels from one image into another.
If the source and destination regions aren't the same
size, it will automatically resize source pixels to fit
the specified target region. No alpha information is
used in the process, however if the source image has an
alpha channel set, it will be copied as well. This
function ignores imageMode().
Parameters:
Name | Type | Description |
---|---|---|
sx |
int | X coordinate of the source's upper left corner |
sy |
int | Y coordinate of the source's upper left corner |
swidth |
int | source image width |
sheight |
int | source image height |
dx |
int | X coordinate of the destinations's upper left corner |
dy |
int | Y coordinate of the destinations's upper left corner |
dwidth |
int | destination image width |
dheight |
int | destination image height |
srcImg |
PImage | an image variable referring to the source image |
- Source:
- See:
PImage(MODE, param)
Filters an image as defined by one of the following
modes: THRESHOLD - converts the image to black and white
pixels depending if they are above or below the
threshold defined by the level parameter. The level must
be between 0.0 (black) and 1.0(white). If no level is
specified, 0.5 is used. GRAY - converts any colors in
the image to grayscale equivalents INVERT - sets each
pixel to its inverse value POSTERIZE - limits each
channel of the image to the number of colors specified
as the level parameter BLUR - executes a Guassian blur
with the level parameter specifying the extent of the
blurring. If no level parameter is used, the blur is
equivalent to Guassian blur of radius 1. OPAQUE - sets
the alpha channel to entirely opaque. ERODE - reduces
the light areas with the amount defined by the level
parameter. DILATE - increases the light areas with the
amount defined by the level parameter
Parameters:
Name | Type | Description |
---|---|---|
MODE |
MODE | Either THRESHOLD, GRAY, INVERT, POSTERIZE, BLUR, OPAQUE, ERODE, or DILATE |
param |
int | float | in the range from 0 to 1 |
- Source:
PImage(filename)
Saves the image into a file. Images are saved in TIFF,
TARGA, JPEG, and PNG format depending on the extension
within the filename parameter. For example, "image.tif"
will have a TIFF image and "image.png" will save a PNG
image. If no extension is included in the filename, the
image will save in TIFF format and .tif will be added to
the name. These files are saved to the sketch's folder,
which may be opened by selecting "Show sketch folder"
from the "Sketch" menu. It is not possible to use save()
while running the program in a web browser. To save an
image created within the code, rather than through
loading, it's necessary to make the image with the
createImage() function so it is aware of the location of
the program and can therefore save the file to the right
place. See the createImage() reference for more
information.
Parameters:
Name | Type | Description |
---|---|---|
filename |
String | a sequence of letters and numbers |
- Source:
PImage(wide, high)
Resize the image to a new width and height. To make the
image scale proportionally, use 0 as the value for the
wide or high parameter.
Parameters:
Name | Type | Description |
---|---|---|
wide |
int | the resized image width |
high |
int | the resized image height |
- Source:
- See:
PImage(maskImg, maskArray)
Masks part of an image from displaying by loading
another image and using it as an alpha channel. This
mask image should only contain grayscale data, but only
the blue color channel is used. The mask image needs to
be the same size as the image to which it is applied. In
addition to using a mask image, an integer array
containing the alpha channel data can be specified
directly. This method is useful for creating dynamically
generated alpha masks. This array must be of the same
length as the target image's pixels array and should
contain only grayscale data of values between 0-255.
Parameters:
Name | Type | Description |
---|---|---|
maskImg |
PImage | any PImage object used as the alpha channel for "img", needs to be same size as "img" |
maskArray |
Array.<int> | any array of Integer numbers used as the alpha channel, needs to be same length as the image's pixel array |
- Source:
PImage()
Loads the pixel data for the image into its pixels[]
array. This function must always be called before
reading from or writing to pixels[]. Certain renderers
may or may not seem to require loadPixels() or
updatePixels(). However, the rule is that any time you
want to manipulate the pixels[] array, you must first
call loadPixels(), and after changes have been made,
call updatePixels(). Even if the renderer may not seem
to use this function in the current Processing release,
this will always be subject to change.
- Source:
PMatrix2D(matrix, m00, m01, m02, m10, m11, m12)
PMatrix2D is a 3x2 affine matrix implementation. The
constructor accepts another PMatrix2D or a list of six
float elements. If no parameters are provided the matrix
is set to the identity matrix.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
PMatrix2D | the initial matrix to set to |
m00 |
float | the first element of the matrix |
m01 |
float | the second element of the matrix |
m02 |
float | the third element of the matrix |
m10 |
float | the fourth element of the matrix |
m11 |
float | the fifth element of the matrix |
m12 |
float | the sixth element of the matrix |
- Source:
PMatrix2D(matrix, elements, m00, m01, m10, m11, m12)
The set() function sets the matrix elements. The
function accepts either another PMatrix2D, an array of
elements, or a list of six floats.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
PMatrix2D | the matrix to set this matrix to |
elements |
Array.<float> | an array of elements to set this matrix to |
m00 |
float | the first element of the matrix |
m01 |
float | the third element of the matrix |
m10 |
float | the fourth element of the matrix |
m11 |
float | the fith element of the matrix |
m12 |
float | the sixth element of the matrix |
- Source:
PMatrix2D() → {PMatrix2D}
The get() function returns a copy of this PMatrix2D.
- Source:
Returns:
a copy of this PMatrix2D
- Type
- PMatrix2D
PMatrix2D()
The reset() function sets this PMatrix2D to the identity
matrix.
- Source:
PMatrix2D() → {Array.<float>}
The array() function returns a copy of the element
values.
- Source:
Returns:
returns a copy of the element values
- Type
- Array.<float>
PMatrix2D(tx, ty)
The translate() function translates this matrix by
moving the current coordinates to the location specified
by tx and ty.
Parameters:
Name | Type | Description |
---|---|---|
tx |
float | the x-axis coordinate to move to |
ty |
float | the y-axis coordinate to move to |
- Source:
PMatrix2D(tx, ty)
The invTranslate() function translates this matrix by
moving the current coordinates to the negative location
specified by tx and ty.
Parameters:
Name | Type | Description |
---|---|---|
tx |
float | the x-axis coordinate to move to |
ty |
float | the y-axis coordinate to move to |
- Source:
PMatrix2D()
The transpose() function is not used in processingjs.
- Source:
PMatrix2D(source,, source,) → {PVector|Array.<float>}
The mult() function multiplied this matrix. If two array
elements are passed in the function will multiply a two
element vector against this matrix. If target is null or
not length four, a new float array will be returned. The
values for vec and target can be the same (though that's
less efficient). If two PVectors are passed in the
function multiply the x and y coordinates of a PVector
against this matrix.
Parameters:
Name | Type | Description |
---|---|---|
source, |
PVector | target the PVectors used to multiply this matrix |
source, |
Array.<float> | target the arrays used to multiply this matrix |
- Source:
Returns:
returns a PVector or an array representing the new
matrix
- Type
- PVector | Array.<float>
PMatrix2D(x, y) → {float}
The multX() function calculates the x component of a
vector from a transformation.
Parameters:
Name | Type | Description |
---|---|---|
x |
float | the x component of the vector being transformed |
y |
float | the y component of the vector being transformed |
- Source:
Returns:
returnes the result of the calculation
- Type
- float
PMatrix2D(x, y) → {float}
The multY() function calculates the y component of a
vector from a transformation.
Parameters:
Name | Type | Description |
---|---|---|
x |
float | the x component of the vector being transformed |
y |
float | the y component of the vector being transformed |
- Source:
Returns:
returnes the result of the calculation
- Type
- float
PMatrix2D(angle)
The skewX() function skews the matrix along the x-axis
the amount specified by the angle parameter. Angles
should be specified in radians (values from 0 to PI*2)
or converted to radians with the
radians() function.
Parameters:
Name | Type | Description |
---|---|---|
angle |
float | angle of skew specified in radians |
- Source:
PMatrix2D(angle)
The skewY() function skews the matrix along the y-axis
the amount specified by the angle parameter. Angles
should be specified in radians (values from 0 to PI*2)
or converted to radians with the
radians() function.
Parameters:
Name | Type | Description |
---|---|---|
angle |
float | angle of skew specified in radians |
- Source:
PMatrix2D() → {float}
The determinant() function calvculates the determinant
of this matrix.
- Source:
Returns:
the determinant of the matrix
- Type
- float
PMatrix2D() → {boolean}
The invert() function inverts this matrix
- Source:
Returns:
true if successful
- Type
- boolean
PMatrix2D(sx, sy)
The scale() function increases or decreases the size of
a shape by expanding and contracting vertices. When only
one parameter is specified scale will occur in all
dimensions. This is equivalent to a two parameter call.
Parameters:
Name | Type | Description |
---|---|---|
sx |
float | the amount to scale on the x-axis |
sy |
float | the amount to scale on the y-axis |
- Source:
PMatrix2D(sx, sy)
The invScale() function decreases or increases the size
of a shape by contracting and expanding vertices. When
only one parameter is specified scale will occur in all
dimensions. This is equivalent to a two parameter call.
Parameters:
Name | Type | Description |
---|---|---|
sx |
float | the amount to scale on the x-axis |
sy |
float | the amount to scale on the y-axis |
- Source:
PMatrix2D(matrix, m00, m01, m10, m11, m12)
The apply() function multiplies the current matrix by
the one specified through the parameters. Note that
either a PMatrix2D or a list of floats can be passed in.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
PMatrix2D | the matrix to apply this matrix to |
m00 |
float | the first element of the matrix |
m01 |
float | the third element of the matrix |
m10 |
float | the fourth element of the matrix |
m11 |
float | the fith element of the matrix |
m12 |
float | the sixth element of the matrix |
- Source:
PMatrix2D(matrix, m00, m01, m10, m11, m12)
The preApply() function applies another matrix to the
left of this one. Note that either a PMatrix2D or
elements of a matrix can be passed in.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
PMatrix2D | the matrix to apply this matrix to |
m00 |
float | the first element of the matrix |
m01 |
float | the third element of the matrix |
m10 |
float | the fourth element of the matrix |
m11 |
float | the fith element of the matrix |
m12 |
float | the sixth element of the matrix |
- Source:
PMatrix2D(angle)
The rotate() function rotates the matrix.
Parameters:
Name | Type | Description |
---|---|---|
angle |
float | the angle of rotation in radiants |
- Source:
PMatrix2D(angle)
The rotateZ() function rotates the matrix.
Parameters:
Name | Type | Description |
---|---|---|
angle |
float | the angle of rotation in radiants |
- Source:
PMatrix2D(angle)
The invRotateZ() function rotates the matrix in opposite
direction.
Parameters:
Name | Type | Description |
---|---|---|
angle |
float | the angle of rotation in radiants |
- Source:
PMatrix2D()
The print() function prints out the elements of this
matrix
- Source:
PMatrix2D(matrix, elements, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33)
The set() function sets the matrix elements. The
function accepts either another PMatrix3D, an array of
elements, or a list of six or sixteen floats.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
PMatrix3D | the initial matrix to set to |
elements |
Array.<float> | an array of elements to set this matrix to |
m00 |
float | the first element of the matrix |
m01 |
float | the second element of the matrix |
m02 |
float | the third element of the matrix |
m03 |
float | the fourth element of the matrix |
m10 |
float | the fifth element of the matrix |
m11 |
float | the sixth element of the matrix |
m12 |
float | the seventh element of the matrix |
m13 |
float | the eight element of the matrix |
m20 |
float | the nineth element of the matrix |
m21 |
float | the tenth element of the matrix |
m22 |
float | the eleventh element of the matrix |
m23 |
float | the twelveth element of the matrix |
m30 |
float | the thirteenth element of the matrix |
m31 |
float | the fourtheenth element of the matrix |
m32 |
float | the fivetheenth element of the matrix |
m33 |
float | the sixteenth element of the matrix |
- Source:
PMatrix3D()
PMatrix3D is a 4x4 matrix implementation. The
constructor accepts another PMatrix3D or a list of six
or sixteen float elements. If no parameters are provided
the matrix is set to the identity matrix.
- Source:
PMatrix3D() → {PMatrix3D}
The get() function returns a copy of this PMatrix3D.
- Source:
Returns:
a copy of this PMatrix3D
- Type
- PMatrix3D
PMatrix3D()
The reset() function sets this PMatrix3D to the identity
matrix.
- Source:
PMatrix3D() → {Array.<float>}
The array() function returns a copy of the element
values.
- Source:
Returns:
returns a copy of the element values
- Type
- Array.<float>
PMatrix3D(tx, ty, tz)
The translate() function translates this matrix by
moving the current coordinates to the location specified
by tx, ty, and tz.
Parameters:
Name | Type | Description |
---|---|---|
tx |
float | the x-axis coordinate to move to |
ty |
float | the y-axis coordinate to move to |
tz |
float | the z-axis coordinate to move to |
- Source:
PMatrix3D()
The transpose() function transpose this matrix.
- Source:
PMatrix3D(source,, source,) → {PVector|Array.<float>}
The mult() function multiplied this matrix. If two array
elements are passed in the function will multiply a two
element vector against this matrix. If target is null or
not length four, a new float array will be returned. The
values for vec and target can be the same (though that's
less efficient). If two PVectors are passed in the
function multiply the x and y coordinates of a PVector
against this matrix.
Parameters:
Name | Type | Description |
---|---|---|
source, |
PVector | target the PVectors used to multiply this matrix |
source, |
Array.<float> | target the arrays used to multiply this matrix |
- Source:
Returns:
returns a PVector or an array representing the new
matrix
- Type
- PVector | Array.<float>
PMatrix3D(matrix, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33)
The preApply() function applies another matrix to the
left of this one. Note that either a PMatrix3D or
elements of a matrix can be passed in.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
PMatrix3D | the matrix to apply this matrix to |
m00 |
float | the first element of the matrix |
m01 |
float | the second element of the matrix |
m02 |
float | the third element of the matrix |
m03 |
float | the fourth element of the matrix |
m10 |
float | the fifth element of the matrix |
m11 |
float | the sixth element of the matrix |
m12 |
float | the seventh element of the matrix |
m13 |
float | the eight element of the matrix |
m20 |
float | the nineth element of the matrix |
m21 |
float | the tenth element of the matrix |
m22 |
float | the eleventh element of the matrix |
m23 |
float | the twelveth element of the matrix |
m30 |
float | the thirteenth element of the matrix |
m31 |
float | the fourtheenth element of the matrix |
m32 |
float | the fivetheenth element of the matrix |
m33 |
float | the sixteenth element of the matrix |
- Source:
PMatrix3D(matrix, m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33)
The apply() function multiplies the current matrix by
the one specified through the parameters. Note that
either a PMatrix3D or a list of floats can be passed in.
Parameters:
Name | Type | Description |
---|---|---|
matrix |
PMatrix3D | the matrix to apply this matrix to |
m00 |
float | the first element of the matrix |
m01 |
float | the second element of the matrix |
m02 |
float | the third element of the matrix |
m03 |
float | the fourth element of the matrix |
m10 |
float | the fifth element of the matrix |
m11 |
float | the sixth element of the matrix |
m12 |
float | the seventh element of the matrix |
m13 |
float | the eight element of the matrix |
m20 |
float | the nineth element of the matrix |
m21 |
float | the tenth element of the matrix |
m22 |
float | the eleventh element of the matrix |
m23 |
float | the twelveth element of the matrix |
m30 |
float | the thirteenth element of the matrix |
m31 |
float | the fourtheenth element of the matrix |
m32 |
float | the fivetheenth element of the matrix |
m33 |
float | the sixteenth element of the matrix |
- Source:
PMatrix3D(angle)
The rotate() function rotates the matrix.
Parameters:
Name | Type | Description |
---|---|---|
angle |
float | the angle of rotation in radiants |
- Source:
PMatrix3D(m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33) → {boolean}
The invApply() function applies the inverted matrix to
this matrix.
Parameters:
Name | Type | Description |
---|---|---|
m00 |
float | the first element of the matrix |
m01 |
float | the second element of the matrix |
m02 |
float | the third element of the matrix |
m03 |
float | the fourth element of the matrix |
m10 |
float | the fifth element of the matrix |
m11 |
float | the sixth element of the matrix |
m12 |
float | the seventh element of the matrix |
m13 |
float | the eight element of the matrix |
m20 |
float | the nineth element of the matrix |
m21 |
float | the tenth element of the matrix |
m22 |
float | the eleventh element of the matrix |
m23 |
float | the twelveth element of the matrix |
m30 |
float | the thirteenth element of the matrix |
m31 |
float | the fourtheenth element of the matrix |
m32 |
float | the fivetheenth element of the matrix |
m33 |
float | the sixteenth element of the matrix |
- Source:
Returns:
returns true if the operation was successful.
- Type
- boolean
PMatrix3D(angle)
The rotateZ() function rotates the matrix.
Parameters:
Name | Type | Description |
---|---|---|
angle |
float | the angle of rotation in radiants |
- Source:
PMatrix3D(angle)
The rotateY() function rotates the matrix.
Parameters:
Name | Type | Description |
---|---|---|
angle |
float | the angle of rotation in radiants |
- Source:
PMatrix3D(angle)
The rotateZ() function rotates the matrix.
Parameters:
Name | Type | Description |
---|---|---|
angle |
float | the angle of rotation in radiants |
- Source:
PMatrix3D(sx, sy, sz)
The scale() function increases or decreases the size of
a matrix by expanding and contracting vertices. When
only one parameter is specified scale will occur in all
dimensions. This is equivalent to a three parameter
call.
Parameters:
Name | Type | Description |
---|---|---|
sx |
float | the amount to scale on the x-axis |
sy |
float | the amount to scale on the y-axis |
sz |
float | the amount to scale on the z-axis |
- Source:
PMatrix3D(angle)
The skewX() function skews the matrix along the x-axis
the amount specified by the angle parameter. Angles
should be specified in radians (values from 0 to PI*2)
or converted to radians with the
radians() function.
Parameters:
Name | Type | Description |
---|---|---|
angle |
float | angle of skew specified in radians |
- Source:
PMatrix3D(angle)
The skewY() function skews the matrix along the y-axis
the amount specified by the angle parameter. Angles
should be specified in radians (values from 0 to PI*2)
or converted to radians with the
radians() function.
Parameters:
Name | Type | Description |
---|---|---|
angle |
float | angle of skew specified in radians |
- Source:
PMatrix3D() → {boolean}
The invert() function inverts this matrix
- Source:
Returns:
true if successful
- Type
- boolean
PMatrix3D()
The print() function prints out the elements of this
matrix
- Source:
PMatrixStack(matrix)
load pushes the matrix given in the function into the
stack
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Object | Array | the matrix to be pushed into the stack |
- Source:
PMatrixStack()
push adds a duplicate of the top of the stack onto the
stack - uses the peek function
- Source:
PMatrixStack() → {Object}
pop removes returns the matrix at the top of the stack
- Source:
Returns:
the matrix at the top of the stack
- Type
- Object
PMatrixStack() → {Object}
peek returns but doesn't remove the matrix at the top of
the stack
- Source:
Returns:
the matrix at the top of the stack
- Type
- Object
PMatrixStack(matrix)
this function multiplies the matrix at the top of the
stack with the matrix given as a parameter
Parameters:
Name | Type | Description |
---|---|---|
matrix |
Object | Array | the matrix to be multiplied into the stack |
- Source:
point(x, y, z)
The point() function draws a point, a coordinate in
space at the dimension of one pixel. The first parameter
is the horizontal value for the point, the second value
is the vertical value for the point, and the optional
third value is the depth value. Drawing this shape in 3D
using the z
parameter requires the P3D or OPENGL parameter in
combination with size as shown in the above example.
Parameters:
Name | Type | Description |
---|---|---|
x |
int | float | x-coordinate of the point |
y |
int | float | y-coordinate of the point |
z |
int | float | z-coordinate of the point |
- Source:
- See:
popMatrix()
Pops the current transformation matrix off the matrix
stack. Understanding pushing and popping requires
understanding the concept of a matrix stack. The
pushMatrix() function saves the current coordinate
system to the stack and popMatrix() restores the prior
coordinate system. pushMatrix() and popMatrix() are used
in conjuction with the other transformation methods and
may be embedded to control the scope of the
transformations.
- Source:
- See:
Returns:
none
popStyle()
The pushStyle() function saves the current style
settings and popStyle() restores the prior settings;
these functions are always used together. They allow you
to change the style settings and later return to what
you had. When a new style is started with pushStyle(),
it builds on the current style information. The
pushStyle() and popStyle() functions can be embedded to
provide more control (see the second example above for a
demonstration.)
- Source:
- See:
Returns:
none
print(message)
The print() function writes to the console area of the
Processing environment.
Parameters:
Name | Type | Description |
---|---|---|
message |
String | the string to write to the console |
- Source:
- See:
printCamera()
The printCamera() function prints the current camera
matrix.
- Source:
println(message)
The println() function writes to the console area of the
Processing environment. Each call to this function
creates a new line of output. Individual elements can be
separated with quotes ("") and joined with the string
concatenation operator (+).
Parameters:
Name | Type | Description |
---|---|---|
message |
String | the string to write to the console |
- Source:
- See:
printMatrix()
Prints the current matrix to the text window.
- Source:
- See:
Returns:
none
printProjection()
The printProjection() prints the current projection
matrix to the text window.
- Source:
PShape(family)
Datatype for storing shapes. Processing can currently
load and display SVG (Scalable Vector Graphics) shapes.
Before a shape is used, it must be loaded with the
loadShape() function. The shape() function
is used to draw the shape to the display window. The
PShape object contain a group of methods, linked
below, that can operate on the shape data.
The loadShape() method supports SVG files created with Inkscape and Adobe Illustrator. It is not a full SVG implementation, but offers some straightforward support for handling vector data.
The loadShape() method supports SVG files created with Inkscape and Adobe Illustrator. It is not a full SVG implementation, but offers some straightforward support for handling vector data.
Parameters:
Name | Type | Description |
---|---|---|
family |
int | the shape type, one of GROUP, PRIMITIVE, PATH, or GEOMETRY |
- Source:
- See:
PShape() → {boolean}
The isVisible() function returns a boolean value "true"
if the image is set to be visible, "false" if not. This
is modified with the setVisible() parameter.
The visibility of a shape is usually controlled by whatever program created the SVG file. For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator.
The visibility of a shape is usually controlled by whatever program created the SVG file. For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator.
- Source:
Returns:
returns "true" if the image is set to be visible,
"false" if not
- Type
- boolean
PShape(visible)
The setVisible() function sets the shape to be visible
or invisible. This is determined by the value of the
visible parameter.
The visibility of a shape is usually controlled by whatever program created the SVG file. For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator.
The visibility of a shape is usually controlled by whatever program created the SVG file. For instance, this parameter is controlled by showing or hiding the shape in the layers palette in Adobe Illustrator.
Parameters:
Name | Type | Description |
---|---|---|
visible |
boolean | "false" makes the shape invisible and "true" makes it visible |
- Source:
PShape()
The disableStyle() function disables the shape's style
data and uses Processing's current styles. Styles
include attributes such as colors, stroke weight, and
stroke joints. Overrides this shape's style information
and uses PGraphics styles and colors. Identical to
ignoreStyles(true). Also disables styles for all child
shapes.
- Source:
PShape()
The enableStyle() function enables the shape's style
data and ignores Processing's current styles. Styles
include attributes such as colors, stroke weight, and
stroke joints.
- Source:
PShape() → {int}
The getFamily function returns the shape type
- Source:
Returns:
the shape type, one of GROUP, PRIMITIVE, PATH, or
GEOMETRY
- Type
- int
PShape()
The getWidth() function gets the width of the drawing
area (not necessarily the shape boundary).
- Source:
PShape()
The getHeight() function gets the height of the drawing
area (not necessarily the shape boundary).
- Source:
PShape(name)
The setName() function sets the name of the shape
Parameters:
Name | Type | Description |
---|---|---|
name |
String | the name of the shape |
- Source:
PShape() → {String}
The getName() function returns the name of the shape
- Source:
Returns:
the name of the shape
- Type
- String
PShape()
Called by the following (the shape() command adds the g)
PShape s = loadShapes("blah.svg"); shape(s);
- Source:
PShape()
the drawImpl() function draws the SVG document.
- Source:
PShape()
The drawPath() function draws the <path> part of
the SVG document.
- Source:
PShape()
The drawGeometry() function draws the geometry part of
the SVG document.
- Source:
PShape()
The drawGroup() function draws the <g> part of the
SVG document.
- Source:
PShape()
The drawPrimitive() function draws SVG document shape
elements. These can be point, line, triangle, quad,
rect, ellipse, arc, box, or sphere.
- Source:
PShape()
The pre() function performs the preparations before the
SVG is drawn. This includes doing transformations and
storing previous styles.
- Source:
PShape()
The post() function performs the necessary actions after
the SVG is drawn. This includes removing transformations
and removing added styles.
- Source:
PShape()
The styles() function changes the Processing's current
styles
- Source:
PShape(target, index) → {PShape}
The getChild() function extracts a child shape from a
parent shape. Specify the name of the shape with the
target parameter or the layer position of the
shape to get with the index parameter. The shape
is returned as a PShape object, or null is
returned if there is an error.
Parameters:
Name | Type | Description |
---|---|---|
target |
String | the name of the shape to get |
index |
int | the layer position of the shape to get |
- Source:
Returns:
returns a child element of a shape as a PShape object or
null if there is an error
- Type
- PShape
PShape() → {int}
The getChildCount() returns the number of children
- Source:
Returns:
returns a count of children
- Type
- int
PShape(child)
The addChild() adds a child to the PShape.
Parameters:
Name | Type | Description |
---|---|---|
child |
PShape | the child to add * |
- Source:
PShape(name, shape)
The addName() functions adds a shape to the name lookup
table.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | the name to be added |
shape |
PShape | the shape |
- Source:
PShape(x, y, z)
The translate() function specifies an amount to displace
the shape. The x parameter specifies left/right
translation, the y parameter specifies up/down
translation, and the z parameter specifies
translations toward/away from the screen. Subsequent
calls to the method accumulates the effect. For example,
calling translate(50, 0) and then
translate(20, 0) is the same as
translate(70, 0). This transformation is applied
directly to the shape, it's not refreshed each time
draw() is run.
Using this method with the z parameter requires using the P3D or OPENGL parameter in combination with size.
Using this method with the z parameter requires using the P3D or OPENGL parameter in combination with size.
Parameters:
Name | Type | Description |
---|---|---|
x |
int | float | left/right translation |
y |
int | float | up/down translation |
z |
int | float | forward/back translation |
- Source:
- See:
-
- PMatrix2D#translate
- PMatrix3D#translate
PShape(dimensions)
The checkMatrix() function makes sure that the shape's
matrix is 1) not null, and 2) has a matrix that can
handle at least the specified number of
dimensions.
Parameters:
Name | Type | Description |
---|---|---|
dimensions |
int | the specified number of dimensions |
- Source:
PShape(angle)
The rotateX() function rotates a shape around the x-axis
the amount specified by the angle parameter.
Angles should be specified in radians (values from 0 to
TWO_PI) or converted to radians with the
radians() method.
Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. Subsequent calls to the method accumulates the effect. For example, calling rotateX(HALF_PI) and then rotateX(HALF_PI) is the same as rotateX(PI). This transformation is applied directly to the shape, it's not refreshed each time draw() is run.
This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above.
Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. Subsequent calls to the method accumulates the effect. For example, calling rotateX(HALF_PI) and then rotateX(HALF_PI) is the same as rotateX(PI). This transformation is applied directly to the shape, it's not refreshed each time draw() is run.
This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above.
Parameters:
Name | Type | Description |
---|---|---|
angle |
float | angle of rotation specified in radians |
- Source:
- See:
-
- PMatrix3D#rotateX
PShape(angle)
The rotateY() function rotates a shape around the y-axis
the amount specified by the angle parameter.
Angles should be specified in radians (values from 0 to
TWO_PI) or converted to radians with the
radians() method.
Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. Subsequent calls to the method accumulates the effect. For example, calling rotateY(HALF_PI) and then rotateY(HALF_PI) is the same as rotateY(PI). This transformation is applied directly to the shape, it's not refreshed each time draw() is run.
This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above.
Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. Subsequent calls to the method accumulates the effect. For example, calling rotateY(HALF_PI) and then rotateY(HALF_PI) is the same as rotateY(PI). This transformation is applied directly to the shape, it's not refreshed each time draw() is run.
This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above.
Parameters:
Name | Type | Description |
---|---|---|
angle |
float | angle of rotation specified in radians |
- Source:
- See:
-
- PMatrix3D#rotateY
PShape(angle)
The rotateZ() function rotates a shape around the z-axis
the amount specified by the angle parameter.
Angles should be specified in radians (values from 0 to
TWO_PI) or converted to radians with the
radians() method.
Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. Subsequent calls to the method accumulates the effect. For example, calling rotateZ(HALF_PI) and then rotateZ(HALF_PI) is the same as rotateZ(PI). This transformation is applied directly to the shape, it's not refreshed each time draw() is run.
This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above.
Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. Subsequent calls to the method accumulates the effect. For example, calling rotateZ(HALF_PI) and then rotateZ(HALF_PI) is the same as rotateZ(PI). This transformation is applied directly to the shape, it's not refreshed each time draw() is run.
This method requires a 3D renderer. You need to pass P3D or OPENGL as a third parameter into the size() method as shown in the example above.
Parameters:
Name | Type | Description |
---|---|---|
angle |
float | angle of rotation specified in radians |
- Source:
- See:
-
- PMatrix3D#rotateZ
PShape(angle, x, y, z)
The rotate() function rotates a shape the amount
specified by the angle parameter. Angles should
be specified in radians (values from 0 to TWO_PI) or
converted to radians with the radians() method.
Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. Transformations apply to everything that happens after and subsequent calls to the method accumulates the effect. For example, calling rotate(HALF_PI) and then rotate(HALF_PI) is the same as rotate(PI). This transformation is applied directly to the shape, it's not refreshed each time draw() is run. If optional parameters x,y,z are supplied, the rotate is about the point (x, y, z).
Shapes are always rotated around the upper-left corner of their bounding box. Positive numbers rotate objects in a clockwise direction. Transformations apply to everything that happens after and subsequent calls to the method accumulates the effect. For example, calling rotate(HALF_PI) and then rotate(HALF_PI) is the same as rotate(PI). This transformation is applied directly to the shape, it's not refreshed each time draw() is run. If optional parameters x,y,z are supplied, the rotate is about the point (x, y, z).
Parameters:
Name | Type | Description |
---|---|---|
angle |
float | angle of rotation specified in radians |
x |
float | x-coordinate of the point |
y |
float | y-coordinate of the point |
z |
float | z-coordinate of the point |
- Source:
- See:
-
- PMatrix2D#rotate
- PMatrix3D#rotate
PShape(s, x, y, z)
The scale() function increases or decreases the size of
a shape by expanding and contracting vertices. Shapes
always scale from the relative origin of their bounding
box. Scale values are specified as decimal percentages.
For example, the method call scale(2.0) increases
the dimension of a shape by 200%. Subsequent calls to
the method multiply the effect. For example, calling
scale(2.0) and then scale(1.5) is the same
as scale(3.0). This transformation is applied
directly to the shape, it's not refreshed each time
draw() is run.
Using this fuction with the z parameter requires passing P3D or OPENGL into the size() parameter.
Using this fuction with the z parameter requires passing P3D or OPENGL into the size() parameter.
Parameters:
Name | Type | Description |
---|---|---|
s |
float | percentage to scale the object |
x |
float | percentage to scale the object in the x-axis |
y |
float | percentage to scale the object in the y-axis |
z |
float | percentage to scale the object in the z-axis |
- Source:
- See:
-
- PMatrix2D#scale
- PMatrix3D#scale
PShape()
The resetMatrix() function resets the matrix
- Source:
- See:
-
- PMatrix2D#reset
- PMatrix3D#reset
PShape(matrix)
The applyMatrix() function multiplies this matrix by
another matrix of type PMatrix3D or PMatrix2D.
Individual elements can also be provided
Parameters:
Name | Type | Description |
---|---|---|
matrix |
PMatrix3D | PMatrix2D | the matrix to multiply by |
- Source:
- See:
-
- PMatrix2D#apply
- PMatrix3D#apply
PShapeSVG(parent, filename, xml, parent)
SVG stands for Scalable Vector Graphics, a portable
graphics format. It is a vector format so it allows for
infinite resolution and relatively small file sizes.
Most modern media software can view SVG files, including
Adobe products, Firefox, etc. Illustrator and Inkscape
can edit SVG files.
Parameters:
Name | Type | Description |
---|---|---|
parent |
PApplet | typically use "this" |
filename |
String | name of the SVG file to load |
xml |
XMLElement | an XMLElement element |
parent |
PShapeSVG | the parent PShapeSVG |
- Source:
- See:
PShapeSVG(str) → {PMatrix2D}
The parseMatrix() function parses the specified SVG
matrix into a PMatrix2D. Note that PMatrix2D is rotated
relative to the SVG definition, so parameters are
rearranged here. More about the transformation matrices
in
this section
of the SVG documentation.
Parameters:
Name | Type | Description |
---|---|---|
str |
String | text of the matrix param. |
- Source:
Returns:
a PMatrix2D
- Type
- PMatrix2D
PShapeSVG(element)
The parseChildren() function parses the specified
XMLElement
Parameters:
Name | Type | Description |
---|---|---|
element |
XMLElement | the XMLElement to parse |
- Source:
PShapeSVG() → {String}
The getName() function returns the name
- Source:
Returns:
the name
- Type
- String
PShapeSVG(elem) → {PShape}
The parseChild() function parses a child XML element.
Parameters:
Name | Type | Description |
---|---|---|
elem |
XMLElement | the element to parse |
- Source:
Returns:
the newly created PShape
- Type
- PShape
PShapeSVG()
The parsePath() function parses the <path> element
of the svg file A path is defined by including a path
element which contains a d="(path data)" attribute,
where the d attribute contains the moveto, line, curve
(both cubic and quadratic Beziers), arc and closepath
instructions. *
- Source:
PShapeSVG()
PShapeSVG.parsePath() helper function
- Source:
- See:
-
- PShapeSVG#parsePath
PShapeSVG()
PShapeSVG.parsePath() helper function
- Source:
- See:
-
- PShapeSVG#parsePath
PShapeSVG()
PShapeSVG.parsePath() helper function
- Source:
- See:
-
- PShapeSVG#parsePath
PShapeSVG()
PShapeSVG.parsePath() helper function
- Source:
- See:
-
- PShapeSVG#parsePath
PShapeSVG()
PShapeSVG.parsePath() helper function
- Source:
- See:
-
- PShapeSVG#parsePath
PShapeSVG(val)
The parsePoly() function parses a polyline or polygon
from an SVG file.
Parameters:
Name | Type | Description |
---|---|---|
val |
boolean | true if shape is closed (polygon), false if not (polyline) |
- Source:
PShapeSVG()
The parseRect() function parses a rect from an SVG file.
- Source:
PShapeSVG(val)
The parseEllipse() function handles parsing ellipse and
circle tags.
Parameters:
Name | Type | Description |
---|---|---|
val |
boolean | true if this is a circle and not an ellipse |
- Source:
PShapeSVG(val)
The parseLine() function handles parsing line tags.
Parameters:
Name | Type | Description |
---|---|---|
val |
boolean | true if this is a circle and not an ellipse |
- Source:
PShapeSVG(element)
The parseColors() function handles parsing the opacity,
strijem stroke-width, stroke-linejoin,stroke-linecap,
fill, and style attributes
Parameters:
Name | Type | Description |
---|---|---|
element |
XMLElement | the element of which attributes to parse |
- Source:
PShapeSVG(opacityText)
PShapeSVG.parseColors() helper function
Parameters:
Name | Type | Description |
---|---|---|
opacityText |
String | the value of fillOpacity |
- Source:
- See:
-
- PShapeSVG#parseColors
PShapeSVG(fillText)
PShapeSVG.parseColors() helper function
Parameters:
Name | Type | Description |
---|---|---|
fillText |
String | the value of fill |
- Source:
- See:
-
- PShapeSVG#parseColors
PShapeSVG(opacity)
PShapeSVG.parseColors() helper function
Parameters:
Name | Type | Description |
---|---|---|
opacity |
String | the value of opacity |
- Source:
- See:
-
- PShapeSVG#parseColors
PShapeSVG(strokeText)
PShapeSVG.parseColors() helper function
Parameters:
Name | Type | Description |
---|---|---|
strokeText |
String | the value to set stroke to |
- Source:
- See:
-
- PShapeSVG#parseColors
PShapeSVG(weight)
PShapeSVG.parseColors() helper function
Parameters:
Name | Type | Description |
---|---|---|
weight |
String | the value to set strokeWeight to |
- Source:
- See:
-
- PShapeSVG#parseColors
PShapeSVG(linejoin)
PShapeSVG.parseColors() helper function
Parameters:
Name | Type | Description |
---|---|---|
linejoin |
String | the value to set strokeJoin to |
- Source:
- See:
-
- PShapeSVG#parseColors
PShapeSVG(linecap)
PShapeSVG.parseColors() helper function
Parameters:
Name | Type | Description |
---|---|---|
linecap |
String | the value to set strokeCap to |
- Source:
- See:
-
- PShapeSVG#parseColors
PShapeSVG(opacityText)
PShapeSVG.parseColors() helper function
Parameters:
Name | Type | Description |
---|---|---|
opacityText |
String | the value to set stroke opacity to |
- Source:
- See:
-
- PShapeSVG#parseColors
PShapeSVG(color) → {int}
The parseRGB() function parses an rbg() color string and
returns a color int
Parameters:
Name | Type | Description |
---|---|---|
color |
String | the color to parse in rbg() format |
- Source:
Returns:
the equivalent color int
- Type
- int
PShapeSVG()
The parseUnitSize() function parse a size that may have
a suffix for its units. Ignoring cases where this could
also be a percentage. The
units
spec:
- "1pt" equals "1.25px" (and therefore 1.25 user units)
- "1pc" equals "15px" (and therefore 15 user units)
- "1mm" would be "3.543307px" (3.543307 user units)
- "1cm" equals "35.43307px" (and therefore 35.43307 user units)
- "1in" equals "90px" (and therefore 90 user units)
- Source:
pushMatrix()
Pushes the current transformation matrix onto the matrix
stack. Understanding pushMatrix() and popMatrix()
requires understanding the concept of a matrix stack.
The pushMatrix() function saves the current coordinate
system to the stack and popMatrix() restores the prior
coordinate system. pushMatrix() and popMatrix() are used
in conjuction with the other transformation methods and
may be embedded to control the scope of the
transformations.
Returns:
none
pushStyle()
The pushStyle() function saves the current style
settings and popStyle() restores the prior settings.
Note that these functions are always used together. They
allow you to change the style settings and later return
to what you had. When a new style is started with
pushStyle(), it builds on the current style information.
The pushStyle() and popStyle() functions can be embedded
to provide more control (see the second example above
for a demonstration.) The style information controlled
by the following functions are included in the style:
fill(), stroke(), tint(), strokeWeight(), strokeCap(),
strokeJoin(), imageMode(), rectMode(), ellipseMode(),
shapeMode(), colorMode(), textAlign(), textFont(),
textMode(), textSize(), textLeading(), emissive(),
specular(), shininess(), ambient()
- Source:
- See:
Returns:
none
PVector(x, y, z)
Parameters:
Name | Type | Description |
---|---|---|
x |
* | |
y |
* | |
z |
* |
- Source:
PVector(angle, v)
Parameters:
Name | Type | Description |
---|---|---|
angle |
* | |
v |
* |
- Source:
Returns:
PVector(v)
Parameters:
Name | Type | Description |
---|---|---|
v |
* |
- Source:
Returns:
PVector(v)
Parameters:
Name | Type | Description |
---|---|---|
v |
* |
- Source:
Returns:
PVector(v1, v2)
Parameters:
Name | Type | Description |
---|---|---|
v1 |
* | |
v2 |
* |
- Source:
Returns:
PVector(v1, v2)
Parameters:
Name | Type | Description |
---|---|---|
v1 |
* | |
v2 |
* |
- Source:
Returns:
PVector(v1, v2)
Parameters:
Name | Type | Description |
---|---|---|
v1 |
* | |
v2 |
* |
- Source:
Returns:
PVector(v1, v2)
Parameters:
Name | Type | Description |
---|---|---|
v1 |
* | |
v2 |
* |
- Source:
Returns:
PVector(v1, v2)
Parameters:
Name | Type | Description |
---|---|---|
v1 |
* | |
v2 |
* |
- Source:
Returns:
PVector(v1, v2, amt)
Parameters:
Name | Type | Description |
---|---|---|
v1 |
* | |
v2 |
* | |
amt |
* |
- Source:
Returns:
PVector(v, y, z)
Parameters:
Name | Type | Description |
---|---|---|
v |
* | |
y |
* | |
z |
* |
- Source:
PVector()
- Source:
PVector()
- Source:
PVector()
- Source:
PVector(v_or_len, len)
Parameters:
Name | Type | Description |
---|---|---|
v_or_len |
* | |
len |
* |
- Source:
Returns:
PVector(v, y, z)
Parameters:
Name | Type | Description |
---|---|---|
v |
* | |
y |
* | |
z |
* |
- Source:
PVector(v, y, z)
Parameters:
Name | Type | Description |
---|---|---|
v |
* | |
y |
* | |
z |
* |
- Source:
PVector(v)
Parameters:
Name | Type | Description |
---|---|---|
v |
* |
- Source:
PVector(v)
Parameters:
Name | Type | Description |
---|---|---|
v |
* |
- Source:
PVector(angle)
Parameters:
Name | Type | Description |
---|---|---|
angle |
* |
- Source:
PVector(v)
Parameters:
Name | Type | Description |
---|---|---|
v |
* |
- Source:
PVector(v, y, z)
Parameters:
Name | Type | Description |
---|---|---|
v |
* | |
y |
* | |
z |
* |
- Source:
Returns:
PVector(v)
Parameters:
Name | Type | Description |
---|---|---|
v |
* |
- Source:
PVector(v_or_x, amt_or_y, z, amt)
Parameters:
Name | Type | Description |
---|---|---|
v_or_x |
* | |
amt_or_y |
* | |
z |
* | |
amt |
* |
- Source:
PVector()
- Source:
PVector(high)
Parameters:
Name | Type | Description |
---|---|---|
high |
* |
- Source:
PVector()
- Source:
PVector()
- Source:
PVector()
- Source:
PVector()
- Source:
quad(x1, y1, x2, y2, x3, y3, x4, y4)
A quad is a quadrilateral, a four sided polygon. It is
similar to a rectangle, but the angles between its edges
are not constrained to ninety degrees. The first pair of
parameters (x1,y1) sets the first vertex and the
subsequent pairs should proceed clockwise or
counter-clockwise around the defined shape.
Parameters:
Name | Type | Description |
---|---|---|
x1 |
float | int | x-coordinate of the first corner |
y1 |
float | int | y-coordinate of the first corner |
x2 |
float | int | x-coordinate of the second corner |
y2 |
float | int | y-coordinate of the second corner |
x3 |
float | int | x-coordinate of the third corner |
y3 |
float | int | y-coordinate of the third corner |
x4 |
float | int | x-coordinate of the fourth corner |
y4 |
float | int | y-coordinate of the fourth corner |
- Source:
radians(value) → {float}
Converts a degree measurement to its corresponding value
in radians. Radians and degrees are two ways of
measuring the same thing. There are 360 degrees in a
circle and 2*PI radians in a circle. For example, 90
degrees = PI/2 = 1.5707964. All trigonometric methods in
Processing require their parameters to be specified in
radians.
Parameters:
Name | Type | Description |
---|---|---|
value |
int | float | an angle in radians |
- Source:
- See:
Returns:
- Type
- float
random(value1, value2) → {float}
Generates random numbers. Each time the random()
function is called, it returns an unexpected value
within the specified range. If one parameter is passed
to the function it will return a float between zero and
the value of the high parameter. The function call
random(5) returns values between 0 and 5 (starting at
zero, up to but not including 5). If two parameters are
passed, it will return a float with a value between the
parameters. The function call random(-5, 10.2) returns
values starting at -5 up to (but not including) 10.2. To
convert a floating-point random number to an integer,
use the int() function.
Parameters:
Name | Type | Description |
---|---|---|
value1 |
int | float | if one parameter is used, the top end to random from, if two params the low end |
value2 |
int | float | the top end of the random range |
- Source:
- See:
Returns:
- Type
- float
Random(seed)
We have two random()'s in the code... what does this do
? and which one is current ?
Parameters:
Name | Type | Description |
---|---|---|
seed |
* |
- Source:
Random()
- Source:
Returns:
randomSeed(seed)
Sets the seed value for random(). By default, random()
produces different results each time the program is run.
Set the value parameter to a constant to return the same
pseudo-random numbers each time the software is run.
Parameters:
Name | Type | Description |
---|---|---|
seed |
int | float | int |
- Source:
- See:
rect(x, y, width, height)
Draws a rectangle to the screen. A rectangle is a
four-sided shape with every angle at ninety degrees. The
first two parameters set the location, the third sets
the width, and the fourth sets the height. The origin is
changed with the rectMode() function.
Parameters:
Name | Type | Description |
---|---|---|
x |
int | float | x-coordinate of the rectangle |
y |
int | float | y-coordinate of the rectangle |
width |
int | float | width of the rectangle |
height |
int | float | height of the rectangle |
- Source:
- See:
rectMode(MODE)
Modifies the location from which rectangles draw. The
default mode is rectMode(CORNER), which specifies the
location to be the upper left corner of the shape and
uses the third and fourth parameters of rect() to
specify the width and height. The syntax
rectMode(CORNERS) uses the first and second parameters
of rect() to set the location of one corner and uses the
third and fourth parameters to set the opposite corner.
The syntax rectMode(CENTER) draws the image from its
center point and uses the third and forth parameters of
rect() to specify the image's width and height. The
syntax rectMode(RADIUS) draws the image from its center
point and uses the third and forth parameters of rect()
to specify half of the image's width and height. The
parameter must be written in ALL CAPS because Processing
is a case sensitive language. Note: In version 125, the
mode named CENTER_RADIUS was shortened to RADIUS.
Parameters:
Name | Type | Description |
---|---|---|
MODE |
MODE | Either CORNER, CORNERS, CENTER, or RADIUS |
- Source:
- See:
red(aColor) → {float}
Extracts the red value from a color, scaled to match
current colorMode(). This value is always returned as a
float so be careful not to assign it to an int value.
Parameters:
Name | Type | Description |
---|---|---|
aColor |
color | any value of the color datatype |
- Source:
- See:
-
- green
- blue
- alpha
- >> right shift
- hue
- saturation
- brightness
Returns:
The red color value.
- Type
- float
redraw()
Executes the code within draw() one time. This functions
allows the program to update the display window only
when necessary, for example when an event registered by
mousePressed() or keyPressed() occurs. In structuring a
program, it only makes sense to call redraw() within
events such as mousePressed(). This is because redraw()
does not run draw() immediately (it only sets a flag
that indicates an update is needed). Calling redraw()
within draw() has no effect because draw() is
continuously called anyway.
- Source:
- See:
Returns:
none
removeFirstArgument(args) → {Array.<Object>}
Removes the first argument from the arguments set --
shifts.
Parameters:
Name | Type | Description |
---|---|---|
args |
Arguments | The Arguments object. |
- Source:
- See:
Returns:
Returns an array of arguments except first one.
- Type
- Array.<Object>
resetMatrix()
Replaces the current matrix with the identity matrix.
The equivalent function in OpenGL is glLoadIdentity().
- Source:
- See:
Returns:
none
reverse(array)
Reverses the order of an array.
Parameters:
Name | Type | Description |
---|---|---|
array |
Array.<boolean> | Array.<byte> | Array.<char> | Array.<int> | Array.<float> | Array.<String> | boolean[], byte[], char[], int[], float[], or String[] |
- Source:
- See:
Returns:
Array (the same datatype as the input)
rotate(angleInRadians)
Rotates a shape the amount specified by the angle
parameter. Angles should be specified in radians (values
from 0 to TWO_PI) or converted to radians with the
radians() function. Objects are always rotated around
their relative position to the origin and positive
numbers rotate objects in a clockwise direction.
Transformations apply to everything that happens after
and subsequent calls to the function accumulates the
effect. For example, calling rotate(HALF_PI) and then
rotate(HALF_PI) is the same as rotate(PI). All
tranformations are reset when draw() begins again.
Technically, rotate() multiplies the current
transformation matrix by a rotation matrix. This
function can be further controlled by the pushMatrix()
and popMatrix().
Parameters:
Name | Type | Description |
---|---|---|
angleInRadians
|
int | float | angle of rotation specified in radians |
- Source:
- See:
Returns:
none
rotateX(angleInRadians)
Rotates a shape around the x-axis the amount specified
by the angle parameter. Angles should be specified in
radians (values from 0 to PI*2) or converted to radians
with the radians() function. Objects are always rotated
around their relative position to the origin and
positive numbers rotate objects in a counterclockwise
direction. Transformations apply to everything that
happens after and subsequent calls to the function
accumulates the effect. For example, calling
rotateX(PI/2) and then rotateX(PI/2) is the same as
rotateX(PI). If rotateX() is called within the draw(),
the transformation is reset when the loop begins again.
This function requires passing P3D or OPENGL into the
size() parameter as shown in the example above.
Parameters:
Name | Type | Description |
---|---|---|
angleInRadians
|
int | float | angle of rotation specified in radians |
- Source:
- See:
Returns:
none
rotateY(angleInRadians)
Rotates a shape around the y-axis the amount specified
by the angle parameter. Angles should be specified in
radians (values from 0 to PI*2) or converted to radians
with the radians() function. Objects are always rotated
around their relative position to the origin and
positive numbers rotate objects in a counterclockwise
direction. Transformations apply to everything that
happens after and subsequent calls to the function
accumulates the effect. For example, calling
rotateY(PI/2) and then rotateY(PI/2) is the same as
rotateY(PI). If rotateY() is called within the draw(),
the transformation is reset when the loop begins again.
This function requires passing P3D or OPENGL into the
size() parameter as shown in the example above.
Parameters:
Name | Type | Description |
---|---|---|
angleInRadians
|
int | float | angle of rotation specified in radians |
- Source:
- See:
Returns:
none
rotateZ(angleInRadians)
Rotates a shape around the z-axis the amount specified
by the angle parameter. Angles should be specified in
radians (values from 0 to PI*2) or converted to radians
with the radians() function. Objects are always rotated
around their relative position to the origin and
positive numbers rotate objects in a counterclockwise
direction. Transformations apply to everything that
happens after and subsequent calls to the function
accumulates the effect. For example, calling
rotateZ(PI/2) and then rotateZ(PI/2) is the same as
rotateZ(PI). If rotateZ() is called within the draw(),
the transformation is reset when the loop begins again.
This function requires passing P3D or OPENGL into the
size() parameter as shown in the example above.
Parameters:
Name | Type | Description |
---|---|---|
angleInRadians
|
int | float | angle of rotation specified in radians |
- Source:
- See:
Returns:
none
saturation(colInt) → {float}
Extracts the saturation value from a color.
Parameters:
Name | Type | Description |
---|---|---|
colInt |
color | any value of the color datatype |
- Source:
- See:
Returns:
The saturation color value.
- Type
- float
save(filename)
Saves an image from the display window. Images are saved
in TIFF, TARGA, JPEG, and PNG format depending on the
extension within the filename parameter. For example,
"image.tif" will have a TIFF image and "image.png" will
save a PNG image. If no extension is included in the
filename, the image will save in TIFF format and .tif
will be added to the name. These files are saved to the
sketch's folder, which may be opened by selecting "Show
sketch folder" from the "Sketch" menu. It is not
possible to use save() while running the program in a
web browser. All images saved from the main drawing
window will be opaque. To save images without a
background, use createGraphics().
Parameters:
Name | Type | Description |
---|---|---|
filename |
String | any sequence of letters and numbers |
- Source:
- See:
saveFrame(title)
Parameters:
Name | Type | Description |
---|---|---|
title |
* |
- Source:
saveStrings(filename, strings)
Writes an array of strings to a file, one line per
string. This file is saved to the localStorage.
Parameters:
Name | Type | Description |
---|---|---|
filename |
String | name of the file to save to localStorage |
strings |
Array.<String> | string array to be written |
- Source:
- See:
-
- loadBytes
- loadStrings
- saveBytes
scale(size, x, y, z)
Increases or decreases the size of a shape by expanding
and contracting vertices. Objects always scale from
their relative origin to the coordinate system. Scale
values are specified as decimal percentages. For
example, the function call scale(2.0) increases the
dimension of a shape by 200%. Transformations apply to
everything that happens after and subsequent calls to
the function multiply the effect. For example, calling
scale(2.0) and then scale(1.5) is the same as
scale(3.0). If scale() is called within draw(), the
transformation is reset when the loop begins again.
Using this fuction with the z parameter requires passing
P3D or OPENGL into the size() parameter as shown in the
example above. This function can be further controlled
by pushMatrix() and popMatrix().
Parameters:
Name | Type | Description |
---|---|---|
size |
int | float | percentage to scale the object |
x |
int | float | percentage to scale the object in the x-axis |
y |
int | float | percentage to scale the object in the y-axis |
z |
int | float | percentage to scale the object in the z-axis |
- Source:
- See:
Returns:
none
screenX(x, y, z) → {float}
Takes a three-dimensional X, Y, Z position and returns
the X value for where it will appear on a
(two-dimensional) screen.
Parameters:
Name | Type | Description |
---|---|---|
x |
int | float | 3D x coordinate to be mapped |
y |
int | float | 3D y coordinate to be mapped |
z |
int | float | 3D z optional coordinate to be mapped |
- Source:
- See:
Returns:
- Type
- float
screenY(x, y, z) → {float}
Takes a three-dimensional X, Y, Z position and returns
the Y value for where it will appear on a
(two-dimensional) screen.
Parameters:
Name | Type | Description |
---|---|---|
x |
int | float | 3D x coordinate to be mapped |
y |
int | float | 3D y coordinate to be mapped |
z |
int | float | 3D z optional coordinate to be mapped |
- Source:
- See:
Returns:
- Type
- float
screenZ(x, y, z) → {float}
Takes a three-dimensional X, Y, Z position and returns
the Z value for where it will appear on a
(two-dimensional) screen.
Parameters:
Name | Type | Description |
---|---|---|
x |
int | float | 3D x coordinate to be mapped |
y |
int | float | 3D y coordinate to be mapped |
z |
int | float | 3D z coordinate to be mapped |
- Source:
- See:
Returns:
- Type
- float
second() → {float}
Processing communicates with the clock on your computer.
The second() function returns the current second as a
value from 0 - 59.
Returns:
The current minute.
- Type
- float
set(x, y, obj, img)
Changes the color of any pixel or writes an image
directly into the display window. The x and y parameters
specify the pixel to change and the color parameter
specifies the color value. The color parameter is
affected by the current color mode (the default is RGB
values from 0 to 255). When setting an image, the x and
y parameters define the coordinates for the upper-left
corner of the image. Setting the color of a single pixel
with set(x, y) is easy, but not as fast as putting the
data directly into pixels[]. The equivalent statement to
"set(x, y, #000000)" using pixels[] is
"pixels[y*width+x] = #000000". You must call
loadPixels() to load the display window data into the
pixels[] array before setting the values and calling
updatePixels() to update the window with any changes.
This function ignores imageMode().
Parameters:
Name | Type | Description |
---|---|---|
x |
int | x-coordinate of the pixel |
y |
int | y-coordinate of the pixel |
obj |
Color | any value of the color datatype |
img |
PImage | any valid variable of type PImage |
- Source:
- See:
shape(shape, x, y, width, height)
The shape() function displays shapes to the screen.
Processing currently works with SVG shapes only. The
shape parameter specifies the shape to display
and the x and y parameters define the
location of the shape from its upper-left corner. The
shape is displayed at its original size unless the
width and height parameters specify a
different size. The shapeMode() function changes
the way the parameters work. A call to
shapeMode(CORNERS), for example, will change the
width and height parameters to define the x and y values
of the opposite corner of the shape.
Note complex shapes may draw awkwardly with P2D, P3D, and OPENGL. Those renderers do not yet support shapes that have holes or complicated breaks.
Note complex shapes may draw awkwardly with P2D, P3D, and OPENGL. Those renderers do not yet support shapes that have holes or complicated breaks.
Parameters:
Name | Type | Description |
---|---|---|
shape |
PShape | the shape to display |
x |
int | float | x-coordinate of the shape |
y |
int | float | y-coordinate of the shape |
width |
int | float | width to display the shape |
height |
int | float | height to display the shape |
- Source:
- See:
-
- PShape
- loadShape()
- shapeMode()
shapeMode(mode)
The shapeMode() function modifies the location from
which shapes draw. The default mode is
shapeMode(CORNER), which specifies the location
to be the upper left corner of the shape and uses the
third and fourth parameters of shape() to specify
the width and height. The syntax
shapeMode(CORNERS) uses the first and second
parameters of shape() to set the location of one
corner and uses the third and fourth parameters to set
the opposite corner. The syntax
shapeMode(CENTER) draws the shape from its center
point and uses the third and forth parameters of
shape() to specify the width and height. The
parameter must be written in "ALL CAPS" because
Processing syntax is case sensitive.
Parameters:
Name | Type | Description |
---|---|---|
mode |
int | One of CORNER, CORNERS, CENTER |
- Source:
- See:
-
- shape()
- rectMode()
shorten(ary)
Decreases an array by one element and returns the
shortened array. When using an array of objects, the
data returned from the function must be cast to the
object array's data type. For example: SomeClass[] items
= (SomeClass[]) shorten(originalArray).
Parameters:
Name | Type | Description |
---|---|---|
ary |
- Source:
- See:
Returns:
Array (the same datatype as the input)
size(aWidth, aHeight, aMode)
Defines the dimension of the display window in units of
pixels. The size() function must be the first line in
setup(). If size() is not called, the default size of
the window is 100x100 pixels. The system variables width
and height are set by the parameters passed to the
size() function.
Parameters:
Name | Type | Description |
---|---|---|
aWidth |
int | width of the display window in units of pixels |
aHeight |
int | height of the display window in units of pixels |
aMode |
MODE | Either P2D, P3D, JAVA2D, or OPENGL |
- Source:
- See:
-
- createGraphics
- screen
size(aWidth, aHeight, aMode)
Parameters:
Name | Type | Description |
---|---|---|
aWidth |
* | |
aHeight |
* | |
aMode |
* |
- Source:
smooth()
The smooth() function draws all geometry with smooth
(anti-aliased) edges. This will slow down the frame rate
of the application, but will enhance the visual
refinement.
Note that smooth() will also improve image quality of resized images, and noSmooth() will disable image (and font) smoothing altogether.
Note that smooth() will also improve image quality of resized images, and noSmooth() will disable image (and font) smoothing altogether.
- Source:
- See:
sort(array, numElem) → {Array.<String>|Array.<int>|Array.<float>}
Sorts an array of numbers from smallest to largest and
puts an array of words in alphabetical order. The
original array is not modified, a re-ordered array is
returned. The count parameter states the number of
elements to sort. For example if there are 12 elements
in an array and if count is the value 5, only the first
five elements on the array will be sorted. Alphabetical
ordering is case insensitive.
Parameters:
Name | Type | Description |
---|---|---|
array |
Array.<String> | Array.<int> | Array.<float> | Array of elements to sort |
numElem |
int | Number of elements to sort |
- Source:
- See:
Returns:
Array (same datatype as the input)
- Type
- Array.<String> | Array.<int> | Array.<float>
sphereDetail(ures, vres)
The sphereDetail() function controls the detail used to
render a sphere by adjusting the number of vertices of
the sphere mesh. The default resolution is 30, which
creates a fairly detailed sphere definition with
vertices every 360/30 = 12 degrees. If you're going to
render a great number of spheres per frame, it is
advised to reduce the level of detail using this
function. The setting stays active until
sphereDetail() is called again with a new
parameter and so should not be called prior to
every sphere() statement, unless you wish to
render spheres with different settings, e.g. using less
detail for smaller spheres or ones further away from the
camera. To control the detail of the horizontal and
vertical resolution independently, use the version of
the functions with two parameters. Calling this function
with one parameter sets the number of segments (minimum
of 3) used per full circle revolution. This is
equivalent to calling the function with two identical
values.
Parameters:
Name | Type | Description |
---|---|---|
ures |
int | number of segments used horizontally (longitudinally) per full circle revolution |
vres |
int | number of segments used vertically (latitudinally) from top to bottom |
- Source:
- See:
splice(array, value, index)
Inserts a value or array of values into an existing
array. The first two parameters must be of the same
datatype. The array parameter defines the array which
will be modified and the second parameter defines the
data which will be inserted. When using an array of
objects, the data returned from the function must be
cast to the object array's data type. For example:
SomeClass[] items = (SomeClass[]) splice(array1, array2,
index).
Parameters:
Name | Type | Description |
---|---|---|
array |
||
value |
||
index |
int | position in the array from which to insert data |
- Source:
- See:
-
- contract
- subset
Returns:
Array (the same datatype as the input)
split(str, delim) → {Array.<string>}
The split() function breaks a string into pieces using a
character or string as the divider. The delim parameter
specifies the character or characters that mark the
boundaries between each piece. A String[] array is
returned that contains each of the pieces. If the result
is a set of numbers, you can convert the String[] array
to to a float[] or int[] array using the datatype
conversion functions int() and float() (see example
above). The splitTokens() function works in a similar
fashion, except that it splits using a range of
characters instead of a specific character or sequence.
Parameters:
Name | Type | Description |
---|---|---|
str |
String | the String to be split |
delim |
String | the character or String used to separate the data |
- Source:
- See:
Returns:
The new string array
- Type
- Array.<string>
splitTokens(str, tokens) → {Array.<string>}
The splitTokens() function splits a String at one or
many character "tokens." The tokens parameter specifies
the character or characters to be used as a boundary. If
no tokens character is specified, any whitespace
character is used to split. Whitespace characters
include tab (\t), line feed (\n), carriage return (\r),
form feed (\f), and space. To convert a String to an
array of integers or floats, use the datatype conversion
functions int() and float() to convert the array of
Strings.
Parameters:
Name | Type | Description |
---|---|---|
str |
String | the String to be split |
tokens |
Array.<Char> | list of individual characters that will be used as separators |
- Source:
- See:
Returns:
The new string array
- Type
- Array.<string>
sq(value) → {float}
Squares a number (multiplies a number by itself). The
result is always a positive number, as multiplying two
negative numbers always yields a positive result. For
example, -1 * -1 = 1.
Parameters:
Name | Type | Description |
---|---|---|
value |
float | int or float |
- Source:
- See:
Returns:
- Type
- float
status(text)
Displays message in the browser's status area. This is
the text area in the lower left corner of the browser.
The status() function will only work when the Processing
program is running in a web browser.
Parameters:
Name | Type | Description |
---|---|---|
text |
String | any valid String |
- Source:
Returns:
none
str()
Alphanumeric chars arguments automatically converted to
numbers when passed in, and will come out as numbers.
- Source:
stroke(gray, value1, value2, value3, alpha, color, hex)
The stroke() function sets the color used to draw lines
and borders around shapes. This color is either
specified in terms of the RGB or HSB color depending on
the current colorMode() (the default color space
is RGB, with each value in the range from 0 to 255).
When using hexadecimal notation to specify a color, use "#" or "0x" before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six digits to specify a color (the way colors are specified in HTML and CSS). When using the hexadecimal notation starting with "0x", the hexadecimal value must be specified with eight characters; the first two characters define the alpha component and the remainder the red, green, and blue components.
The value for the parameter "gray" must be less than or equal to the current maximum value as specified by colorMode(). The default maximum value is 255.
When using hexadecimal notation to specify a color, use "#" or "0x" before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six digits to specify a color (the way colors are specified in HTML and CSS). When using the hexadecimal notation starting with "0x", the hexadecimal value must be specified with eight characters; the first two characters define the alpha component and the remainder the red, green, and blue components.
The value for the parameter "gray" must be less than or equal to the current maximum value as specified by colorMode(). The default maximum value is 255.
Parameters:
Name | Type | Description |
---|---|---|
gray |
int | float | number specifying value between white and black |
value1 |
int | float | red or hue value |
value2 |
int | float | green or saturation value |
value3 |
int | float | blue or brightness value |
alpha |
int | float | opacity of the stroke |
color |
Color | any value of the color datatype |
hex |
int | color value in hexadecimal notation (i.e. #FFCC00 or 0xFFFFCC00) |
- Source:
- See:
strokeCap(value)
The strokeCap() function sets the style for rendering
line endings. These ends are either squared, extended,
or rounded and specified with the corresponding
parameters SQUARE, PROJECT, and ROUND. The default cap
is ROUND. This function is not available with the P2D,
P3D, or OPENGL renderers
Parameters:
Name | Type | Description |
---|---|---|
value |
int | Either SQUARE, PROJECT, or ROUND |
- Source:
strokeJoin(value)
The strokeJoin() function sets the style of the joints
which connect line segments. These joints are either
mitered, beveled, or rounded and specified with the
corresponding parameters MITER, BEVEL, and ROUND. The
default joint is MITER. This function is not available
with the P2D, P3D, or OPENGL renderers
Parameters:
Name | Type | Description |
---|---|---|
value |
int | Either SQUARE, PROJECT, or ROUND |
- Source:
strokeWeight(w)
The strokeWeight() function sets the width of the stroke
used for lines, points, and the border around shapes.
All widths are set in units of pixels.
Parameters:
Name | Type | Description |
---|---|---|
w |
int | float | the weight (in pixels) of the stroke |
- Source:
subset(array, offset, length)
Extracts an array of elements from an existing array.
The array parameter defines the array from which the
elements will be copied and the offset and length
parameters determine which elements to extract. If no
length is given, elements will be extracted from the
offset to the end of the array. When specifying the
offset remember the first array element is 0. This
function does not change the source array. When using an
array of objects, the data returned from the function
must be cast to the object array's data type.
Parameters:
Name | Type | Description |
---|---|---|
array |
||
offset |
int | position to begin |
length |
int | number of values to extract |
- Source:
- See:
Returns:
Array (the same datatype as the input)
text(data, x, y, z, stringdata, width, height)
text() Draws text to the screen.
Parameters:
Name | Type | Description |
---|---|---|
data |
String | char | int | float | the alphanumeric symbols to be displayed |
x |
int | float | x-coordinate of text |
y |
int | float | y-coordinate of text |
z |
int | float | optional z-coordinate of text |
stringdata |
String | optional letters to be displayed |
width |
int | float | optional width of text box |
height |
int | float | optional height of text box |
- Source:
- See:
textAlign(ALIGN, YALIGN)
textAlign() Sets the current alignment for drawing text.
Parameters:
Name | Type | Description |
---|---|---|
ALIGN |
int | Horizontal alignment, either LEFT, CENTER, or RIGHT |
YALIGN |
int | optional vertical alignment, either TOP, BOTTOM, CENTER, or BASELINE |
- Source:
- See:
textAscent() → {float}
textAscent() returns the maximum height a character
extends above the baseline of the current font at its
current size, in pixels.
- Source:
- See:
Returns:
height of the current font above the baseline, at its
current size, in pixels
- Type
- float
textDescent() → {float}
textDescent() returns the maximum depth a character will
protrude below the baseline of the current font at its
current size, in pixels.
- Source:
- See:
Returns:
depth of the current font below the baseline, at its
current size, in pixels
- Type
- float
textFont(pfont, size)
textFont() Sets the current font.
Parameters:
Name | Type | Description |
---|---|---|
pfont |
PFont | the PFont to load as current text font |
size |
int | float | optional font size in pixels |
- Source:
- See:
textLeading(the)
textLeading() Sets the current font's leading, which is
the distance from baseline to baseline over consecutive
lines, with additional vertical spacing taking into
account. Usually this value is 1.2 or 1.25 times the
textsize, but this value can be changed to effect
vertically compressed or stretched text.
Parameters:
Name | Type | Description |
---|---|---|
the |
int | float | desired baseline-to-baseline size in pixels |
- Source:
textMode(MODE)
Sets the way text draws to the screen. In the default
configuration (the MODEL mode), it's possible to rotate,
scale, and place letters in two and three dimensional
space.
Changing to SCREEN mode draws letters directly to the front of the window and greatly increases rendering quality and speed when used with the P2D and P3D renderers. textMode(SCREEN) with OPENGL and JAVA2D (the default) renderers will generally be slower, though pixel accurate with P2D and P3D. With textMode(SCREEN), the letters draw at the actual size of the font (in pixels) and therefore calls to textSize() will not affect the size of the letters. To create a font at the size you desire, use the "Create font..." option in the Tools menu, or use the createFont() function. When using textMode(SCREEN), any z-coordinate passed to a text() command will be ignored, because your computer screen is...flat!
Changing to SCREEN mode draws letters directly to the front of the window and greatly increases rendering quality and speed when used with the P2D and P3D renderers. textMode(SCREEN) with OPENGL and JAVA2D (the default) renderers will generally be slower, though pixel accurate with P2D and P3D. With textMode(SCREEN), the letters draw at the actual size of the font (in pixels) and therefore calls to textSize() will not affect the size of the letters. To create a font at the size you desire, use the "Create font..." option in the Tools menu, or use the createFont() function. When using textMode(SCREEN), any z-coordinate passed to a text() command will be ignored, because your computer screen is...flat!
Parameters:
Name | Type | Description |
---|---|---|
MODE |
int | Either MODEL, SCREEN or SHAPE (not yet supported) |
- Source:
- See:
textSize(size)
textSize() Sets the current font size in pixels.
Parameters:
Name | Type | Description |
---|---|---|
size |
int | float | font size in pixels |
- Source:
- See:
texture(pimage)
Sets a texture to be applied to vertex points. The
texture() function must be called between
beginShape() and endShape() and before any
calls to vertex(). When textures are in use, the fill
color is ignored. Instead, use tint() to specify the
color of the texture as it is applied to the shape.
Parameters:
Name | Type | Description |
---|---|---|
pimage |
PImage | the texture to apply |
- Source:
- See:
Returns:
none
textureMode(MODE)
Sets the coordinate space for texture mapping. There are
two options, IMAGE, which refers to the actual
coordinates of the image, and NORMALIZED, which refers
to a normalized space of values ranging from 0 to 1. The
default mode is IMAGE. In IMAGE, if an image is 100 x
200 pixels, mapping the image onto the entire size of a
quad would require the points (0,0) (0,100) (100,200)
(0,200). The same mapping in NORMAL_SPACE is (0,0) (0,1)
(1,1) (0,1).
Parameters:
Name | Type | Description |
---|---|---|
MODE |
either IMAGE or NORMALIZED |
- Source:
- See:
Returns:
none
textWidth(str) → {float}
textWidth() Calculates and returns the width of any
character or text string in pixels.
Parameters:
Name | Type | Description |
---|---|---|
str |
char | String | char or String to be measured |
- Source:
- See:
Returns:
width of char or String in pixels
- Type
- float
tint(gray, alpha, value1, value2, value3, color, hex)
The tint() function sets the fill value for displaying
images. Images can be tinted to specified colors or made
transparent by setting the alpha.
To make an image transparent, but not change it's color, use white as the tint color and specify an alpha value. For instance, tint(255, 128) will make an image 50% transparent (unless colorMode() has been used).
When using hexadecimal notation to specify a color, use "#" or "0x" before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six digits to specify a color (the way colors are specified in HTML and CSS). When using the hexadecimal notation starting with "0x", the hexadecimal value must be specified with eight characters; the first two characters define the alpha component and the remainder the red, green, and blue components.
The value for the parameter "gray" must be less than or equal to the current maximum value as specified by colorMode(). The default maximum value is 255.
The tint() method is also used to control the coloring of textures in 3D.
To make an image transparent, but not change it's color, use white as the tint color and specify an alpha value. For instance, tint(255, 128) will make an image 50% transparent (unless colorMode() has been used).
When using hexadecimal notation to specify a color, use "#" or "0x" before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six digits to specify a color (the way colors are specified in HTML and CSS). When using the hexadecimal notation starting with "0x", the hexadecimal value must be specified with eight characters; the first two characters define the alpha component and the remainder the red, green, and blue components.
The value for the parameter "gray" must be less than or equal to the current maximum value as specified by colorMode(). The default maximum value is 255.
The tint() method is also used to control the coloring of textures in 3D.
Parameters:
Name | Type | Description |
---|---|---|
gray |
int | float | any valid number |
alpha |
int | float | opacity of the image |
value1 |
int | float | red or hue value |
value2 |
int | float | green or saturation value |
value3 |
int | float | blue or brightness value |
color |
int | float | any value of the color datatype |
hex |
int | color value in hexadecimal notation (i.e. #FFCC00 or 0xFFFFCC00) |
- Source:
- See:
toImageData() → {ImageData}
This function takes content from a canvas and turns it
into an ImageData object to be used with a PImage
- Source:
- See:
Returns:
ImageData object to attach to a PImage (1D array of
pixel data)
- Type
- ImageData
translate(x, y, z)
Specifies an amount to displace objects within the
display window. The x parameter specifies left/right
translation, the y parameter specifies up/down
translation, and the z parameter specifies translations
toward/away from the screen. Using this function with
the z parameter requires using the P3D or OPENGL
parameter in combination with size as shown in the above
example. Transformations apply to everything that
happens after and subsequent calls to the function
accumulates the effect. For example, calling
translate(50, 0) and then translate(20, 0) is the same
as translate(70, 0). If translate() is called within
draw(), the transformation is reset when the loop begins
again. This function can be further controlled by the
pushMatrix() and popMatrix().
Parameters:
Name | Type | Description |
---|---|---|
x |
int | float | left/right translation |
y |
int | float | up/down translation |
z |
int | float | forward/back translation |
- Source:
- See:
Returns:
none
triangle(x1, y1, x2, y2, x3, y3)
A triangle is a plane created by connecting three
points. The first two arguments specify the first point,
the middle two arguments specify the second point, and
the last two arguments specify the third point.
Parameters:
Name | Type | Description |
---|---|---|
x1 |
int | float | x-coordinate of the first point |
y1 |
int | float | y-coordinate of the first point |
x2 |
int | float | x-coordinate of the second point |
y2 |
int | float | y-coordinate of the second point |
x3 |
int | float | x-coordinate of the third point |
y3 |
int | float | y-coordinate of the third point |
- Source:
trim(str, str) → {String|Array.<String>}
Remove whitespace characters from the beginning and
ending of a String or a String array. Works like
String.trim() but includes the unicode nbsp character as
well. If an array is passed in the function will return
a new array not effecting the array passed in.
Parameters:
Name | Type | Description |
---|---|---|
str |
String | the string to trim |
str |
Array.<String> | the string array to trim |
- Source:
Returns:
retrurns a string or an array will removed whitespaces
- Type
- String | Array.<String>
unbinary(binaryString) → {Int}
Converts a String representation of a binary number to
its equivalent integer value. For example,
unbinary("00001000") will return 8.
Parameters:
Name | Type | Description |
---|---|---|
binaryString |
String | String |
- Source:
- See:
Returns:
- Type
- Int
unhex(hex) → {int}
Converts a String representation of a hexadecimal number
to its equivalent integer value.
Parameters:
Name | Type | Description |
---|---|---|
hex |
String | the hex string to convert to an int |
- Source:
- See:
Returns:
- Type
- int
updatePixels()
Updates the display window with the data in the pixels[]
array. Use in conjunction with loadPixels(). If you're
only reading pixels from the array, there's no need to
call updatePixels() unless there are changes. Certain
renderers may or may not seem to require loadPixels() or
updatePixels(). However, the rule is that any time you
want to manipulate the pixels[] array, you must first
call loadPixels(), and after changes have been made,
call updatePixels(). Even if the renderer may not seem
to use this function in the current Processing release,
this will always be subject to change. Currently, none
of the renderers use the additional parameters to
updatePixels(), however this may be implemented in the
future.
- Source:
- See:
-
- loadPixels
- pixels[]
vertex(x, y, z, u, v)
All shapes are constructed by connecting a series of
vertices. vertex() is used to specify the vertex
coordinates for points, lines, triangles, quads, and
polygons and is used exclusively within the
beginShape() and endShape() function.
Drawing a vertex in 3D using the z parameter requires the P3D or OPENGL parameter in combination with size as shown in the above example.
This function is also used to map a texture onto the geometry. The texture() function declares the texture to apply to the geometry and the u and v coordinates set define the mapping of this texture to the form. By default, the coordinates used for u and v are specified in relation to the image's size in pixels, but this relation can be changed with textureMode().
Drawing a vertex in 3D using the z parameter requires the P3D or OPENGL parameter in combination with size as shown in the above example.
This function is also used to map a texture onto the geometry. The texture() function declares the texture to apply to the geometry and the u and v coordinates set define the mapping of this texture to the form. By default, the coordinates used for u and v are specified in relation to the image's size in pixels, but this relation can be changed with textureMode().
Parameters:
Name | Type | Description |
---|---|---|
x |
int | float | x-coordinate of the vertex |
y |
int | float | y-coordinate of the vertex |
z |
int | float | z-coordinate of the vertex |
u |
int | float | horizontal coordinate for the texture mapping |
v |
int | float | vertical coordinate for the texture mapping |
- Source:
- See:
XMLElement(parent, filename, xml, fullname, namespace, systemID, lineNr)
XMLElement is a representation of an XML object. The
object is able to parse XML code
Parameters:
Name | Type | Description |
---|---|---|
parent |
PApplet | typically use "this" |
filename |
String | name of the XML/SVG file to load |
xml |
String | the xml/svg string |
fullname |
String | the full name of the element |
namespace |
String | the namespace of the URI |
systemID |
String | the system ID of the XML data where the element starts |
lineNr |
Integer | the line in the XML data where the element starts |
- Source:
XMLElement(filename)
The parse() function retrieves the file via ajax() and
uses DOMParser() parseFromString method to make an XML
document
Parameters:
Name | Type | Description |
---|---|---|
filename |
String | name of the XML/SVG file to load |
- Source:
- See:
-
- XMLElement#parseChildrenRecursive
Throws:
ExceptionType Error loading document
XMLElement(parent) → {XMLElement}
Internal helper function for parse(). Loops through the
Parameters:
Name | Type | Description |
---|---|---|
parent |
XMLElement | the parent node |
|
- Source:
Returns:
the new element and its children elements
- Type
- XMLElement
XMLElement(fullName, namespace, systemID, lineNr)
The createElement() function Creates an empty element
Parameters:
Name | Type | Description |
---|---|---|
fullName |
String | the full name of the element |
namespace |
String | the namespace URI |
systemID |
String | the system ID of the XML data where the element starts |
lineNr |
int | the line in the XML data where the element starts |
- Source:
XMLElement() → {XMLElement}
The createPCDataElement() function creates an element to
be used for #PCDATA content. Because Processing discards
whitespace TEXT nodes, this method will not build an
element if the passed content is empty after trimming
for whitespace.
- Source:
Returns:
new "test" XMLElement, or null if content consists only
of whitespace
- Type
- XMLElement
XMLElement(name, namespace) → {boolean}
The hasAttribute() function returns whether an attribute
exists
Parameters:
Name | Type | Description |
---|---|---|
name |
String | name of the attribute |
namespace |
String | the namespace URI of the attribute |
- Source:
Returns:
true if the attribute exists
- Type
- boolean
XMLElement(rawElement) → {boolean}
The equals() function checks to see if the XMLElement
being passed in equals another XMLElement
Parameters:
Name | Type | Description |
---|---|---|
rawElement |
XMLElement | the element to compare to |
- Source:
Returns:
true if the element equals another element
- Type
- boolean
XMLElement() → {String}
The getContent() function returns the content of an
element. If there is no such content, null is returned
- Source:
Returns:
the (possibly null) content
- Type
- String
XMLElement(name, namespace, defaultValue) → {String}
The getAttribute() function returns the value of an
attribute
Parameters:
Name | Type | Description |
---|---|---|
name |
String | the non-null full name of the attribute |
namespace |
String | the namespace URI, which may be null |
defaultValue |
String | the default value of the attribute |
- Source:
Returns:
the value, or defaultValue if the attribute does not
exist
- Type
- String
XMLElement(name, defaultValue) → {String}
The getStringAttribute() function returns the string
attribute of the element If the
defaultValue parameter is used and the attribute
doesn't exist, the defaultValue value is
returned. When calling the function without the
defaultValue parameter, if the attribute doesn't
exist, the value 0 is returned.
Parameters:
Name | Type | Description |
---|---|---|
name |
the name of the attribute | |
defaultValue |
value returned if the attribute is not found |
- Source:
Returns:
the value, or defaultValue if the attribute does not
exist
- Type
- String
XMLElement(name, defaultValue) → {float}
The getFloatAttribute() function returns the float
attribute of the element. If the
defaultValue parameter is used and the attribute
doesn't exist, the defaultValue value is
returned. When calling the function without the
defaultValue parameter, if the attribute doesn't
exist, the value 0 is returned.
Parameters:
Name | Type | Description |
---|---|---|
name |
the name of the attribute | |
defaultValue |
value returned if the attribute is not found |
- Source:
Returns:
the value, or defaultValue if the attribute does not
exist
- Type
- float
XMLElement(name, defaultValue) → {int}
The getIntAttribute() function returns the integer
attribute of the element. If the
defaultValue parameter is used and the attribute
doesn't exist, the defaultValue value is
returned. When calling the function without the
defaultValue parameter, if the attribute doesn't
exist, the value 0 is returned.
Parameters:
Name | Type | Description |
---|---|---|
name |
the name of the attribute | |
defaultValue |
value returned if the attribute is not found |
- Source:
Returns:
the value, or defaultValue if the attribute does not
exist
- Type
- int
XMLElement() → {boolean}
The hasChildren() function returns whether the element
has children.
- Source:
Returns:
true if the element has children.
- Type
- boolean
XMLElement(child)
The addChild() function adds a child element
Parameters:
Name | Type | Description |
---|---|---|
child |
XMLElement | the non-null child to add. |
- Source:
XMLElement(child, index)
The insertChild() function inserts a child element at
the index provided
Parameters:
Name | Type | Description |
---|---|---|
child |
XMLElement | the non-null child to add. |
index |
int | where to put the child. |
- Source:
XMLElement(index, path) → {XMLElement}
The getChild() returns the child XMLElement as specified
by the index parameter. The value of the
index parameter must be less than the total
number of children to avoid going out of the array
storing the child elements. When the
path parameter is specified, then it will return
all children that match that path. The path is a series
of elements and sub-elements, separated by slashes.
Parameters:
Name | Type | Description |
---|---|---|
index |
int | where to put the child. |
path |
String | path to a particular element |
- Source:
Returns:
the element
- Type
- XMLElement
XMLElement(path) → {XMLElement}
The getChildren() returns all of the children as an
XMLElement array. When the path parameter is
specified, then it will return all children that match
that path. The path is a series of elements and
sub-elements, separated by slashes.
Parameters:
Name | Type | Description |
---|---|---|
path |
String | element name or path/to/element |
- Source:
- See:
-
- XMLElement#getChildCount()
- XMLElement#getChild()
Returns:
array of child elements that match
- Type
- XMLElement
XMLElement() → {int}
The getChildCount() returns the number of children for
the element.
- Source:
- See:
-
- XMLElement#getChild()
- XMLElement#getChildren()
Returns:
the count
- Type
- int
XMLElement(items, offset) → {XMLElement}
Internal helper function for getChild().
Parameters:
Name | Type | Description |
---|---|---|
items |
Array.<String> | result of splitting the query on slashes |
offset |
int | where in the items[] array we're currently looking |
- Source:
Returns:
matching element or null if no match
- Type
- XMLElement
XMLElement(items, offset) → {Array.<XMLElement>}
Internal helper function for getChildren().
Parameters:
Name | Type | Description |
---|---|---|
items |
Array.<String> | result of splitting the query on slashes |
offset |
int | where in the items[] array we're currently looking |
- Source:
Returns:
matching elements or empty array if no match
- Type
- Array.<XMLElement>
XMLElement() → {boolean}
The isLeaf() function returns whether the element is a
leaf element.
- Source:
Returns:
true if the element has no children.
- Type
- boolean
XMLElement() → {Array.<String>}
The listChildren() function put the names of all
children into an array. Same as looping through each
child and calling getName() on each XMLElement.
- Source:
Returns:
a list of element names.
- Type
- Array.<String>
XMLElement(name, namespace)
The removeAttribute() function removes an attribute
Parameters:
Name | Type | Description |
---|---|---|
name |
String | the non-null name of the attribute. |
namespace |
String | the namespace URI of the attribute, which may be null. |
- Source:
XMLElement(child)
The removeChild() removes a child element.
Parameters:
Name | Type | Description |
---|---|---|
child |
XMLElement | the the non-null child to be renoved |
- Source:
XMLElement(index)
The removeChildAtIndex() removes the child located at a
certain index
Parameters:
Name | Type | Description |
---|---|---|
index |
int | the index of the child, where the first child has index 0 |
- Source:
XMLElement(name, namespace) → {XMLAttribute}
The findAttribute() function searches an attribute
Parameters:
Name | Type | Description |
---|---|---|
name |
String | fullName the non-null full name of the attribute |
namespace |
String | the name space, which may be null |
- Source:
Returns:
the attribute, or null if the attribute does not exist.
- Type
- XMLAttribute
XMLElement(name, namespace)
The setAttribute() function sets an attribute.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | the non-null full name of the attribute |
namespace |
String | the non-null value of the attribute |
- Source:
XMLElement(content)
The setContent() function sets the #PCDATA content. It
is an error to call this method with a non-null value if
there are child objects.
Parameters:
Name | Type | Description |
---|---|---|
content |
String | the (possibly null) content |
- Source:
XMLElement(name, namespace)
The setName() function sets the full name. This method
also sets the short name and clears the namespace URI.
Parameters:
Name | Type | Description |
---|---|---|
name |
String | the non-null name |
namespace |
String | the namespace URI, which may be null. |
- Source:
XMLElement() → {String}
The getName() function returns the full name (i.e. the
name including an eventual namespace prefix) of the
element.
- Source:
Returns:
the name, or null if the element only contains #PCDATA.
- Type
- String
XMLElement() → {String}
The getLocalName() function returns the local name (i.e.
the name excluding an eventual namespace prefix) of the
element.
- Source:
Returns:
the name, or null if the element only contains #PCDATA.
- Type
- String
XMLElement() → {int}
The getAttributeCount() function returns the number of
attributes for the node that this XMLElement represents.
- Source:
Returns:
the number of attributes in this XMLElement
- Type
- int
XMLElement() → {String}
The toString() function returns the XML definition of an
XMLElement.
- Source:
Returns:
the XML definition of this XMLElement
- Type
- String
year() → {float}
Processing communicates with the clock on your computer.
The year() function returns the current year as an
integer (2003, 2004, 2005, etc).
Returns:
The current year.
- Type
- float