Skip to content

Quick Reference

Claudio Esperança edited this page Oct 10, 2016 · 2 revisions

Introduction

You will find below a short (and I mean short) summary of the functions and variables defined by pyprocessing. Each entry contains a Processing feature with a link to the reference page of that feature in the Processing site, the pyprocessing equivalent, if any, and a brief description of that feature.

As a rule, pyprocessing functions have exactly the same name of their Processing counterparts, and allow the same argument variations. On the other hand, global variables necessarily have to follow a different naming convention in pyprocessing. When a global variable names in Processing is a composite word, the corresponding pyprocessing name is the first word followed by the remaining words in lowercase. For instance, Processing's mouseX variable is called mouse.x in pyprocessing. The notable exception is key, which is equivalent to key.char in pyprocessing.

This is still incomplete! Browsing the examples in the repository will give you a more up-to-date picture of pyprocessing's features.

Structure

Processing pyprocessing Description
draw() draw() a function of your program that is called for drawing
a frame
exit() exit() exits the application
loop() loop() makes draw() be called periodically
noLoop() noLoop() stops draw() fro being called periodically
popStyle() popStyle() restores the prior style settings
pushStyle() pushStyle() saves the current style settings
redraw() redraw
N/A run() your program should call this to map the drawing
window and start the event loop
setup() setup() a function of your program that is called
automatically once by run()
size() size() used to establish the dimensions of the drawing window

Image

Processing pyprocessing Description
createImage() createImage() creates an empty PImage object
filter() screenFilter() applies a filter to the display window
image() image() displays a PImage object
imageMode() imageMode() changes the semantics of the arguments of image()
loadImage() loadImage() loads an image into a PImage object
loadPixels() loadPixels() loads the current canvas data into screen.pixels
updatePixels() updatePixels() displays the data from screen.pixels
get() get() returns a copy, a part of a pixel of the screen
set() setScreen() sets a position of the screen with data

Environment

Processing pyprocessing Description
cursor() cursor() Changes or shows the mouse cursor.
delay() delay() stops the program from running for a specified time
day() day() returns the value of the current day
focused N/A
frameCount frame.count Number of frames drawn so far.
frameRate() frameRate() Sets the number of times draw() will be called per second.
frameRate frame.rate Estimated number of frames per second for the recent past.
height height Height of the drawing window in pixels.
hour() hour() returns the value of the current hour
link() link() links to a webpage
millis() millis() returns the amount of milliseconds since starting a program
minute() minute() returns the value of the current minute
month() month() returns the value of the current month
noCursor() noCursor() Inhibits the display of the mouse cursor.
online N/A
screen screen holds the width, height and pixels of the display.
second() second() returns the value of the current second
year() year() returns the value of the current year
width width width of the drawing window in pixels

Color

Setting

Processing pyprocessing Description
background() background() clears the drawing with a background color
colorMode() colorMode() sets up the color system (RGB or HSB) for specifying
colors
fill() fill() specifies the color for drawing filled shapes
noFill() noFill() makes shapes be rendered non-filled
noStroke() noStroke() makes shapes be rendered without their borders
stroke() stroke() specifies the color for drawing lines and shape borders
noTint() noTint() reverts to displaying images with their original values
tint() tint() sets the fill value for displaying images

Creating & Reading

Processing pyprocessing Description
alpha() alpha() returns the alpha (transparency) component of a color
blendColor() blendColor() returns the blending between two colors
blue() blue() returns the blue component of a color
brightness() brightness() returns the brightness of a color
color() color() builds a color value from its components
green() green() returns the green component of a color
hue() hue() returns the hue of a color
lerpColor() lerpColor() returns a linear interpolation between two colors
red() red() returns the red component of a color
saturation() saturation() returns the saturation of a color

Shape

2D Primitives

Processing pyprocessing Description
arc() arc() draws an arc of ellipse
ellipse() ellipse() draws an ellipse
line() line() draws a line segment
point() point() draws a point
quad() quad() draws a quadrilateral
rect() rect() draws a rectangle
triangle() triangle() draws a triangle

3D Primitives

Processing pyprocessing Description
box() box() draws a parallelepiped
sphere() sphere() draws a sphere
sphereDetail() sphereDetail() sets the level of detail used to render spheres

Curves

Processing pyprocessing Description
bezier() bezier() Draws a cubic Bézier curve
bezierDetail() bezierDetail() Changes sampling rate of Bézier curves
bezierPoint() bezierPoint() Evaluates one coordinate of a point on a Bézier curve
bezierTangent() bezierTangent() Evaluates one coordinate of a tangent of a Bézier curve
curve() curve() Draws a cubic Catmull-Rom curve
curveDetail() curveDetail() Changes the sampling rate of Catmull-Rom curves
curvePoint() curvePoint() Evaluates one coordinate of a point of
a Catmull-Rom curve
curveTangent() curveTangent() Evaluates one coordinate of a tangent of
a Catmull-Rom curve
curveTightness() curveTightness() Changes the tightness of Catmull-Rom curves

Attributes

Processing pyprocessing Description
noSmooth() noSmooth() renders in non-antialiased mode
rectMode() rectMode() changes the semantics of the arguments of rect()
ellipseMode() ellipseMode() changes the semantics of the arguments of ellipse()
smooth() smooth() renders in antialiased mode
strokeCap() N/A
strokeJoin() N/A
strokeWeight() strokeWeight() changes the thickness of lines

Vertex

Processing pyprocessing Description
bezierVertex() bezierVertex() adds a Bézier arc to the shape
curveVertex() curveVertex() adds a Catmull-Rom arc to the shape
endShape() endVertex() finishes the shape
texture() texture() sets a texture to be applied when drawing
textureMode() textureMode() changes how texture coordinates are evalued
vertex() vertex() adds a vertex to the shape

Input

Mouse

Processing pyprocessing Description
mouseButton mouse.button tells what mouse button is pressed.
mouseClicked() mouseClicked() called when a mouse button is pressed and released
mouseDragged() mouseDragged() called when a mouse is dragged with a pressed button
mouseMoved() mouseMoved() called when a mouse is moved with buttons pressed
mousePressed() mousePressed() called when a mouse button is pressed
mousePressed mouse.pressed tells whether a mouse button is pressed
mouseReleased() mouseReleased() called when a mouse button is released
mouseX mouse.x current x position of the mouse
mouseY mouse.y current y position of the mouse
pmouseX pmouse.x previous x position of the mouse
pmouseY pmouse.y previous y position of the mouse

Keyboard

Processing pyprocessing Description
key key.char holds the char value of the most recently pressed key
keyCode key.code holds an int code of the most recently pressed key
keyPressed() keyPressed() called when a key is pressed
keyPressed key.pressed() tells whether a key is pressed
keyReleased() keyReleased() called when a key is released
keyTyped() keyTyped() called when a non-code key is pressed

Text

Processing pyprocessing Description
textAlign() textAlign() changes the text alignment attributes
createFont() createFont() creates a font
textFont() textFont() sets the received font as current font
htmlText() htmlText() draws the html text at the given position
text() text() draws the text at the given position
textSize() textSize() changes the current font size
textWidth() textWidth() returns the width of the received string rendered in the current font
textAscent() textAscent() returns the ascent of the current font
textDescent() textDescent() returns the descent of the current font

Math

Processing pyprocessing Description
PVector PVector a class used to describe two or three dimensional vectors
noise() noise() returns the perlin noise value at specified coordinates
binary() binary() converts a value to a string in binary notation
hex() hex() converts a value to a string in hexadecimal notation
unbinary() unbinary() converts a string in binary notation to its decimal value
unhex() unhex() converts a string in hexadecimal notation to its decimal value
byte() byte() converts a char or int to its byte representation
constrain() constrain() returns the constrained value according to the received parameters
dist() dist() returns the Euclidean distance between two points
map() map() re-maps a number from one range to another
mag() mag() returns the magnitude of a vector
lerp() lerp() returns a interpolation between two numbers
sq() sq() returns the square of a value

Transform

Processing pyprocessing Description
applyMatrix() applyMatrix() multiplies the current transformation matrix by a
given matrix
getMatrix() getMatrix() returns the MODELVIEW matrix
popMatrix() popMatrix() discards the current (top) matrix from the
transformation matrix stack
printMatrix() printMatrix() prints the current transformation matrix
pushMatrix() pushMatrix() pushes a copy of the current matrix onto the
transformation matrix stack
resetMatrix() resetMatrix() sets an identity matrix as the the current
transformation matrix
rotate() rotate() rotates around a given axis
rotateX() rotateX() rotates around the x axis
rotateY() rotateY() rotates around the y axis
rotateZ() rotateZ() rotates around the z axis
shearX() shearX() shears a shape around the x axis
shearY() shearY() shears a shape around the y axis
scale() scale() performs a scale transformation
translate() translate() performs a translation transformation

Lights, Camera

Lights

Processing pyprocessing Description
ambientLight() ambientLight() adds an ambient light source
directionalLight() directionalLight adds a directional light source
lightFalloff() lightFalloff() sets attenuation factors for next light sources
lightSpecular() lightSpecular() sets specular coefficients for next light sources
lights() lights() turns on lighting and default light sources
noLights() noLights() turns off lighting
normal() normal() sets the normal vector for subsequent vertices
pointLight() pointLight() adds a point light source
spotLight() spotLight() adds a spot light source

Camera

Processing pyprocessing Description
beginCamera() N/A
camera() camera() sets the camera transformation
endCamera() N/A
frustum() N/A
ortho() ortho() sets an orthogonal projection
perspective() perspective() sets a perspective projection
printCamera() printCamera() prints the current transformation matrix
getProjection() getProjection() returns the PROJECTION matrix
printProjection() printProjection() prints the current projection matrix

Coordinates

Processing pyprocessing Description
modelX() modelX() returns the screen x coordinate of given object
coordinates
modelY() modelY() returns the screen y coordinate of given object
coordinates
modelZ() modelZ() returns the screen z coordinate of given object
coordinates
N/A modelXYZ() returns the screen coordinates of given object
coordinates
screenX() screenX() returns the screen x coordinate of given object
coordinates
screenY() screenY() returns the screen y coordinate of given object
coordinates
screenZ() screenY() returns the screen z coordinate of given object
coordinates
N/A screenXYZ() returns the screen coordinates of given object
coordinates

Material Properties

Processing pyprocessing Description
ambient() ambient() sets the ambient properties of the next vertices
emissive() emissive() sets the emissive properties of the next vertices
shininess() shininess() sets the shininess property of the next vertices
specular() specular() sets the specular properties of the next vertices