processing.core
Class PApplet

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by java.applet.Applet
                  extended by processing.core.PApplet
All Implemented Interfaces:
java.awt.event.FocusListener, java.awt.event.KeyListener, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable, java.lang.Runnable, java.util.EventListener, javax.accessibility.Accessible, PConstants
Direct Known Subclasses:
ColorSelector.ColorRange, ColorSelector.ColorSlider

public class PApplet
extends java.applet.Applet
implements PConstants, java.lang.Runnable, java.awt.event.MouseListener, java.awt.event.MouseMotionListener, java.awt.event.KeyListener, java.awt.event.FocusListener

Base class for all sketches that use processing.core.

Note that you should not use AWT or Swing components inside a Processing applet. The surface is made to automatically update itself, and will cause problems with redraw of components drawn above it. If you'd like to integrate other Java components, see below.

As of release 0145, Processing uses active mode rendering in all cases. All animation tasks happen on the "Processing Animation Thread". The setup() and draw() methods are handled by that thread, and events (like mouse movement and key presses, which are fired by the event dispatch thread or EDT) are queued to be (safely) handled at the end of draw(). For code that needs to run on the EDT, use SwingUtilities.invokeLater(). When doing so, be careful to synchronize between that code (since invokeLater() will make your code run from the EDT) and the Processing animation thread. Use of a callback function or the registerXxx() methods in PApplet can help ensure that your code doesn't do something naughty.

As of release 0136 of Processing, we have discontinued support for versions of Java prior to 1.5. We don't have enough people to support it, and for a project of our size, we should be focusing on the future, rather than working around legacy Java code. In addition, Java 1.5 gives us access to better timing facilities which will improve the steadiness of animation.

This class extends Applet instead of JApplet because 1) historically, we supported Java 1.1, which does not include Swing (without an additional, sizable, download), and 2) Swing is a bloated piece of crap. A Processing applet is a heavyweight AWT component, and can be used the same as any other AWT component, with or without Swing.

Similarly, Processing runs in a Frame and not a JFrame. However, there's nothing to prevent you from embedding a PApplet into a JFrame, it's just that the base version uses a regular AWT frame because there's simply no need for swing in that context. If people want to use Swing, they can embed themselves as they wish.

It is possible to use PApplet, along with core.jar in other projects. In addition to enabling you to use Java 1.5+ features with your sketch, this also allows you to embed a Processing drawing area into another Java application. This means you can use standard GUI controls with a Processing sketch. Because AWT and Swing GUI components cannot be used on top of a PApplet, you can instead embed the PApplet inside another GUI the way you would any other Component.

It is also possible to resize the Processing window by including frame.setResizable(true) inside your setup() method. Note that the Java method frame.setSize() will not work unless you first set the frame to be resizable.

Because the default animation thread will run at 60 frames per second, an embedded PApplet can make the parent sluggish. You can use frameRate() to make it update less often, or you can use noLoop() and loop() to disable and then re-enable looping. If you want to only update the sketch intermittently, use noLoop() inside setup(), and redraw() whenever the screen needs to be updated once (or loop() to re-enable the animation thread). The following example embeds a sketch and also uses the noLoop() and redraw() methods. You need not use noLoop() and redraw() when embedding if you want your application to animate continuously.

 public class ExampleFrame extends Frame {

     public ExampleFrame() {
         super("Embedded PApplet");

         setLayout(new BorderLayout());
         PApplet embed = new Embedded();
         add(embed, BorderLayout.CENTER);

         // important to call this whenever embedding a PApplet.
         // It ensures that the animation thread is started and
         // that other internal variables are properly set.
         embed.init();
     }
 }

 public class Embedded extends PApplet {

     public void setup() {
         // original setup code here ...
         size(400, 400);

         // prevent thread from starving everything else
         noLoop();
     }

     public void draw() {
         // drawing code goes here
     }

     public void mousePressed() {
         // do something based on mouse movement

         // update the screen (run draw once)
         redraw();
     }
 }
 

Processing on multiple displays

I was asked about Processing with multiple displays, and for lack of a better place to document it, things will go here.

You can address both screens by making a window the width of both, and the height of the maximum of both screens. In this case, do not use present mode, because that's exclusive to one screen. Basically it'll give you a PApplet that spans both screens. If using one half to control and the other half for graphics, you'd just have to put the 'live' stuff on one half of the canvas, the control stuff on the other. This works better in windows because on the mac we can't get rid of the menu bar unless it's running in present mode.

For more control, you need to write straight java code that uses p5. You can create two windows, that are shown on two separate screens, that have their own PApplet. this is just one of the tradeoffs of one of the things that we don't support in p5 from within the environment itself (we must draw the line somewhere), because of how messy it would get to start talking about multiple screens. It's also not that tough to do by hand w/ some Java code.

See Also:
Serialized Form

Nested Class Summary
 class PApplet.RegisteredMethods
          This returns the last width and height specified by the user via the size() command.
static class PApplet.RendererChangeException
          Exception thrown when size() is called the first time.
 
Field Summary
 java.lang.String[] args
          Command line options passed in from main().
static java.lang.String ARGS_BGCOLOR
           
static java.lang.String ARGS_DISPLAY
           
static java.lang.String ARGS_EDITOR_LOCATION
          Position of the upper-lefthand corner of the editor window that launched this applet.
static java.lang.String ARGS_EXCLUSIVE
           
static java.lang.String ARGS_EXTERNAL
          Location for where to position the applet window on screen.
static java.lang.String ARGS_HIDE_STOP
           
static java.lang.String ARGS_LOCATION
           
static java.lang.String ARGS_PRESENT
           
static java.lang.String ARGS_SKETCH_FOLDER
          Allows the user or PdeEditor to set a specific sketch folder path.
static java.lang.String ARGS_STOP_COLOR
           
static int DEFAULT_HEIGHT
           
static int DEFAULT_WIDTH
          Default width and height for applet when not specified
 boolean defaultSize
          true if no size() command has been executed.
static java.lang.String EXTERNAL_MOVE
          When run externally to a PDE Editor, this is sent by the applet whenever the window is moved.
static java.lang.String EXTERNAL_STOP
          When run externally to a PdeEditor, this is sent by the applet when it quits.
 boolean finished
          true if this applet has had it.
 boolean firstMouse
          Used to set pmouseX/Y to mouseX/Y the first time mouseX/Y are used, otherwise pmouseX/Y are always zero, causing a nasty jump.
 boolean focused
          Gets set to true/false as the applet gains/loses focus.
 java.awt.Frame frame
          The frame containing this applet (if any)
 int frameCount
          How many frames have been displayed since the applet started.
 float frameRate
          The current value of frames per second.
 PGraphics g
          The PGraphics renderer associated with this PApplet
 int height
          height of this applet's associated PGraphics
static byte[] ICON_IMAGE
          GIF image of the Processing logo.
static float javaVersion
          Version of Java that's in use, whether 1.1 or 1.3 or whatever, stored as a float.
static java.lang.String javaVersionName
          Full name of the Java version (i.e.
 char key
          Last key pressed.
 int keyCode
          When "key" is set to CODED, this will contain a Java key code.
 java.awt.event.KeyEvent keyEvent
          the last KeyEvent object passed into a mouse function.
 boolean keyPressed
          true if the mouse is currently pressed.
static int MENU_SHORTCUT
          Modifier flags for the shortcut key used to trigger menus.
static int MIN_WINDOW_HEIGHT
           
static int MIN_WINDOW_WIDTH
          Minimum dimensions for the window holding an applet.
 int mouseButton
          Last mouse button pressed, one of LEFT, CENTER, or RIGHT.
 java.awt.event.MouseEvent mouseEvent
           
 boolean mousePressed
           
 int mouseX
          current x position of the mouse
 int mouseY
          current y position of the mouse
 boolean online
          true if the applet is online.
 int[] pixels
          Pixel buffer from this applet's PGraphics.
static int platform
          Current platform in use, one of the PConstants WINDOWS, MACOSX, MACOS9, LINUX or OTHER.
 int pmouseX
          Previous x/y position of the mouse.
 int pmouseY
          Previous x/y position of the mouse.
 PGraphics recorder
          A leech graphics object that is echoing all events.
 int requestImageMax
          By trial and error, four image loading threads seem to work best when loading images from online.
 java.awt.Dimension screen
          The screen size when the applet was started.
 java.io.File selectedFile
           
 java.lang.String sketchPath
          Path to sketch folder
 int width
          width of this applet's associated PGraphics
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface processing.core.PConstants
A, AB, ADD, AG, ALPHA, ALPHA_MASK, ALT, AMBIENT, AR, ARC, ARGB, ARROW, B, BACKSPACE, BASELINE, BEEN_LIT, BEVEL, BLEND, BLUE_MASK, BLUR, BOTTOM, BOX, BURN, CENTER, CENTER_DIAMETER, CENTER_RADIUS, CHATTER, CLOSE, CMYK, CODED, COMPLAINT, CONTROL, CORNER, CORNERS, CROSS, CUSTOM, DA, DARKEST, DB, DEG_TO_RAD, DELETE, DG, DIAMETER, DIFFERENCE, DILATE, DIRECTIONAL, DISABLE_ACCURATE_TEXTURES, DISABLE_DEPTH_SORT, DISABLE_DEPTH_TEST, DISABLE_OPENGL_2X_SMOOTH, DISABLE_OPENGL_ERROR_REPORT, DODGE, DOWN, DR, DXF, EB, EDGE, EG, ELLIPSE, ENABLE_ACCURATE_TEXTURES, ENABLE_DEPTH_SORT, ENABLE_DEPTH_TEST, ENABLE_NATIVE_FONTS, ENABLE_OPENGL_2X_SMOOTH, ENABLE_OPENGL_4X_SMOOTH, ENABLE_OPENGL_ERROR_REPORT, ENTER, EPSILON, ER, ERODE, ERROR_BACKGROUND_IMAGE_FORMAT, ERROR_BACKGROUND_IMAGE_SIZE, ERROR_PUSHMATRIX_OVERFLOW, ERROR_PUSHMATRIX_UNDERFLOW, ERROR_TEXTFONT_NULL_PFONT, ESC, EXCLUSION, G, GIF, GRAY, GREEN_MASK, HALF_PI, HAND, HARD_LIGHT, HINT_COUNT, HSB, IMAGE, INVERT, JAVA2D, JPEG, LEFT, LIGHTEST, LINE, LINES, LINUX, MACOSX, MAX_FLOAT, MAX_INT, MIN_FLOAT, MIN_INT, MITER, MODEL, MOVE, MULTIPLY, NORMAL, NORMALIZED, NX, NY, NZ, OPAQUE, OPEN, OPENGL, ORTHOGRAPHIC, OTHER, OVERLAY, P2D, P3D, PATH, PDF, PERSPECTIVE, PI, platformNames, POINT, POINTS, POLYGON, POSTERIZE, PROBLEM, PROJECT, QUAD, QUAD_STRIP, QUADS, QUARTER_PI, R, RAD_TO_DEG, RADIUS, RECT, RED_MASK, REPLACE, RETURN, RGB, RIGHT, ROUND, SA, SB, SCREEN, SG, SHAPE, SHIFT, SHINE, SOFT_LIGHT, SPB, SPG, SPHERE, SPOT, SPR, SQUARE, SR, SUBTRACT, SW, TAB, TARGA, TEXT, THIRD_PI, THRESHOLD, TIFF, TOP, TRIANGLE, TRIANGLE_FAN, TRIANGLE_STRIP, TRIANGLES, TWO_PI, TX, TY, TZ, U, UP, V, VERTEX_FIELD_COUNT, VW, VX, VY, VZ, WAIT, WHITESPACE, WINDOWS, X, Y, Z
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PApplet()
           
 
Method Summary
static float abs(float n)
           
static int abs(int n)
           
static float acos(float value)
           
 void addListeners()
           
 float alpha(int what)
           
 void ambient(float gray)
           
 void ambient(float x, float y, float z)
           
 void ambient(int rgb)
           
 void ambientLight(float red, float green, float blue)
           
 void ambientLight(float red, float green, float blue, float x, float y, float z)
           
static byte[] append(byte[] b, byte value)
           
static char[] append(char[] b, char value)
           
static float[] append(float[] b, float value)
           
static int[] append(int[] b, int value)
           
static java.lang.Object append(java.lang.Object b, java.lang.Object value)
           
static java.lang.String[] append(java.lang.String[] b, java.lang.String value)
           
 void applyMatrix(float n00, float n01, float n02, float n10, float n11, float n12)
           
 void applyMatrix(float n00, float n01, float n02, float n03, float n10, float n11, float n12, float n13, float n20, float n21, float n22, float n23, float n30, float n31, float n32, float n33)
           
 void applyMatrix(PMatrix source)
           
 void applyMatrix(PMatrix2D source)
           
 void applyMatrix(PMatrix3D source)
           
 void arc(float a, float b, float c, float d, float start, float stop)
           
static void arraycopy(java.lang.Object src, int srcPosition, java.lang.Object dst, int dstPosition, int length)
          Deprecated. Use arrayCopy() instead.
static void arrayCopy(java.lang.Object src, int srcPosition, java.lang.Object dst, int dstPosition, int length)
          Calls System.arraycopy(), included here so that we can avoid people needing to learn about the System object before they can just copy an array.
static void arraycopy(java.lang.Object src, java.lang.Object dst)
          Deprecated. Use arrayCopy() instead.
static void arrayCopy(java.lang.Object src, java.lang.Object dst)
          Shortcut to copy the entire contents of the source into the destination array.
static void arraycopy(java.lang.Object src, java.lang.Object dst, int length)
          Deprecated. Use arrayCopy() instead.
static void arrayCopy(java.lang.Object src, java.lang.Object dst, int length)
          Convenience method for arraycopy().
static float asin(float value)
           
static float atan(float value)
           
static float atan2(float a, float b)
           
 void background(float gray)
           
 void background(float gray, float alpha)
           
 void background(float x, float y, float z)
           
 void background(float x, float y, float z, float a)
           
 void background(int rgb)
           
 void background(int rgb, float alpha)
           
 void background(PImage image)
           
 void beginCamera()
           
 void beginRaw(PGraphics rawGraphics)
          Begin recording raw shape data to the specified renderer.
 PGraphics beginRaw(java.lang.String renderer, java.lang.String filename)
          Begin recording raw shape data to a renderer of the specified type, using the width and height of the main drawing surface.
 void beginRecord(PGraphics recorder)
          Begin recording (echoing) commands to the specified PGraphics object.
 PGraphics beginRecord(java.lang.String renderer, java.lang.String filename)
          Begin recording to a new renderer of the specified type, using the width and height of the main drawing surface.
 void beginShape()
           
 void beginShape(int kind)
           
 void bezier(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
           
 void bezier(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4)
           
 void bezierDetail(int detail)
           
 float bezierPoint(float a, float b, float c, float d, float t)
           
 float bezierTangent(float a, float b, float c, float d, float t)
           
 void bezierVertex(float x2, float y2, float x3, float y3, float x4, float y4)
           
 void bezierVertex(float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4)
           
static java.lang.String binary(byte what)
          Returns a String that contains the binary value of a byte.
static java.lang.String binary(char what)
          Returns a String that contains the binary value of a char.
static java.lang.String binary(int what)
          Returns a String that contains the binary value of an int.
static java.lang.String binary(int what, int digits)
          Returns a String that contains the binary value of an int.
 void blend(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int mode)
           
 void blend(PImage src, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, int mode)
           
static int blendColor(int c1, int c2, int mode)
           
 float blue(int what)
           
 void box(float size)
           
 void box(float w, float h, float d)
           
 void breakShape()
           
 float brightness(int what)
           
 void camera()
           
 void camera(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ)
           
static int ceil(float what)
           
 int color(float fgray)
           
 int color(float fgray, float falpha)
           
 int color(float x, float y, float z)
           
 int color(float x, float y, float z, float a)
           
 int color(int gray)
           
 int color(int gray, int alpha)
          As of 0116 this also takes color(#FF8800, alpha)
 int color(int x, int y, int z)
           
 int color(int x, int y, int z, int a)
           
 void colorMode(int mode)
           
 void colorMode(int mode, float max)
           
 void colorMode(int mode, float maxX, float maxY, float maxZ)
           
 void colorMode(int mode, float maxX, float maxY, float maxZ, float maxA)
           
static boolean[] concat(boolean[] a, boolean[] b)
           
static byte[] concat(byte[] a, byte[] b)
           
static char[] concat(char[] a, char[] b)
           
static float[] concat(float[] a, float[] b)
           
static int[] concat(int[] a, int[] b)
           
static java.lang.Object concat(java.lang.Object a, java.lang.Object b)
           
static java.lang.String[] concat(java.lang.String[] a, java.lang.String[] b)
           
static float constrain(float amt, float low, float high)
           
static int constrain(int amt, int low, int high)
           
 void copy(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh)
           
 void copy(PImage src, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh)
           
static float cos(float angle)
           
 PFont createFont(java.lang.String name, float size)
           
 PFont createFont(java.lang.String name, float size, boolean smooth)
           
 PFont createFont(java.lang.String name, float size, boolean smooth, char[] charset)
          Create a .vlw font on the fly from either a font name that's installed on the system, or from a .ttf or .otf that's inside the data folder of this sketch.
 PGraphics createGraphics(int iwidth, int iheight, java.lang.String irenderer)
          Create an offscreen PGraphics object for drawing.
 PGraphics createGraphics(int iwidth, int iheight, java.lang.String irenderer, java.lang.String ipath)
          Create an offscreen graphics surface for drawing, in this case for a renderer that writes to a file (such as PDF or DXF).
 PImage createImage(int wide, int high, int format)
          Preferred method of creating new PImage objects, ensures that a reference to the parent PApplet is included, which makes save() work without needing an absolute path.
static java.io.InputStream createInput(java.io.File file)
           
 java.io.InputStream createInput(java.lang.String filename)
          Simplified method to open a Java InputStream.
 java.io.InputStream createInputRaw(java.lang.String filename)
          Call openStream() without automatic gzip decompression.
static java.io.OutputStream createOutput(java.io.File file)
           
 java.io.OutputStream createOutput(java.lang.String filename)
          Similar to createInput() (formerly openStream), this creates a Java OutputStream for a given filename or path.
static void createPath(java.io.File file)
           
static void createPath(java.lang.String path)
          Takes a path and creates any in-between folders if they don't already exist.
static java.io.BufferedReader createReader(java.io.File file)
          I want to read lines from a file.
static java.io.BufferedReader createReader(java.io.InputStream input)
          I want to read lines from a stream.
 java.io.BufferedReader createReader(java.lang.String filename)
          I want to read lines from a file.
static java.io.PrintWriter createWriter(java.io.File file)
          I want to print lines to a file.
static java.io.PrintWriter createWriter(java.io.OutputStream output)
          I want to print lines to a file.
 java.io.PrintWriter createWriter(java.lang.String filename)
          I want to print lines to a file.
 void cursor()
          Show the cursor after noCursor() was called.
 void cursor(int cursorType)
          Set the cursor type
 void cursor(PImage image)
          Replace the cursor with the specified PImage.
 void cursor(PImage image, int hotspotX, int hotspotY)
          Set a custom cursor to an image with a specific hotspot.
 void curve(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
           
 void curve(float x1, float y1, float z1, float x2, float y2, float z2, float x3, float y3, float z3, float x4, float y4, float z4)
           
 void curveDetail(int detail)
           
 float curvePoint(float a, float b, float c, float d, float t)
           
 float curveTangent(float a, float b, float c, float d, float t)
           
 void curveTightness(float tightness)
           
 void curveVertex(float x, float y)
           
 void curveVertex(float x, float y, float z)
           
 java.io.File dataFile(java.lang.String where)
          Return a full path to an item in the data folder as a File object.
 java.lang.String dataPath(java.lang.String where)
          Return a full path to an item in the data folder.
static int day()
          Get the current day of the month (1 through 31).
static float degrees(float radians)
           
 void delay(int napTime)
          The delay() function causes the program to halt for a specified time.
 void destroy()
          Called by the browser or applet viewer to inform this applet that it is being reclaimed and that it should destroy any resources that it has allocated.
 void die(java.lang.String what)
          Function for an applet/application to kill itself and display an error.
 void die(java.lang.String what, java.lang.Exception e)
          Same as above but with an exception.
 void directionalLight(float red, float green, float blue, float nx, float ny, float nz)
           
 boolean displayable()
           
static float dist(float x1, float y1, float x2, float y2)
           
static float dist(float x1, float y1, float z1, float x2, float y2, float z2)
           
 void draw()
           
 void edge(boolean edge)
           
 void ellipse(float a, float b, float c, float d)
           
 void ellipseMode(int mode)
           
 void emissive(float gray)
           
 void emissive(float x, float y, float z)
           
 void emissive(int rgb)
           
 void endCamera()
           
 void endRaw()
          Stop recording raw shape data to the specified renderer.
 void endRecord()
           
 void endShape()
           
 void endShape(int mode)
           
static java.lang.Process exec(java.lang.String[] argv)
           
 void exit()
          Call to safely exit the sketch when finished.
static float exp(float a)
           
static boolean[] expand(boolean[] list)
           
static boolean[] expand(boolean[] list, int newSize)
           
static byte[] expand(byte[] list)
           
static byte[] expand(byte[] list, int newSize)
           
static char[] expand(char[] list)
           
static char[] expand(char[] list, int newSize)
           
static float[] expand(float[] list)
           
static float[] expand(float[] list, int newSize)
           
static int[] expand(int[] list)
           
static int[] expand(int[] list, int newSize)
           
static java.lang.Object expand(java.lang.Object array)
           
static java.lang.Object expand(java.lang.Object list, int newSize)
           
static java.lang.String[] expand(java.lang.String[] list)
           
static java.lang.String[] expand(java.lang.String[] list, int newSize)
           
 void fill(float gray)
           
 void fill(float gray, float alpha)
           
 void fill(float x, float y, float z)
           
 void fill(float x, float y, float z, float a)
           
 void fill(int rgb)
           
 void fill(int rgb, float alpha)
           
 void filter(int kind)
           
 void filter(int kind, float param)
           
static int floor(float what)
           
 void flush()
           
 void focusGained()
           
 void focusGained(java.awt.event.FocusEvent e)
           
 void focusLost()
           
 void focusLost(java.awt.event.FocusEvent e)
           
 void frameRate(float newRateTarget)
          Set a target frameRate.
 void frustum(float left, float right, float bottom, float top, float near, float far)
           
 PImage get()
           
 int get(int x, int y)
           
 PImage get(int x, int y, int w, int h)
           
 java.lang.Object getCache(java.lang.Object parent)
           
 PMatrix getMatrix()
           
 PMatrix2D getMatrix(PMatrix2D target)
           
 PMatrix3D getMatrix(PMatrix3D target)
           
 int getSketchHeight()
           
 java.lang.String getSketchRenderer()
           
 int getSketchWidth()
           
 float green(int what)
           
 void handleDraw()
           
static java.lang.String hex(byte what)
           
static java.lang.String hex(char what)
           
static java.lang.String hex(int what)
           
static java.lang.String hex(int what, int digits)
           
 void hint(int which)
           
static int hour()
          Hour position of the current time in international format (0-23).
 float hue(int what)
           
 void image(PImage image, float x, float y)
           
 void image(PImage image, float x, float y, float c, float d)
           
 void image(PImage image, float a, float b, float c, float d, int u1, int v1, int u2, int v2)
           
 void imageMode(int mode)
           
 void init()
           
static java.lang.String join(java.lang.String[] str, char separator)
          Join an array of Strings together as a single String, separated by the whatever's passed in for the separator.
static java.lang.String join(java.lang.String[] str, java.lang.String separator)
          Join an array of Strings together as a single String, separated by the whatever's passed in for the separator.
 void keyPressed()
          Called each time a single key on the keyboard is pressed.
 void keyPressed(java.awt.event.KeyEvent e)
          Overriding keyXxxxx(KeyEvent e) functions will cause the 'key', 'keyCode', and 'keyEvent' variables to no longer work; key events will no longer be queued until the end of draw(); and the keyPressed(), keyReleased() and keyTyped() methods will no longer be called.
 void keyReleased()
          See keyPressed().
 void keyReleased(java.awt.event.KeyEvent e)
           
 void keyTyped()
          Only called for "regular" keys like letters, see keyPressed() for full documentation.
 void keyTyped(java.awt.event.KeyEvent e)
           
static float lerp(float start, float stop, float amt)
           
 int lerpColor(int c1, int c2, float amt)
           
static int lerpColor(int c1, int c2, float amt, int mode)
           
 void lightFalloff(float constant, float linear, float quadratic)
           
 void lights()
           
 void lightSpecular(float x, float y, float z)
           
 void line(float x1, float y1, float x2, float y2)
           
 void line(float x1, float y1, float z1, float x2, float y2, float z2)
           
 void link(java.lang.String here)
           
 void link(java.lang.String url, java.lang.String frameTitle)
          Link to an external page without all the muss.
static byte[] loadBytes(java.io.File file)
           
static byte[] loadBytes(java.io.InputStream input)
           
 byte[] loadBytes(java.lang.String filename)
           
 PFont loadFont(java.lang.String filename)
           
 PImage loadImage(java.lang.String filename)
          Load an image from the data folder or a local directory.
 PImage loadImage(java.lang.String filename, java.lang.String extension)
          Identical to loadImage, but allows you to specify the type of image by its extension.
 void loadPixels()
          Override the g.pixels[] function to set the pixels[] array that's part of the PApplet object.
 PShape loadShape(java.lang.String filename)
          Load a geometry from a file as a PShape.
static java.lang.String[] loadStrings(java.io.File file)
           
static java.lang.String[] loadStrings(java.io.InputStream input)
           
 java.lang.String[] loadStrings(java.lang.String filename)
          Load data from a file and shove it into a String array.
static float log(float a)
           
 void loop()
           
static float mag(float a, float b)
           
static float mag(float a, float b, float c)
           
static void main(java.lang.String[] args)
          main() method for running this class from the command line.
static float map(float value, float istart, float istop, float ostart, float ostop)
          Convenience function to map a variable from one coordinate space to another.
 void mask(int[] alpha)
           
 void mask(PImage alpha)
           
static java.lang.String[] match(java.lang.String what, java.lang.String regexp)
          Match a string with a regular expression, and returns the match as an array.
static java.lang.String[][] matchAll(java.lang.String what, java.lang.String regexp)
          Identical to match(), except that it returns an array of all matches in the specified String, rather than just the first.
static float max(float[] list)
          Find the maximum value in an array.
static float max(float a, float b)
           
static float max(float a, float b, float c)
           
static int max(int[] list)
          Find the maximum value in an array.
static int max(int a, int b)
           
static int max(int a, int b, int c)
           
 int millis()
          Get the number of milliseconds since the applet started.
static float min(float[] list)
          Find the minimum value in an array.
static float min(float a, float b)
           
static float min(float a, float b, float c)
           
static int min(int[] list)
          Find the minimum value in an array.
static int min(int a, int b)
           
static int min(int a, int b, int c)
           
static int minute()
          Minutes position of the current time.
 float modelX(float x, float y, float z)
           
 float modelY(float x, float y, float z)
           
 float modelZ(float x, float y, float z)
           
static int month()
          Get the current month in range 1 through 12.
 void mouseClicked()
          When the mouse is clicked, mousePressed() will be called, then mouseReleased(), then mouseClicked().
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseDragged()
          Mouse button is pressed and the mouse has been dragged.
 void mouseDragged(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
           
 void mouseExited(java.awt.event.MouseEvent e)
           
 void mouseMoved()
          Mouse button is not pressed but the mouse has changed locations.
 void mouseMoved(java.awt.event.MouseEvent e)
           
 void mousePressed()
          Mouse has been pressed, and should be considered "down" until mouseReleased() is called.
 void mousePressed(java.awt.event.MouseEvent e)
          If you override this or any function that takes a "MouseEvent e" without calling its super.mouseXxxx() then mouseX, mouseY, mousePressed, and mouseEvent will no longer be set.
 void mouseReleased()
          Mouse button has been released.
 void mouseReleased(java.awt.event.MouseEvent e)
           
static java.lang.String[] nf(float[] num, int left, int right)
           
static java.lang.String nf(float num, int left, int right)
           
static java.lang.String[] nf(int[] num, int digits)
           
static java.lang.String nf(int num, int digits)
           
static java.lang.String[] nfc(float[] num, int right)
           
static java.lang.String nfc(float num, int right)
           
static java.lang.String nfc(int num)
           
static java.lang.String[] nfc(int[] num)
           
static java.lang.String[] nfp(float[] num, int left, int right)
           
static java.lang.String nfp(float num, int left, int right)
           
static java.lang.String[] nfp(int[] num, int digits)
           
static java.lang.String nfp(int num, int digits)
          number format positive (or plus) Formats a number, always placing a - or + sign in the front when it's negative or positive.
static java.lang.String[] nfs(float[] num, int left, int right)
          Number formatter that takes into account whether the number has a sign (positive, negative, etc) in front of it.
static java.lang.String nfs(float num, int left, int right)
           
static java.lang.String[] nfs(int[] num, int digits)
           
static java.lang.String nfs(int num, int digits)
          number format signed (or space) Formats a number but leaves a blank space in the front when it's positive so that it can be properly aligned with numbers that have a negative sign in front of them.
 void noCursor()
          Hide the cursor by creating a transparent image and using it as a custom cursor.
 void noFill()
           
 float noise(float x)
          Computes the Perlin noise function value at point x.
 float noise(float x, float y)
          Computes the Perlin noise function value at the point x, y.
 float noise(float x, float y, float z)
          Computes the Perlin noise function value at x, y, z.
 void noiseDetail(int lod)
           
 void noiseDetail(int lod, float falloff)
           
 void noiseSeed(long what)
           
 void noLights()
           
 void noLoop()
           
static float norm(float value, float start, float stop)
          Normalize a value to exist between 0 and 1 (inclusive).
 void normal(float nx, float ny, float nz)
           
 void noSmooth()
           
 void noStroke()
           
 void noTint()
           
static void open(java.lang.String filename)
          Attempt to open a file using the platform's shell.
static java.lang.Process open(java.lang.String[] argv)
          Launch a process using a platforms shell.
 java.io.InputStream openStream(java.lang.String filename)
          Deprecated. As of release 0136, use createInput() instead.
 void ortho()
           
 void ortho(float left, float right, float bottom, float top, float near, float far)
           
 void paint(java.awt.Graphics screen)
           
 java.lang.String param(java.lang.String what)
          Get a param from the web page, or (eventually) from a properties file.
static boolean[] parseBoolean(byte[] what)
          Convert a byte array to a boolean array.
static boolean parseBoolean(int what)
          Convert an integer to a boolean.
static boolean[] parseBoolean(int[] what)
          Convert an int array to a boolean array.
static boolean parseBoolean(java.lang.String what)
          Convert the string "true" or "false" to a boolean.
static boolean[] parseBoolean(java.lang.String[] what)
           
static byte parseByte(boolean what)
           
static byte[] parseByte(boolean[] what)
           
static float[] parseByte(byte[] what)
           
static byte parseByte(char what)
           
static byte[] parseByte(char[] what)
           
static byte parseByte(float what)
           
static byte[] parseByte(float[] what)
           
static byte parseByte(int what)
           
static byte[] parseByte(int[] what)
           
static char parseChar(byte what)
           
static char[] parseChar(byte[] what)
           
static char parseChar(int what)
           
static char[] parseChar(int[] what)
           
static float parseFloat(int what)
          Convert an int to a float value.
static float[] parseFloat(int[] what)
           
static float parseFloat(java.lang.String what)
           
static float[] parseFloat(java.lang.String[] what)
           
static float[] parseFloat(java.lang.String[] what, float missing)
           
static float parseFloat(java.lang.String what, float otherwise)
           
static int parseInt(boolean what)
           
static int[] parseInt(boolean[] what)
           
static int parseInt(byte what)
          Note that parseInt() will un-sign a signed byte value.
static int[] parseInt(byte[] what)
           
static int parseInt(char what)
          Note that parseInt('5') is unlike String in the sense that it won't return 5, but the ascii value.
static int[] parseInt(char[] what)
           
static int parseInt(float what)
          Same as floor(), or an (int) cast.
static int[] parseInt(float[] what)
           
static int parseInt(java.lang.String what)
          Parse a String into an int value.
static int[] parseInt(java.lang.String[] what)
          Make an array of int elements from an array of String objects.
static int[] parseInt(java.lang.String[] what, int missing)
          Make an array of int elements from an array of String objects.
static int parseInt(java.lang.String what, int otherwise)
          Parse a String to an int, and provide an alternate value that should be used when the number is invalid.
 void perspective()
           
 void perspective(float fovy, float aspect, float zNear, float zFar)
           
 void point(float x, float y)
           
 void point(float x, float y, float z)
           
 void pointLight(float red, float green, float blue, float x, float y, float z)
           
 void popMatrix()
           
 void popStyle()
           
static float pow(float a, float b)
           
static void print(boolean what)
           
static void print(byte what)
           
static void print(char what)
           
static void print(float what)
           
static void print(int what)
           
static void print(java.lang.Object what)
           
static void print(java.lang.String what)
           
 void printCamera()
           
static void println()
           
static void println(boolean what)
           
static void println(byte what)
           
static void println(char what)
           
static void println(float what)
           
static void println(int what)
           
static void println(java.lang.Object what)
           
static void println(java.lang.String what)
           
 void printMatrix()
           
 void printProjection()
           
 void pushMatrix()
           
 void pushStyle()
           
 void quad(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
           
static float radians(float degrees)
           
 float random(float howbig)
          Return a random number in the range [0, howbig).
 float random(float howsmall, float howbig)
          Return a random number in the range [howsmall, howbig).
 void randomSeed(long what)
           
 void rect(float a, float b, float c, float d)
           
 void rectMode(int mode)
           
 float red(int what)
           
 void redraw()
           
 void registerDispose(java.lang.Object o)
           
 void registerDraw(java.lang.Object o)
           
 void registerKeyEvent(java.lang.Object o)
           
 void registerMouseEvent(java.lang.Object o)
           
 void registerPost(java.lang.Object o)
           
 void registerPre(java.lang.Object o)
           
 void registerSize(java.lang.Object o)
           
 void removeCache(java.lang.Object parent)
           
 PImage requestImage(java.lang.String filename)
           
 PImage requestImage(java.lang.String filename, java.lang.String extension)
           
 void resetMatrix()
           
static boolean[] reverse(boolean[] list)
           
static byte[] reverse(byte[] list)
           
static char[] reverse(char[] list)
           
static float[] reverse(float[] list)
           
static int[] reverse(int[] list)
           
static java.lang.Object reverse(java.lang.Object list)
           
static java.lang.String[] reverse(java.lang.String[] list)
           
 void rotate(float angle)
           
 void rotate(float angle, float vx, float vy, float vz)
           
 void rotateX(float angle)
           
 void rotateY(float angle)
           
 void rotateZ(float angle)
           
static int round(float what)
           
 void run()
          Main method for the primary animation thread.
 float saturation(int what)
           
 void save(java.lang.String filename)
          Intercepts any relative paths to make them absolute (relative to the sketch folder) before passing to save() in PImage.
static void saveBytes(java.io.File file, byte[] buffer)
          Saves bytes to a specific File location specified by the user.
static void saveBytes(java.io.OutputStream output, byte[] buffer)
          Spews a buffer of bytes to an OutputStream.
 void saveBytes(java.lang.String filename, byte[] buffer)
          Saves bytes to a file to inside the sketch folder.
 java.io.File saveFile(java.lang.String where)
          Identical to savePath(), but returns a File object.
 void saveFrame()
          Grab an image of what's currently in the drawing area and save it as a .tif or .tga file.
 void saveFrame(java.lang.String what)
          Save the current frame as a .tif or .tga image.
 java.lang.String savePath(java.lang.String where)
          Returns a path inside the applet folder to save to.
static void saveStream(java.io.File targetFile, java.io.InputStream sourceStream)
           
 void saveStream(java.io.File targetFile, java.lang.String sourceLocation)
          Identical to the other saveStream(), but writes to a File object, for greater control over the file location.
 void saveStream(java.lang.String targetFilename, java.lang.String sourceLocation)
          Save the contents of a stream to a file in the sketch folder.
static void saveStrings(java.io.File file, java.lang.String[] strings)
           
static void saveStrings(java.io.OutputStream output, java.lang.String[] strings)
           
 void saveStrings(java.lang.String filename, java.lang.String[] strings)
           
 void scale(float s)
           
 void scale(float sx, float sy)
           
 void scale(float x, float y, float z)
           
 float screenX(float x, float y)
           
 float screenX(float x, float y, float z)
           
 float screenY(float x, float y)
           
 float screenY(float x, float y, float z)
           
 float screenZ(float x, float y, float z)
           
static int second()
          Seconds position of the current time.
 java.lang.String selectFolder()
          Open a platform-specific folder chooser dialog.
 java.lang.String selectFolder(java.lang.String prompt)
          Open a platform-specific folder chooser dialog.
 java.lang.String selectInput()
          Open a platform-specific file chooser dialog to select a file for input.
 java.lang.String selectInput(java.lang.String prompt)
          Open a platform-specific file chooser dialog to select a file for input.
 java.lang.String selectOutput()
          Open a platform-specific file save dialog to select a file for output.
 java.lang.String selectOutput(java.lang.String prompt)
          Open a platform-specific file save dialog to select a file for output.
 void set(int x, int y, int c)
           
 void set(int x, int y, PImage src)
           
 void setCache(java.lang.Object parent, java.lang.Object storage)
           
 void setMatrix(PMatrix source)
           
 void setMatrix(PMatrix2D source)
           
 void setMatrix(PMatrix3D source)
           
 void setup()
           
 void setupExternalMessages()
          Set this sketch to communicate its state back to the PDE.
 void setupFrameResizeListener()
          Set up a listener that will fire proper component resize events in cases where frame.setResizable(true) is called.
 void shape(PShape shape)
           
 void shape(PShape shape, float x, float y)
           
 void shape(PShape shape, float x, float y, float c, float d)
           
 void shapeMode(int mode)
           
 void shininess(float shine)
           
static boolean[] shorten(boolean[] list)
           
static byte[] shorten(byte[] list)
           
static char[] shorten(char[] list)
           
static float[] shorten(float[] list)
           
static int[] shorten(int[] list)
           
static java.lang.Object shorten(java.lang.Object list)
           
static java.lang.String[] shorten(java.lang.String[] list)
           
static float sin(float angle)
           
 void size(int iwidth, int iheight)
          Starts up and creates a two-dimensional drawing surface, or resizes the current drawing surface.
 void size(int iwidth, int iheight, java.lang.String irenderer)
           
 void size(int iwidth, int iheight, java.lang.String irenderer, java.lang.String ipath)
          Creates a new PGraphics object and sets it to the specified size.
 java.io.File sketchFile(java.lang.String where)
           
 java.lang.String sketchPath(java.lang.String where)
          Prepend the sketch folder path to the filename (or path) that is passed in.
 void smooth()
           
static byte[] sort(byte[] what)
           
static byte[] sort(byte[] what, int count)
           
static char[] sort(char[] what)
           
static char[] sort(char[] what, int count)
           
static float[] sort(float[] what)
           
static float[] sort(float[] what, int count)
           
static int[] sort(int[] what)
           
static int[] sort(int[] what, int count)
           
static java.lang.String[] sort(java.lang.String[] what)
           
static java.lang.String[] sort(java.lang.String[] what, int count)
           
 void specular(float gray)
           
 void specular(float x, float y, float z)
           
 void specular(int rgb)
           
 void sphere(float r)
           
 void sphereDetail(int res)
           
 void sphereDetail(int ures, int vres)
           
static boolean[] splice(boolean[] list, boolean[] v, int index)
           
static boolean[] splice(boolean[] list, boolean v, int index)
           
static byte[] splice(byte[] list, byte[] v, int index)
           
static byte[] splice(byte[] list, byte v, int index)
           
static char[] splice(char[] list, char[] v, int index)
           
static char[] splice(char[] list, char v, int index)
           
static float[] splice(float[] list, float[] v, int index)
           
static float[] splice(float[] list, float v, int index)
           
static int[] splice(int[] list, int[] v, int index)
           
static int[] splice(int[] list, int v, int index)
           
static java.lang.Object splice(java.lang.Object list, java.lang.Object v, int index)
           
static java.lang.String[] splice(java.lang.String[] list, java.lang.String[] v, int index)
           
static java.lang.String[] splice(java.lang.String[] list, java.lang.String v, int index)
           
static java.lang.String[] split(java.lang.String what, char delim)
          Split a string into pieces along a specific character.
static java.lang.String[] split(java.lang.String what, java.lang.String delim)
          Split a String on a specific delimiter.
static java.lang.String[] splitTokens(java.lang.String what)
          Split the provided String at wherever whitespace occurs.
static java.lang.String[] splitTokens(java.lang.String what, java.lang.String delim)
          Splits a string into pieces, using any of the chars in the String 'delim' as separator characters.
 void spotLight(float red, float green, float blue, float x, float y, float z, float nx, float ny, float nz, float angle, float concentration)
           
static float sq(float a)
           
static float sqrt(float a)
           
 void start()
          Called by the browser or applet viewer to inform this applet that it should start its execution.
 void status(java.lang.String what)
          Show status in the status bar of a web browser, or in the System.out console.
 void stop()
          Called by the browser or applet viewer to inform this applet that it should stop its execution.
static java.lang.String str(boolean x)
           
static java.lang.String[] str(boolean[] x)
           
static java.lang.String str(byte x)
           
static java.lang.String[] str(byte[] x)
           
static java.lang.String str(char x)
           
static java.lang.String[] str(char[] x)
           
static java.lang.String str(float x)
           
static java.lang.String[] str(float[] x)
           
static java.lang.String str(int x)
           
static java.lang.String[] str(int[] x)
           
 void stroke(float gray)
           
 void stroke(float gray, float alpha)
           
 void stroke(float x, float y, float z)
           
 void stroke(float x, float y, float z, float a)
           
 void stroke(int rgb)
           
 void stroke(int rgb, float alpha)
           
 void strokeCap(int cap)
           
 void strokeJoin(int join)
           
 void strokeWeight(float weight)
           
 void style(PStyle s)
           
static boolean[] subset(boolean[] list, int start)
           
static boolean[] subset(boolean[] list, int start, int count)
           
static byte[] subset(byte[] list, int start)
           
static byte[] subset(byte[] list, int start, int count)
           
static char[] subset(char[] list, int start)
           
static char[] subset(char[] list, int start, int count)
           
static float[] subset(float[] list, int start)
           
static float[] subset(float[] list, int start, int count)
           
static int[] subset(int[] list, int start)
           
static int[] subset(int[] list, int start, int count)
           
static java.lang.Object subset(java.lang.Object list, int start)
           
static java.lang.Object subset(java.lang.Object list, int start, int count)
           
static java.lang.String[] subset(java.lang.String[] list, int start)
           
static java.lang.String[] subset(java.lang.String[] list, int start, int count)
           
static float tan(float angle)
           
 void text(char c)
           
 void text(char[] chars, int start, int stop, float x, float y)
           
 void text(char[] chars, int start, int stop, float x, float y, float z)
           
 void text(char c, float x, float y)
           
 void text(char c, float x, float y, float z)
           
 void text(float num, float x, float y)
           
 void text(float num, float x, float y, float z)
           
 void text(int num, float x, float y)
           
 void text(int num, float x, float y, float z)
           
 void text(java.lang.String str)
           
 void text(java.lang.String str, float x, float y)
           
 void text(java.lang.String str, float x, float y, float z)
           
 void text(java.lang.String str, float x1, float y1, float x2, float y2)
           
 void text(java.lang.String s, float x1, float y1, float x2, float y2, float z)
           
 void textAlign(int align)
           
 void textAlign(int alignX, int alignY)
           
 float textAscent()
           
 float textDescent()
           
 void textFont(PFont which)
           
 void textFont(PFont which, float size)
           
 void textLeading(float leading)
           
 void textMode(int mode)
           
 void textSize(float size)
           
 void texture(PImage image)
           
 void textureMode(int mode)
           
 float textWidth(char c)
           
 float textWidth(java.lang.String str)
           
 void tint(float gray)
           
 void tint(float gray, float alpha)
           
 void tint(float x, float y, float z)
           
 void tint(float x, float y, float z, float a)
           
 void tint(int rgb)
           
 void tint(int rgb, float alpha)
           
 void translate(float tx, float ty)
           
 void translate(float tx, float ty, float tz)
           
 void triangle(float x1, float y1, float x2, float y2, float x3, float y3)
           
static java.lang.String trim(java.lang.String str)
          Remove whitespace characters from the beginning and ending of a String.
static java.lang.String[] trim(java.lang.String[] array)
          Trim the whitespace from a String array.
static int unbinary(java.lang.String what)
          Unpack a binary String into an int.
static int unhex(java.lang.String what)
           
 void unregisterDispose(java.lang.Object o)
           
 void unregisterDraw(java.lang.Object o)
           
 void unregisterKeyEvent(java.lang.Object o)
           
 void unregisterMouseEvent(java.lang.Object o)
           
 void unregisterPost(java.lang.Object o)
           
 void unregisterPre(java.lang.Object o)
           
 void unregisterSize(java.lang.Object o)
           
 void update(java.awt.Graphics screen)
           
 void updatePixels()
           
 void updatePixels(int x1, int y1, int x2, int y2)
           
 void vertex(float[] v)
           
 void vertex(float x, float y)
           
 void vertex(float x, float y, float z)
           
 void vertex(float x, float y, float u, float v)
           
 void vertex(float x, float y, float z, float u, float v)
           
static int year()
          Get the current year.
 
Methods inherited from class java.applet.Applet
getAccessibleContext, getAppletContext, getAppletInfo, getAudioClip, getAudioClip, getCodeBase, getDocumentBase, getImage, getImage, getLocale, getParameter, getParameterInfo, isActive, newAudioClip, play, play, resize, resize, setStub, showStatus
 
Methods inherited from class java.awt.Panel
addNotify
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getLayout, getListeners, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusBackward, transferFocusDownCycle, validate
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, dispatchEvent, enable, enable, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocusInWindow, reshape, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

javaVersionName

public static final java.lang.String javaVersionName
Full name of the Java version (i.e. 1.5.0_11). Prior to 0125, this was only the first three digits.


javaVersion

public static final float javaVersion
Version of Java that's in use, whether 1.1 or 1.3 or whatever, stored as a float.

Note that because this is stored as a float, the values may not be exactly 1.3 or 1.4. Instead, make sure you're comparing against 1.3f or 1.4f, which will have the same amount of error (i.e. 1.40000001). This could just be a double, but since Processing only uses floats, it's safer for this to be a float because there's no good way to specify a double with the preproc.


platform

public static int platform
Current platform in use, one of the PConstants WINDOWS, MACOSX, MACOS9, LINUX or OTHER.


MENU_SHORTCUT

public static final int MENU_SHORTCUT
Modifier flags for the shortcut key used to trigger menus. (Cmd on Mac OS X, Ctrl on Linux and Windows)


g

public PGraphics g
The PGraphics renderer associated with this PApplet


frame

public java.awt.Frame frame
The frame containing this applet (if any)


screen

public java.awt.Dimension screen
The screen size when the applet was started.

Access this via screen.width and screen.height. To make an applet run at full screen, use size(screen.width, screen.height).

If you have multiple displays, this will be the size of the main display. Running full screen across multiple displays isn't particularly supported, and requires more monkeying with the values. This probably can't/won't be fixed until/unless I get a dual head system.

Note that this won't update if you change the resolution of your screen once the the applet is running.

This variable is not static, because future releases need to be better at handling multiple displays.


recorder

public PGraphics recorder
A leech graphics object that is echoing all events.


args

public java.lang.String[] args
Command line options passed in from main().

This does not include the arguments passed in to PApplet itself.


sketchPath

public java.lang.String sketchPath
Path to sketch folder


DEFAULT_WIDTH

public static final int DEFAULT_WIDTH
Default width and height for applet when not specified

See Also:
Constant Field Values

DEFAULT_HEIGHT

public static final int DEFAULT_HEIGHT
See Also:
Constant Field Values

MIN_WINDOW_WIDTH

public static final int MIN_WINDOW_WIDTH
Minimum dimensions for the window holding an applet. This varies between platforms, Mac OS X 10.3 can do any height but requires at least 128 pixels width. Windows XP has another set of limitations. And for all I know, Linux probably lets you make windows with negative sizes.

See Also:
Constant Field Values

MIN_WINDOW_HEIGHT

public static final int MIN_WINDOW_HEIGHT
See Also:
Constant Field Values

defaultSize

public boolean defaultSize
true if no size() command has been executed. This is used to wait until a size has been set before placing in the window and showing it.


pixels

public int[] pixels
Pixel buffer from this applet's PGraphics.

When used with OpenGL or Java2D, this value will be null until loadPixels() has been called.


width

public int width
width of this applet's associated PGraphics


height

public int height
height of this applet's associated PGraphics


mouseX

public int mouseX
current x position of the mouse


mouseY

public int mouseY
current y position of the mouse


pmouseX

public int pmouseX
Previous x/y position of the mouse. This will be a different value when inside a mouse handler (like the mouseMoved() method) versus when inside draw(). Inside draw(), pmouseX is updated once each frame, but inside mousePressed() and friends, it's updated each time an event comes through. Be sure to use only one or the other type of means for tracking pmouseX and pmouseY within your sketch, otherwise you're gonna run into trouble.


pmouseY

public int pmouseY
Previous x/y position of the mouse. This will be a different value when inside a mouse handler (like the mouseMoved() method) versus when inside draw(). Inside draw(), pmouseX is updated once each frame, but inside mousePressed() and friends, it's updated each time an event comes through. Be sure to use only one or the other type of means for tracking pmouseX and pmouseY within your sketch, otherwise you're gonna run into trouble.


firstMouse

public boolean firstMouse
Used to set pmouseX/Y to mouseX/Y the first time mouseX/Y are used, otherwise pmouseX/Y are always zero, causing a nasty jump.

Just using (frameCount == 0) won't work since mouseXxxxx() may not be called until a couple frames into things.


mouseButton

public int mouseButton
Last mouse button pressed, one of LEFT, CENTER, or RIGHT.

If running on Mac OS, a ctrl-click will be interpreted as the righthand mouse button (unlike Java, which reports it as the left mouse).


mousePressed

public boolean mousePressed

mouseEvent

public java.awt.event.MouseEvent mouseEvent

key

public char key
Last key pressed.

If it's a coded key, i.e. UP/DOWN/CTRL/SHIFT/ALT, this will be set to CODED (0xffff or 65535).


keyCode

public int keyCode
When "key" is set to CODED, this will contain a Java key code.

For the arrow keys, keyCode will be one of UP, DOWN, LEFT and RIGHT. Also available are ALT, CONTROL and SHIFT. A full set of constants can be obtained from java.awt.event.KeyEvent, from the VK_XXXX variables.


keyPressed

public boolean keyPressed
true if the mouse is currently pressed.


keyEvent

public java.awt.event.KeyEvent keyEvent
the last KeyEvent object passed into a mouse function.


focused

public boolean focused
Gets set to true/false as the applet gains/loses focus.


online

public boolean online
true if the applet is online.

This can be used to test how the applet should behave since online situations are different (no file writing, etc).


frameRate

public float frameRate
The current value of frames per second.

The initial value will be 10 fps, and will be updated with each frame thereafter. The value is not instantaneous (since that wouldn't be very useful since it would jump around so much), but is instead averaged (integrated) over several frames. As such, this value won't be valid until after 5-10 frames.


frameCount

public int frameCount
How many frames have been displayed since the applet started.

This value is read-only do not attempt to set it, otherwise bad things will happen.

Inside setup(), frameCount is 0. For the first iteration of draw(), frameCount will equal 1.


finished

public boolean finished
true if this applet has had it.


ARGS_EDITOR_LOCATION

public static final java.lang.String ARGS_EDITOR_LOCATION
Position of the upper-lefthand corner of the editor window that launched this applet.

See Also:
Constant Field Values

ARGS_EXTERNAL

public static final java.lang.String ARGS_EXTERNAL
Location for where to position the applet window on screen.

This is used by the editor to when saving the previous applet location, or could be used by other classes to launch at a specific position on-screen.

See Also:
Constant Field Values

ARGS_LOCATION

public static final java.lang.String ARGS_LOCATION
See Also:
Constant Field Values

ARGS_DISPLAY

public static final java.lang.String ARGS_DISPLAY
See Also:
Constant Field Values

ARGS_BGCOLOR

public static final java.lang.String ARGS_BGCOLOR
See Also:
Constant Field Values

ARGS_PRESENT

public static final java.lang.String ARGS_PRESENT
See Also:
Constant Field Values

ARGS_EXCLUSIVE

public static final java.lang.String ARGS_EXCLUSIVE
See Also:
Constant Field Values

ARGS_STOP_COLOR

public static final java.lang.String ARGS_STOP_COLOR
See Also:
Constant Field Values

ARGS_HIDE_STOP

public static final java.lang.String ARGS_HIDE_STOP
See Also:
Constant Field Values

ARGS_SKETCH_FOLDER

public static final java.lang.String ARGS_SKETCH_FOLDER
Allows the user or PdeEditor to set a specific sketch folder path.

Used by PdeEditor to pass in the location where saveFrame() and all that stuff should write things.

See Also:
Constant Field Values

EXTERNAL_STOP

public static final java.lang.String EXTERNAL_STOP
When run externally to a PdeEditor, this is sent by the applet when it quits.

See Also:
Constant Field Values

EXTERNAL_MOVE

public static final java.lang.String EXTERNAL_MOVE
When run externally to a PDE Editor, this is sent by the applet whenever the window is moved.

This is used so that the editor can re-open the sketch window in the same position as the user last left it.

See Also:
Constant Field Values

requestImageMax

public int requestImageMax
By trial and error, four image loading threads seem to work best when loading images from online. This is consistent with the number of open connections that web browsers will maintain. The variable is made public (however no accessor has been added since it's esoteric) if you really want to have control over the value used. For instance, when loading local files, it might be better to only have a single thread (or two) loading images so that you're disk isn't simply jumping around.


selectedFile

public java.io.File selectedFile

ICON_IMAGE

public static final byte[] ICON_IMAGE
GIF image of the Processing logo.

Constructor Detail

PApplet

public PApplet()
Method Detail

init

public void init()
Overrides:
init in class java.applet.Applet

getSketchWidth

public int getSketchWidth()

getSketchHeight

public int getSketchHeight()

getSketchRenderer

public java.lang.String getSketchRenderer()

start

public void start()
Called by the browser or applet viewer to inform this applet that it should start its execution. It is called after the init method and each time the applet is revisited in a Web page.

Called explicitly via the first call to PApplet.paint(), because PAppletGL needs to have a usable screen before getting things rolling.

Overrides:
start in class java.applet.Applet

stop

public void stop()
Called by the browser or applet viewer to inform this applet that it should stop its execution.

Unfortunately, there are no guarantees from the Java spec when or if stop() will be called (i.e. on browser quit, or when moving between web pages), and it's not always called.

Overrides:
stop in class java.applet.Applet

destroy

public void destroy()
Called by the browser or applet viewer to inform this applet that it is being reclaimed and that it should destroy any resources that it has allocated.

This also attempts to call PApplet.stop(), in case there was an inadvertent override of the stop() function by a user.

destroy() supposedly gets called as the applet viewer is shutting down the applet. stop() is called first, and then destroy() to really get rid of things. no guarantees on when they're run (on browser quit, or when moving between pages), though.

Overrides:
destroy in class java.applet.Applet

registerSize

public void registerSize(java.lang.Object o)

registerPre

public void registerPre(java.lang.Object o)

registerDraw

public void registerDraw(java.lang.Object o)

registerPost

public void registerPost(java.lang.Object o)

registerMouseEvent

public void registerMouseEvent(java.lang.Object o)

registerKeyEvent

public void registerKeyEvent(java.lang.Object o)

registerDispose

public void registerDispose(java.lang.Object o)

unregisterSize

public void unregisterSize(java.lang.Object o)

unregisterPre

public void unregisterPre(java.lang.Object o)

unregisterDraw

public void unregisterDraw(java.lang.Object o)

unregisterPost

public void unregisterPost(java.lang.Object o)

unregisterMouseEvent

public void unregisterMouseEvent(java.lang.Object o)

unregisterKeyEvent

public void unregisterKeyEvent(java.lang.Object o)

unregisterDispose

public void unregisterDispose(java.lang.Object o)

setup

public void setup()

draw

public void draw()

size

public void size(int iwidth,
                 int iheight)
Starts up and creates a two-dimensional drawing surface, or resizes the current drawing surface.

This should be the first thing called inside of setup().

If using Java 1.3 or later, this will default to using PGraphics2, the Java2D-based renderer. If using Java 1.1, or if PGraphics2 is not available, then PGraphics will be used. To set your own renderer, use the other version of the size() method that takes a renderer as its last parameter.

If called once a renderer has already been set, this will use the previous renderer and simply resize it.


size

public void size(int iwidth,
                 int iheight,
                 java.lang.String irenderer)

size

public void size(int iwidth,
                 int iheight,
                 java.lang.String irenderer,
                 java.lang.String ipath)
Creates a new PGraphics object and sets it to the specified size. Note that you cannot change the renderer once outside of setup(). In most cases, you can call size() to give it a new size, but you need to always ask for the same renderer, otherwise you're gonna run into trouble. The size() method should *only* be called from inside the setup() or draw() methods, so that it is properly run on the main animation thread. To change the size of a PApplet externally, use setSize(), which will update the component size, and queue a resize of the renderer as well.


createGraphics

public PGraphics createGraphics(int iwidth,
                                int iheight,
                                java.lang.String irenderer)
Create an offscreen PGraphics object for drawing. This can be used for bitmap or vector images drawing or rendering.


createGraphics

public PGraphics createGraphics(int iwidth,
                                int iheight,
                                java.lang.String irenderer,
                                java.lang.String ipath)
Create an offscreen graphics surface for drawing, in this case for a renderer that writes to a file (such as PDF or DXF).

Parameters:
ipath - can be an absolute or relative path

createImage

public PImage createImage(int wide,
                          int high,
                          int format)
Preferred method of creating new PImage objects, ensures that a reference to the parent PApplet is included, which makes save() work without needing an absolute path.


update

public void update(java.awt.Graphics screen)
Overrides:
update in class java.awt.Container

paint

public void paint(java.awt.Graphics screen)
Overrides:
paint in class java.awt.Container

run

public void run()
Main method for the primary animation thread. Painting in AWT and Swing

Specified by:
run in interface java.lang.Runnable

handleDraw

public void handleDraw()

redraw

public void redraw()

loop

public void loop()

noLoop

public void noLoop()

addListeners

public void addListeners()

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
If you override this or any function that takes a "MouseEvent e" without calling its super.mouseXxxx() then mouseX, mouseY, mousePressed, and mouseEvent will no longer be set.

Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Specified by:
mouseExited in interface java.awt.event.MouseListener

mouseDragged

public void mouseDragged(java.awt.event.MouseEvent e)
Specified by:
mouseDragged in interface java.awt.event.MouseMotionListener

mouseMoved

public void mouseMoved(java.awt.event.MouseEvent e)
Specified by:
mouseMoved in interface java.awt.event.MouseMotionListener

mousePressed

public void mousePressed()
Mouse has been pressed, and should be considered "down" until mouseReleased() is called. If you must, use int button = mouseEvent.getButton(); to figure out which button was clicked. It will be one of: MouseEvent.BUTTON1, MouseEvent.BUTTON2, MouseEvent.BUTTON3 Note, however, that this is completely inconsistent across platforms.


mouseReleased

public void mouseReleased()
Mouse button has been released.


mouseClicked

public void mouseClicked()
When the mouse is clicked, mousePressed() will be called, then mouseReleased(), then mouseClicked(). Note that mousePressed is already false inside of mouseClicked().


mouseDragged

public void mouseDragged()
Mouse button is pressed and the mouse has been dragged.


mouseMoved

public void mouseMoved()
Mouse button is not pressed but the mouse has changed locations.


keyPressed

public void keyPressed(java.awt.event.KeyEvent e)
Overriding keyXxxxx(KeyEvent e) functions will cause the 'key', 'keyCode', and 'keyEvent' variables to no longer work; key events will no longer be queued until the end of draw(); and the keyPressed(), keyReleased() and keyTyped() methods will no longer be called.

Specified by:
keyPressed in interface java.awt.event.KeyListener

keyReleased

public void keyReleased(java.awt.event.KeyEvent e)
Specified by:
keyReleased in interface java.awt.event.KeyListener

keyTyped

public void keyTyped(java.awt.event.KeyEvent e)
Specified by:
keyTyped in interface java.awt.event.KeyListener

keyPressed

public void keyPressed()
Called each time a single key on the keyboard is pressed. Because of how operating systems handle key repeats, holding down a key will cause multiple calls to keyPressed(), because the OS repeat takes over.

Examples for key handling: (Tested on Windows XP, please notify if different on other platforms, I have a feeling Mac OS and Linux may do otherwise)

 1. Pressing 'a' on the keyboard:
    keyPressed  with key == 'a' and keyCode == 'A'
    keyTyped    with key == 'a' and keyCode ==  0
    keyReleased with key == 'a' and keyCode == 'A'

 2. Pressing 'A' on the keyboard:
    keyPressed  with key == 'A' and keyCode == 'A'
    keyTyped    with key == 'A' and keyCode ==  0
    keyReleased with key == 'A' and keyCode == 'A'

 3. Pressing 'shift', then 'a' on the keyboard (caps lock is off):
    keyPressed  with key == CODED and keyCode == SHIFT
    keyPressed  with key == 'A'   and keyCode == 'A'
    keyTyped    with key == 'A'   and keyCode == 0
    keyReleased with key == 'A'   and keyCode == 'A'
    keyReleased with key == CODED and keyCode == SHIFT

 4. Holding down the 'a' key.
    The following will happen several times,
    depending on your machine's "key repeat rate" settings:
    keyPressed  with key == 'a' and keyCode == 'A'
    keyTyped    with key == 'a' and keyCode ==  0
    When you finally let go, you'll get:
    keyReleased with key == 'a' and keyCode == 'A'

 5. Pressing and releasing the 'shift' key
    keyPressed  with key == CODED and keyCode == SHIFT
    keyReleased with key == CODED and keyCode == SHIFT
    (note there is no keyTyped)

 6. Pressing the tab key in an applet with Java 1.4 will
    normally do nothing, but PApplet dynamically shuts
    this behavior off if Java 1.4 is in use (tested 1.4.2_05 Windows).
    Java 1.1 (Microsoft VM) passes the TAB key through normally.
    Not tested on other platforms or for 1.3.
 


keyReleased

public void keyReleased()
See keyPressed().


keyTyped

public void keyTyped()
Only called for "regular" keys like letters, see keyPressed() for full documentation.


focusGained

public void focusGained()

focusGained

public void focusGained(java.awt.event.FocusEvent e)
Specified by:
focusGained in interface java.awt.event.FocusListener

focusLost

public void focusLost()

focusLost

public void focusLost(java.awt.event.FocusEvent e)
Specified by:
focusLost in interface java.awt.event.FocusListener

millis

public int millis()
Get the number of milliseconds since the applet started.

This is a function, rather than a variable, because it may change multiple times per frame.


second

public static int second()
Seconds position of the current time.


minute

public static int minute()
Minutes position of the current time.


hour

public static int hour()
Hour position of the current time in international format (0-23).

To convert this value to American time:

int yankeeHour = (hour() % 12);
 if (yankeeHour == 0) yankeeHour = 12;


day

public static int day()
Get the current day of the month (1 through 31).

If you're looking for the day of the week (M-F or whatever) or day of the year (1..365) then use java's Calendar.get()


month

public static int month()
Get the current month in range 1 through 12.


year

public static int year()
Get the current year.


delay

public void delay(int napTime)
The delay() function causes the program to halt for a specified time. Delay times are specified in thousandths of a second. For example, running delay(3000) will stop the program for three seconds and delay(500) will stop the program for a half-second. Remember: the display window is updated only at the end of draw(), so putting more than one delay() inside draw() will simply add them together and the new frame will be drawn when the total delay is over.

I'm not sure if this is even helpful anymore, as the screen isn't updated before or after the delay, meaning which means it just makes the app lock up temporarily.


frameRate

public void frameRate(float newRateTarget)
Set a target frameRate. This will cause delay() to be called after each frame so that the sketch synchronizes to a particular speed. Note that this only sets the maximum frame rate, it cannot be used to make a slow sketch go faster. Sketches have no default frame rate setting, and will attempt to use maximum processor power to achieve maximum speed.


param

public java.lang.String param(java.lang.String what)
Get a param from the web page, or (eventually) from a properties file.


status

public void status(java.lang.String what)
Show status in the status bar of a web browser, or in the System.out console. Eventually this might show status in the p5 environment itself, rather than relying on the console.


link

public void link(java.lang.String here)

link

public void link(java.lang.String url,
                 java.lang.String frameTitle)
Link to an external page without all the muss.

When run with an applet, uses the browser to open the url, for applications, attempts to launch a browser with the url.

Works on Mac OS X and Windows. For Linux, use:

open(new String[] { "firefox", url });
or whatever you want as your browser, since Linux doesn't yet have a standard method for launching URLs.


open

public static void open(java.lang.String filename)
Attempt to open a file using the platform's shell.


open

public static java.lang.Process open(java.lang.String[] argv)
Launch a process using a platforms shell. This version uses an array to make it easier to deal with spaces in the individual elements. (This avoids the situation of trying to put single or double quotes around different bits).


exec

public static java.lang.Process exec(java.lang.String[] argv)

die

public void die(java.lang.String what)
Function for an applet/application to kill itself and display an error. Mostly this is here to be improved later.


die

public void die(java.lang.String what,
                java.lang.Exception e)
Same as above but with an exception. Also needs work.


exit

public void exit()
Call to safely exit the sketch when finished. For instance, to render a single frame, save it, and quit.


save

public void save(java.lang.String filename)
Intercepts any relative paths to make them absolute (relative to the sketch folder) before passing to save() in PImage. (Changed in 0100)


saveFrame

public void saveFrame()
Grab an image of what's currently in the drawing area and save it as a .tif or .tga file.

Best used just before endDraw() at the end of your draw(). This can only create .tif or .tga images, so if neither extension is specified it defaults to writing a tiff and adds a .tif suffix.


saveFrame

public void saveFrame(java.lang.String what)
Save the current frame as a .tif or .tga image.

The String passed in can contain a series of # signs that will be replaced with the screengrab number.

 i.e. saveFrame("blah-####.tif");
      // saves a numbered tiff image, replacing the
      // #### signs with zeros and the frame number 


cursor

public void cursor(int cursorType)
Set the cursor type


cursor

public void cursor(PImage image)
Replace the cursor with the specified PImage. The x- and y- coordinate of the center will be the center of the image.


cursor

public void cursor(PImage image,
                   int hotspotX,
                   int hotspotY)
Set a custom cursor to an image with a specific hotspot. Only works with JDK 1.2 and later. Currently seems to be broken on Java 1.4 for Mac OS X

Based on code contributed by Amit Pitaru, plus additional code to handle Java versions via reflection by Jonathan Feinberg. Reflection removed for release 0128 and later.


cursor

public void cursor()
Show the cursor after noCursor() was called. Notice that the program remembers the last set cursor type


noCursor

public void noCursor()
Hide the cursor by creating a transparent image and using it as a custom cursor.


print

public static void print(byte what)

print

public static void print(boolean what)

print

public static void print(char what)

print

public static void print(int what)

print

public static void print(float what)

print

public static void print(java.lang.String what)

print

public static void print(java.lang.Object what)

println

public static void println()

println

public static void println(byte what)

println

public static void println(boolean what)

println

public static void println(char what)

println

public static void println(int what)

println

public static void println(float what)

println

public static void println(java.lang.String what)

println

public static void println(java.lang.Object what)

abs

public static final float abs(float n)

abs

public static final int abs(int n)

sq

public static final float sq(float a)

sqrt

public static final float sqrt(float a)

log

public static final float log(float a)

exp

public static final float exp(float a)

pow

public static final float pow(float a,
                              float b)

max

public static final int max(int a,
                            int b)

max

public static final float max(float a,
                              float b)

max

public static final int max(int a,
                            int b,
                            int c)

max

public static final float max(float a,
                              float b,
                              float c)

max

public static final int max(int[] list)
Find the maximum value in an array. Throws an ArrayIndexOutOfBoundsException if the array is length 0.

Parameters:
list - the source array
Returns:
The maximum value

max

public static final float max(float[] list)
Find the maximum value in an array. Throws an ArrayIndexOutOfBoundsException if the array is length 0.

Parameters:
list - the source array
Returns:
The maximum value

min

public static final int min(int a,
                            int b)

min

public static final float min(float a,
                              float b)

min

public static final int min(int a,
                            int b,
                            int c)

min

public static final float min(float a,
                              float b,
                              float c)

min

public static final int min(int[] list)
Find the minimum value in an array. Throws an ArrayIndexOutOfBoundsException if the array is length 0.

Parameters:
list - the source array
Returns:
The minimum value

min

public static final float min(float[] list)
Find the minimum value in an array. Throws an ArrayIndexOutOfBoundsException if the array is length 0.

Parameters:
list - the source array
Returns:
The minimum value

constrain

public static final int constrain(int amt,
                                  int low,
                                  int high)

constrain

public static final float constrain(float amt,
                                    float low,
                                    float high)

sin

public static final float sin(float angle)

cos

public static final float cos(float angle)

tan

public static final float tan(float angle)

asin

public static final float asin(float value)

acos

public static final float acos(float value)

atan

public static final float atan(float value)

atan2

public static final float atan2(float a,
                                float b)

degrees

public static final float degrees(float radians)

radians

public static final float radians(float degrees)

ceil

public static final int ceil(float what)

floor

public static final int floor(float what)

round

public static final int round(float what)

mag

public static final float mag(float a,
                              float b)

mag

public static final float mag(float a,
                              float b,
                              float c)

dist

public static final float dist(float x1,
                               float y1,
                               float x2,
                               float y2)

dist

public static final float dist(float x1,
                               float y1,
                               float z1,
                               float x2,
                               float y2,
                               float z2)

lerp

public static final float lerp(float start,
                               float stop,
                               float amt)

norm

public static final float norm(float value,
                               float start,
                               float stop)
Normalize a value to exist between 0 and 1 (inclusive). Mathematically the opposite of lerp(), figures out what proportion a particular value is relative to start and stop coordinates.


map

public static final float map(float value,
                              float istart,
                              float istop,
                              float ostart,
                              float ostop)
Convenience function to map a variable from one coordinate space to another. Equivalent to unlerp() followed by lerp().


random

public final float random(float howbig)
Return a random number in the range [0, howbig).

The number returned will range from zero up to (but not including) 'howbig'.


random

public final float random(float howsmall,
                          float howbig)
Return a random number in the range [howsmall, howbig).

The number returned will range from 'howsmall' up to (but not including 'howbig'.

If howsmall is >= howbig, howsmall will be returned, meaning that random(5, 5) will return 5 (useful) and random(7, 4) will return 7 (not useful.. better idea?)


randomSeed

public final void randomSeed(long what)

noise

public float noise(float x)
Computes the Perlin noise function value at point x.


noise

public float noise(float x,
                   float y)
Computes the Perlin noise function value at the point x, y.


noise

public float noise(float x,
                   float y,
                   float z)
Computes the Perlin noise function value at x, y, z.


noiseDetail

public void noiseDetail(int lod)

noiseDetail

public void noiseDetail(int lod,
                        float falloff)

noiseSeed

public void noiseSeed(long what)

loadImage

public PImage loadImage(java.lang.String filename)
Load an image from the data folder or a local directory. Supports .gif (including transparency), .tga, and .jpg images. In Java 1.3 or later, .png images are also supported.

Generally, loadImage() should only be used during setup, because re-loading images inside draw() is likely to cause a significant delay while memory is allocated and the thread blocks while waiting for the image to load because loading is not asynchronous.

To load several images asynchronously, see more information in the FAQ about writing your own threaded image loading method.

As of 0096, returns null if no image of that name is found, rather than an error.

Release 0115 also provides support for reading TIFF and RLE-encoded Targa (.tga) files written by Processing via save() and saveFrame(). Other TIFF and Targa files will probably not load, use a different format (gif, jpg and png are safest bets) when creating images with another application to use with Processing.

Also in release 0115, more image formats (BMP and others) can be read when using Java 1.4 and later. Because many people still use Java 1.1 and 1.3, these formats are not recommended for work that will be posted on the web. To get a list of possible image formats for use with Java 1.4 and later, use the following: println(javax.imageio.ImageIO.getReaderFormatNames())

Images are loaded via a byte array that is passed to Toolkit.createImage(). Unfortunately, we cannot use Applet.getImage() because it takes a URL argument, which would be a pain in the a-- to make work consistently for online and local sketches. Sometimes this causes problems, resulting in issues like Bug 279 and Bug 305. In release 0115, everything was instead run through javax.imageio, but that turned out to be very slow, see Bug 392. As a result, starting with 0116, the following happens:

For releases 0116 and later, if you have problems such as those seen in Bugs 279 and 305, use Applet.getImage() instead. You'll be stuck with the limitations of getImage() (the headache of dealing with online/offline use). Set up your own MediaTracker, and pass the resulting java.awt.Image to the PImage constructor that takes an AWT image.


loadImage

public PImage loadImage(java.lang.String filename,
                        java.lang.String extension)
Identical to loadImage, but allows you to specify the type of image by its extension. Especially useful when downloading from CGI scripts.

Use 'unknown' as the extension to pass off to the default image loader that handles gif, jpg, and png.


requestImage

public PImage requestImage(java.lang.String filename)

requestImage

public PImage requestImage(java.lang.String filename,
                           java.lang.String extension)

loadShape

public PShape loadShape(java.lang.String filename)
Load a geometry from a file as a PShape. Currently only supports SVG data.


loadFont

public PFont loadFont(java.lang.String filename)

createFont

public PFont createFont(java.lang.String name,
                        float size)

createFont

public PFont createFont(java.lang.String name,
                        float size,
                        boolean smooth)

createFont

public PFont createFont(java.lang.String name,
                        float size,
                        boolean smooth,
                        char[] charset)
Create a .vlw font on the fly from either a font name that's installed on the system, or from a .ttf or .otf that's inside the data folder of this sketch.

Only works with Java 1.3 or later. Many .otf fonts don't seem to be supported by Java, perhaps because they're CFF based?

Font names are inconsistent across platforms and Java versions. On Mac OS X, Java 1.3 uses the font menu name of the font, whereas Java 1.4 uses the PostScript name of the font. Java 1.4 on OS X will also accept the font menu name as well. On Windows, it appears that only the menu names are used, no matter what Java version is in use. Naming system unknown/untested for 1.5.

Use 'null' for the charset if you want to use any of the 65,536 unicode characters that exist in the font. Note that this can produce an enormous file or may cause an OutOfMemoryError.


selectInput

public java.lang.String selectInput()
Open a platform-specific file chooser dialog to select a file for input.

Returns:
full path to the selected file, or null if no selection.

selectInput

public java.lang.String selectInput(java.lang.String prompt)
Open a platform-specific file chooser dialog to select a file for input.

Parameters:
prompt - Mesage to show the user when prompting for a file.
Returns:
full path to the selected file, or null if canceled.

selectOutput

public java.lang.String selectOutput()
Open a platform-specific file save dialog to select a file for output.

Returns:
full path to the file entered, or null if canceled.

selectOutput

public java.lang.String selectOutput(java.lang.String prompt)
Open a platform-specific file save dialog to select a file for output.

Parameters:
prompt - Mesage to show the user when prompting for a file.
Returns:
full path to the file entered, or null if canceled.

selectFolder

public java.lang.String selectFolder()
Open a platform-specific folder chooser dialog.

Returns:
full path to the selected folder, or null if no selection.

selectFolder

public java.lang.String selectFolder(java.lang.String prompt)
Open a platform-specific folder chooser dialog.

Parameters:
prompt - Mesage to show the user when prompting for a file.
Returns:
full path to the selected folder, or null if no selection.

createReader

public java.io.BufferedReader createReader(java.lang.String filename)
I want to read lines from a file. I have RSI from typing these eight lines of code so many times.


createReader

public static java.io.BufferedReader createReader(java.io.File file)
I want to read lines from a file. And I'm still annoyed.


createReader

public static java.io.BufferedReader createReader(java.io.InputStream input)
I want to read lines from a stream. If I have to type the following lines any more I'm gonna send Sun my medical bills.


createWriter

public java.io.PrintWriter createWriter(java.lang.String filename)
I want to print lines to a file. Why can't I?


createWriter

public static java.io.PrintWriter createWriter(java.io.File file)
I want to print lines to a file. I have RSI from typing these eight lines of code so many times.


createWriter

public static java.io.PrintWriter createWriter(java.io.OutputStream output)
I want to print lines to a file. Why am I always explaining myself? It's the JavaSoft API engineers who need to explain themselves.


openStream

public java.io.InputStream openStream(java.lang.String filename)
Deprecated. As of release 0136, use createInput() instead.


createInput

public java.io.InputStream createInput(java.lang.String filename)
Simplified method to open a Java InputStream.

This method is useful if you want to use the facilities provided by PApplet to easily open things from the data folder or from a URL, but want an InputStream object so that you can use other Java methods to take more control of how the stream is read.

If the requested item doesn't exist, null is returned. (Prior to 0096, die() would be called, killing the applet)

For 0096+, the "data" folder is exported intact with subfolders, and openStream() properly handles subdirectories from the data folder

If not online, this will also check to see if the user is asking for a file whose name isn't properly capitalized. This helps prevent issues when a sketch is exported to the web, where case sensitivity matters, as opposed to Windows and the Mac OS default where case sensitivity is preserved but ignored.

It is strongly recommended that libraries use this method to open data files, so that the loading sequence is handled in the same way as functions like loadBytes(), loadImage(), etc.

The filename passed in can be:


createInputRaw

public java.io.InputStream createInputRaw(java.lang.String filename)
Call openStream() without automatic gzip decompression.


createInput

public static java.io.InputStream createInput(java.io.File file)

loadBytes

public byte[] loadBytes(java.lang.String filename)

loadBytes

public static byte[] loadBytes(java.io.InputStream input)

loadBytes

public static byte[] loadBytes(java.io.File file)

loadStrings

public static java.lang.String[] loadStrings(java.io.File file)

loadStrings

public java.lang.String[] loadStrings(java.lang.String filename)
Load data from a file and shove it into a String array.

Exceptions are handled internally, when an error, occurs, an exception is printed to the console and 'null' is returned, but the program continues running. This is a tradeoff between 1) showing the user that there was a problem but 2) not requiring that all i/o code is contained in try/catch blocks, for the sake of new users (or people who are just trying to get things done in a "scripting" fashion. If you want to handle exceptions, use Java methods for I/O.


loadStrings

public static java.lang.String[] loadStrings(java.io.InputStream input)

createOutput

public java.io.OutputStream createOutput(java.lang.String filename)
Similar to createInput() (formerly openStream), this creates a Java OutputStream for a given filename or path. The file will be created in the sketch folder, or in the same folder as an exported application.

If the path does not exist, intermediate folders will be created. If an exception occurs, it will be printed to the console, and null will be returned.

Future releases may also add support for handling HTTP POST via this method (for better symmetry with createInput), however that's maybe a little too clever (and then we'd have to add the same features to the other file functions like createWriter). Who you callin' bloated?


createOutput

public static java.io.OutputStream createOutput(java.io.File file)

saveStream

public void saveStream(java.lang.String targetFilename,
                       java.lang.String sourceLocation)
Save the contents of a stream to a file in the sketch folder. This is basically saveBytes(blah, loadBytes()), but done more efficiently (and with less confusing syntax).


saveStream

public void saveStream(java.io.File targetFile,
                       java.lang.String sourceLocation)
Identical to the other saveStream(), but writes to a File object, for greater control over the file location. Note that unlike other api methods, this will not automatically compress or uncompress gzip files.


saveStream

public static void saveStream(java.io.File targetFile,
                              java.io.InputStream sourceStream)

saveBytes

public void saveBytes(java.lang.String filename,
                      byte[] buffer)
Saves bytes to a file to inside the sketch folder. The filename can be a relative path, i.e. "poo/bytefun.txt" would save to a file named "bytefun.txt" to a subfolder called 'poo' inside the sketch folder. If the in-between subfolders don't exist, they'll be created.


saveBytes

public static void saveBytes(java.io.File file,
                             byte[] buffer)
Saves bytes to a specific File location specified by the user.


saveBytes

public static void saveBytes(java.io.OutputStream output,
                             byte[] buffer)
Spews a buffer of bytes to an OutputStream.


saveStrings

public void saveStrings(java.lang.String filename,
                        java.lang.String[] strings)

saveStrings

public static void saveStrings(java.io.File file,
                               java.lang.String[] strings)

saveStrings

public static void saveStrings(java.io.OutputStream output,
                               java.lang.String[] strings)

sketchPath

public java.lang.String sketchPath(java.lang.String where)
Prepend the sketch folder path to the filename (or path) that is passed in. External libraries should use this function to save to the sketch folder.

Note that when running as an applet inside a web browser, the sketchPath will be set to null, because security restrictions prevent applets from accessing that information.

This will also cause an error if the sketch is not inited properly, meaning that init() was never called on the PApplet when hosted my some other main() or by other code. For proper use of init(), see the examples in the main description text for PApplet.


sketchFile

public java.io.File sketchFile(java.lang.String where)

savePath

public java.lang.String savePath(java.lang.String where)
Returns a path inside the applet folder to save to. Like sketchPath(), but creates any in-between folders so that things save properly.

All saveXxxx() functions use the path to the sketch folder, rather than its data folder. Once exported, the data folder will be found inside the jar file of the exported application or applet. In this case, it's not possible to save data into the jar file, because it will often be running from a server, or marked in-use if running from a local file system. With this in mind, saving to the data path doesn't make sense anyway. If you know you're running locally, and want to save to the data folder, use saveXxxx("data/blah.dat").


saveFile

public java.io.File saveFile(java.lang.String where)
Identical to savePath(), but returns a File object.


dataPath

public java.lang.String dataPath(java.lang.String where)
Return a full path to an item in the data folder.

In this method, the data path is defined not as the applet's actual data path, but a folder titled "data" in the sketch's working directory. When running inside the PDE, this will be the sketch's "data" folder. However, when exported (as application or applet), sketch's data folder is exported as part of the applications jar file, and it's not possible to read/write from the jar file in a generic way. If you need to read data from the jar file, you should use createInput().


dataFile

public java.io.File dataFile(java.lang.String where)
Return a full path to an item in the data folder as a File object. See the dataPath() method for more information.


createPath

public static void createPath(java.lang.String path)
Takes a path and creates any in-between folders if they don't already exist. Useful when trying to save to a subfolder that may not actually exist.


createPath

public static void createPath(java.io.File file)

sort

public static byte[] sort(byte[] what)

sort

public static byte[] sort(byte[] what,
                          int count)

sort

public static char[] sort(char[] what)

sort

public static char[] sort(char[] what,
                          int count)

sort

public static int[] sort(int[] what)

sort

public static int[] sort(int[] what,
                         int count)

sort

public static float[] sort(float[] what)

sort

public static float[] sort(float[] what,
                           int count)

sort

public static java.lang.String[] sort(java.lang.String[] what)

sort

public static java.lang.String[] sort(java.lang.String[] what,
                                      int count)

arrayCopy

public static void arrayCopy(java.lang.Object src,
                             int srcPosition,
                             java.lang.Object dst,
                             int dstPosition,
                             int length)
Calls System.arraycopy(), included here so that we can avoid people needing to learn about the System object before they can just copy an array.


arrayCopy

public static void arrayCopy(java.lang.Object src,
                             java.lang.Object dst,
                             int length)
Convenience method for arraycopy(). Identical to arraycopy(src, 0, dst, 0, length);


arrayCopy

public static void arrayCopy(java.lang.Object src,
                             java.lang.Object dst)
Shortcut to copy the entire contents of the source into the destination array. Identical to arraycopy(src, 0, dst, 0, src.length);


arraycopy

public static void arraycopy(java.lang.Object src,
                             int srcPosition,
                             java.lang.Object dst,
                             int dstPosition,
                             int length)
Deprecated. Use arrayCopy() instead.


arraycopy

public static void arraycopy(java.lang.Object src,
                             java.lang.Object dst,
                             int length)
Deprecated. Use arrayCopy() instead.


arraycopy

public static void arraycopy(java.lang.Object src,
                             java.lang.Object dst)
Deprecated. Use arrayCopy() instead.


expand

public static boolean[] expand(boolean[] list)

expand

public static boolean[] expand(boolean[] list,
                               int newSize)

expand

public static byte[] expand(byte[] list)

expand

public static byte[] expand(byte[] list,
                            int newSize)

expand

public static char[] expand(char[] list)

expand

public static char[] expand(char[] list,
                            int newSize)

expand

public static int[] expand(int[] list)

expand

public static int[] expand(int[] list,
                           int newSize)

expand

public static float[] expand(float[] list)

expand

public static float[] expand(float[] list,
                             int newSize)

expand

public static java.lang.String[] expand(java.lang.String[] list)

expand

public static java.lang.String[] expand(java.lang.String[] list,
                                        int newSize)

expand

public static java.lang.Object expand(java.lang.Object array)

expand

public static java.lang.Object expand(java.lang.Object list,
                                      int newSize)

append

public static byte[] append(byte[] b,
                            byte value)

append

public static char[] append(char[] b,
                            char value)

append

public static int[] append(int[] b,
                           int value)

append

public static float[] append(float[] b,
                             float value)

append

public static java.lang.String[] append(java.lang.String[] b,
                                        java.lang.String value)

append

public static java.lang.Object append(java.lang.Object b,
                                      java.lang.Object value)

shorten

public static boolean[] shorten(boolean[] list)

shorten

public static byte[] shorten(byte[] list)

shorten

public static char[] shorten(char[] list)

shorten

public static int[] shorten(int[] list)

shorten

public static float[] shorten(float[] list)

shorten

public static java.lang.String[] shorten(java.lang.String[] list)

shorten

public static java.lang.Object shorten(java.lang.Object list)

splice

public static final boolean[] splice(boolean[] list,
                                     boolean v,
                                     int index)

splice

public static final boolean[] splice(boolean[] list,
                                     boolean[] v,
                                     int index)

splice

public static final byte[] splice(byte[] list,
                                  byte v,
                                  int index)

splice

public static final byte[] splice(byte[] list,
                                  byte[] v,
                                  int index)

splice

public static final char[] splice(char[] list,
                                  char v,
                                  int index)

splice

public static final char[] splice(char[] list,
                                  char[] v,
                                  int index)

splice

public static final int[] splice(int[] list,
                                 int v,
                                 int index)

splice

public static final int[] splice(int[] list,
                                 int[] v,
                                 int index)

splice

public static final float[] splice(float[] list,
                                   float v,
                                   int index)

splice

public static final float[] splice(float[] list,
                                   float[] v,
                                   int index)

splice

public static final java.lang.String[] splice(java.lang.String[] list,
                                              java.lang.String v,
                                              int index)

splice

public static final java.lang.String[] splice(java.lang.String[] list,
                                              java.lang.String[] v,
                                              int index)

splice

public static final java.lang.Object splice(java.lang.Object list,
                                            java.lang.Object v,
                                            int index)

subset

public static boolean[] subset(boolean[] list,
                               int start)

subset

public static boolean[] subset(boolean[] list,
                               int start,
                               int count)

subset

public static byte[] subset(byte[] list,
                            int start)

subset

public static byte[] subset(byte[] list,
                            int start,
                            int count)

subset

public static char[] subset(char[] list,
                            int start)

subset

public static char[] subset(char[] list,
                            int start,
                            int count)

subset

public static int[] subset(int[] list,
                           int start)

subset

public static int[] subset(int[] list,
                           int start,
                           int count)

subset

public static float[] subset(float[] list,
                             int start)

subset

public static float[] subset(float[] list,
                             int start,
                             int count)

subset

public static java.lang.String[] subset(java.lang.String[] list,
                                        int start)

subset

public static java.lang.String[] subset(java.lang.String[] list,
                                        int start,
                                        int count)

subset

public static java.lang.Object subset(java.lang.Object list,
                                      int start)

subset

public static java.lang.Object subset(java.lang.Object list,
                                      int start,
                                      int count)

concat

public static boolean[] concat(boolean[] a,
                               boolean[] b)

concat

public static byte[] concat(byte[] a,
                            byte[] b)

concat

public static char[] concat(char[] a,
                            char[] b)

concat

public static int[] concat(int[] a,
                           int[] b)

concat

public static float[] concat(float[] a,
                             float[] b)

concat

public static java.lang.String[] concat(java.lang.String[] a,
                                        java.lang.String[] b)

concat

public static java.lang.Object concat(java.lang.Object a,
                                      java.lang.Object b)

reverse

public static boolean[] reverse(boolean[] list)

reverse

public static byte[] reverse(byte[] list)

reverse

public static char[] reverse(char[] list)

reverse

public static int[] reverse(int[] list)

reverse

public static float[] reverse(float[] list)

reverse

public static java.lang.String[] reverse(java.lang.String[] list)

reverse

public static java.lang.Object reverse(java.lang.Object list)

trim

public static java.lang.String trim(java.lang.String str)
Remove whitespace characters from the beginning and ending of a String. Works like String.trim() but includes the unicode nbsp character as well.


trim

public static java.lang.String[] trim(java.lang.String[] array)
Trim the whitespace from a String array. This returns a new array and does not affect the passed-in array.


join

public static java.lang.String join(java.lang.String[] str,
                                    char separator)
Join an array of Strings together as a single String, separated by the whatever's passed in for the separator.


join

public static java.lang.String join(java.lang.String[] str,
                                    java.lang.String separator)
Join an array of Strings together as a single String, separated by the whatever's passed in for the separator.

To use this on numbers, first pass the array to nf() or nfs() to get a list of String objects, then use join on that.

 e.g. String stuff[] = { "apple", "bear", "cat" };
      String list = join(stuff, ", ");
      // list is now "apple, bear, cat"


splitTokens

public static java.lang.String[] splitTokens(java.lang.String what)
Split the provided String at wherever whitespace occurs. Multiple whitespace (extra spaces or tabs or whatever) between items will count as a single break.

The whitespace characters are "\t\n\r\f", which are the defaults for java.util.StringTokenizer, plus the unicode non-breaking space character, which is found commonly on files created by or used in conjunction with Mac OS X (character 160, or 0x00A0 in hex).

 i.e. splitTokens("a b") -> { "a", "b" }
      splitTokens("a    b") -> { "a", "b" }
      splitTokens("a\tb") -> { "a", "b" }
      splitTokens("a \t  b  ") -> { "a", "b" }


splitTokens

public static java.lang.String[] splitTokens(java.lang.String what,
                                             java.lang.String delim)
Splits a string into pieces, using any of the chars in the String 'delim' as separator characters. For instance, in addition to white space, you might want to treat commas as a separator. The delimeter characters won't appear in the returned String array.
 i.e. splitTokens("a, b", " ,") -> { "a", "b" }
 
To include all the whitespace possibilities, use the variable WHITESPACE, found in PConstants:
 i.e. splitTokens("a   | b", WHITESPACE + "|");  ->  { "a", "b" }


split

public static java.lang.String[] split(java.lang.String what,
                                       char delim)
Split a string into pieces along a specific character. Most commonly used to break up a String along a space or a tab character.

This operates differently than the others, where the single delimeter is the only breaking point, and consecutive delimeters will produce an empty string (""). This way, one can split on tab characters, but maintain the column alignments (of say an excel file) where there are empty columns.


split

public static java.lang.String[] split(java.lang.String what,
                                       java.lang.String delim)
Split a String on a specific delimiter. Unlike Java's String.split() method, this does not parse the delimiter as a regexp because it's more confusing than necessary, and String.split() is always available for those who want regexp.


match

public static java.lang.String[] match(java.lang.String what,
                                       java.lang.String regexp)
Match 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). This uses multiline matching (Pattern.MULTILINE) and dotall mode (Pattern.DOTALL) by default, so that ^ and $ match the beginning and end of any lines found in the source, and the . operator will also pick up newline characters.


matchAll

public static java.lang.String[][] matchAll(java.lang.String what,
                                            java.lang.String regexp)
Identical to match(), except that it returns an array of all matches in the specified String, rather than just the first.


parseBoolean

public static final boolean parseBoolean(int what)

Convert an integer to a boolean. Because of how Java handles upgrading numbers, this will also cover byte and char (as they will upgrade to an int without any sort of explicit cast).

The preprocessor will convert boolean(what) to parseBoolean(what).

Returns:
false if 0, true if any other number

parseBoolean

public static final boolean parseBoolean(java.lang.String what)
Convert the string "true" or "false" to a boolean.

Returns:
true if 'what' is "true" or "TRUE", false otherwise

parseBoolean

public static final boolean[] parseBoolean(byte[] what)
Convert a byte array to a boolean array. Each element will be evaluated identical to the integer case, where a byte equal to zero will return false, and any other value will return true.

Returns:
array of boolean elements

parseBoolean

public static final boolean[] parseBoolean(int[] what)
Convert an int array to a boolean array. An int equal to zero will return false, and any other value will return true.

Returns:
array of boolean elements

parseBoolean

public static final boolean[] parseBoolean(java.lang.String[] what)

parseByte

public static final byte parseByte(boolean what)

parseByte

public static final byte parseByte(char what)

parseByte

public static final byte parseByte(int what)

parseByte

public static final byte parseByte(float what)

parseByte

public static final byte[] parseByte(boolean[] what)

parseByte

public static final byte[] parseByte(char[] what)

parseByte

public static final byte[] parseByte(int[] what)

parseByte

public static final byte[] parseByte(float[] what)

parseChar

public static final char parseChar(byte what)

parseChar

public static final char parseChar(int what)

parseChar

public static final char[] parseChar(byte[] what)

parseChar

public static final char[] parseChar(int[] what)

parseInt

public static final int parseInt(boolean what)

parseInt

public static final int parseInt(byte what)
Note that parseInt() will un-sign a signed byte value.


parseInt

public static final int parseInt(char what)
Note that parseInt('5') is unlike String in the sense that it won't return 5, but the ascii value. This is because ((int) someChar) returns the ascii value, and parseInt() is just longhand for the cast.


parseInt

public static final int parseInt(float what)
Same as floor(), or an (int) cast.


parseInt

public static final int parseInt(java.lang.String what)
Parse a String into an int value. Returns 0 if the value is bad.


parseInt

public static final int parseInt(java.lang.String what,
                                 int otherwise)
Parse a String to an int, and provide an alternate value that should be used when the number is invalid.


parseInt

public static final int[] parseInt(boolean[] what)

parseInt

public static final int[] parseInt(byte[] what)

parseInt

public static final int[] parseInt(char[] what)

parseInt

public static int[] parseInt(float[] what)

parseInt

public static int[] parseInt(java.lang.String[] what)
Make an array of int elements from an array of String objects. If the String can't be parsed as a number, it will be set to zero. String s[] = { "1", "300", "44" }; int numbers[] = parseInt(s); numbers will contain { 1, 300, 44 }


parseInt

public static int[] parseInt(java.lang.String[] what,
                             int missing)
Make an array of int elements from an array of String objects. If the String can't be parsed as a number, its entry in the array will be set to the value of the "missing" parameter. String s[] = { "1", "300", "apple", "44" }; int numbers[] = parseInt(s, 9999); numbers will contain { 1, 300, 9999, 44 }


parseFloat

public static final float parseFloat(int what)
Convert an int to a float value. Also handles bytes because of Java's rules for upgrading values.


parseFloat

public static final float parseFloat(java.lang.String what)

parseFloat

public static final float parseFloat(java.lang.String what,
                                     float otherwise)

parseByte

public static final float[] parseByte(byte[] what)

parseFloat

public static final float[] parseFloat(int[] what)

parseFloat

public static final float[] parseFloat(java.lang.String[] what)

parseFloat

public static final float[] parseFloat(java.lang.String[] what,
                                       float missing)

str

public static final java.lang.String str(boolean x)

str

public static final java.lang.String str(byte x)

str

public static final java.lang.String str(char x)

str

public static final java.lang.String str(int x)

str

public static final java.lang.String str(float x)

str

public static final java.lang.String[] str(boolean[] x)

str

public static final java.lang.String[] str(byte[] x)

str

public static final java.lang.String[] str(char[] x)

str

public static final java.lang.String[] str(int[] x)

str

public static final java.lang.String[] str(float[] x)

nf

public static java.lang.String[] nf(int[] num,
                                    int digits)

nf

public static java.lang.String nf(int num,
                                  int digits)

nfc

public static java.lang.String[] nfc(int[] num)

nfc

public static java.lang.String nfc(int num)

nfs

public static java.lang.String nfs(int num,
                                   int digits)
number format signed (or space) Formats a number but leaves a blank space in the front when it's positive so that it can be properly aligned with numbers that have a negative sign in front of them.


nfs

public static java.lang.String[] nfs(int[] num,
                                     int digits)

nfp

public static java.lang.String nfp(int num,
                                   int digits)
number format positive (or plus) Formats a number, always placing a - or + sign in the front when it's negative or positive.


nfp

public static java.lang.String[] nfp(int[] num,
                                     int digits)

nf

public static java.lang.String[] nf(float[] num,
                                    int left,
                                    int right)

nf

public static java.lang.String nf(float num,
                                  int left,
                                  int right)

nfc

public static java.lang.String[] nfc(float[] num,
                                     int right)

nfc

public static java.lang.String nfc(float num,
                                   int right)

nfs

public static java.lang.String[] nfs(float[] num,
                                     int left,
                                     int right)
Number formatter that takes into account whether the number has a sign (positive, negative, etc) in front of it.


nfs

public static java.lang.String nfs(float num,
                                   int left,
                                   int right)

nfp

public static java.lang.String[] nfp(float[] num,
                                     int left,
                                     int right)

nfp

public static java.lang.String nfp(float num,
                                   int left,
                                   int right)

hex

public static final java.lang.String hex(byte what)

hex

public static final java.lang.String hex(char what)

hex

public static final java.lang.String hex(int what)

hex

public static final java.lang.String hex(int what,
                                         int digits)

unhex

public static final int unhex(java.lang.String what)

binary

public static final java.lang.String binary(byte what)
Returns a String that contains the binary value of a byte. The returned value will always have 8 digits.


binary

public static final java.lang.String binary(char what)
Returns a String that contains the binary value of a char. The returned value will always have 16 digits because chars are two bytes long.


binary

public static final java.lang.String binary(int what)
Returns a String that contains the binary value of an int. The length depends on the size of the number itself. An int can be up to 32 binary digits, but that seems like overkill for almost any situation, so this function just auto-size. If you want a specific number of digits (like all 32) use binary(int what, int digits) to specify how many digits.


binary

public static final java.lang.String binary(int what,
                                            int digits)
Returns a String that contains the binary value of an int. The digits parameter determines how many digits will be used.


unbinary

public static final int unbinary(java.lang.String what)
Unpack a binary String into an int. i.e. unbinary("00001000") would return 8.


color

public final int color(int gray)

color

public final int color(float fgray)

color

public final int color(int gray,
                       int alpha)
As of 0116 this also takes color(#FF8800, alpha)


color

public final int color(float fgray,
                       float falpha)

color

public final int color(int x,
                       int y,
                       int z)

color

public final int color(float x,
                       float y,
                       float z)

color

public final int color(int x,
                       int y,
                       int z,
                       int a)

color

public final int color(float x,
                       float y,
                       float z,
                       float a)

setupExternalMessages

public void setupExternalMessages()
Set this sketch to communicate its state back to the PDE.

This uses the stderr stream to write positions of the window (so that it will be saved by the PDE for the next run) and notify on quit. See more notes in the Worker class.


setupFrameResizeListener

public void setupFrameResizeListener()
Set up a listener that will fire proper component resize events in cases where frame.setResizable(true) is called.


main

public static void main(java.lang.String[] args)
main() method for running this class from the command line.

The options shown here are not yet finalized and will be changing over the next several releases.

The simplest way to turn and applet into an application is to add the following code to your program:

static public void main(String args[]) {
   PApplet.main(new String[] { "YourSketchName" });
 }
This will properly launch your applet from a double-clickable .jar or from the command line.
 Parameters useful for launching or also used by the PDE:

 --location=x,y        upper-lefthand corner of where the applet
                       should appear on screen. if not used,
                       the default is to center on the main screen.

 --present             put the applet into full screen presentation
                       mode. requires java 1.4 or later.
                       
 --exclusive           use full screen exclusive mode when presenting.
                       disables new windows or interaction with other 
                       monitors, this is like a "game" mode.

 --hide-stop           use to hide the stop button in situations where
                       you don't want to allow users to exit. also
                       see the FAQ on information for capturing the ESC
                       key when running in presentation mode.

 --stop-color=#xxxxxx  color of the 'stop' text used to quit an
                       sketch when it's in present mode.

 --bgcolor=#xxxxxx     background color of the window.

 --sketch-path         location of where to save files from functions
                       like saveStrings() or saveFrame(). defaults to
                       the folder that the java application was
                       launched from, which means if this isn't set by
                       the pde, everything goes into the same folder
                       as processing.exe.

 --display=n           set what display should be used by this applet.
                       displays are numbered starting from 1.

 Parameters used by Processing when running via the PDE

 --external            set when the applet is being used by the PDE

 --editor-location=x,y position of the upper-lefthand corner of the
                       editor window, for placement of applet window
 


beginRecord

public PGraphics beginRecord(java.lang.String renderer,
                             java.lang.String filename)
Begin recording to a new renderer of the specified type, using the width and height of the main drawing surface.


beginRecord

public void beginRecord(PGraphics recorder)
Begin recording (echoing) commands to the specified PGraphics object.


endRecord

public void endRecord()

beginRaw

public PGraphics beginRaw(java.lang.String renderer,
                          java.lang.String filename)
Begin recording raw shape data to a renderer of the specified type, using the width and height of the main drawing surface. If hashmarks (###) are found in the filename, they'll be replaced by the current frame number (frameCount).


beginRaw

public void beginRaw(PGraphics rawGraphics)
Begin recording raw shape data to the specified renderer. This simply echoes to g.beginRaw(), but since is placed here (rather than generated by preproc.pl) for clarity and so that it doesn't echo the command should beginRecord() be in use.


endRaw

public void endRaw()
Stop recording raw shape data to the specified renderer. This simply echoes to g.beginRaw(), but since is placed here (rather than generated by preproc.pl) for clarity and so that it doesn't echo the command should beginRecord() be in use.


loadPixels

public void loadPixels()
Override the g.pixels[] function to set the pixels[] array that's part of the PApplet object. Allows the use of pixels[] in the code, rather than g.pixels[].


updatePixels

public void updatePixels()

updatePixels

public void updatePixels(int x1,
                         int y1,
                         int x2,
                         int y2)

flush

public void flush()

hint

public void hint(int which)

beginShape

public void beginShape()

beginShape

public void beginShape(int kind)

edge

public void edge(boolean edge)

normal

public void normal(float nx,
                   float ny,
                   float nz)

textureMode

public void textureMode(int mode)

texture

public void texture(PImage image)

vertex

public void vertex(float x,
                   float y)

vertex

public void vertex(float x,
                   float y,
                   float z)

vertex

public void vertex(float[] v)

vertex

public void vertex(float x,
                   float y,
                   float u,
                   float v)

vertex

public void vertex(float x,
                   float y,
                   float z,
                   float u,
                   float v)

breakShape

public void breakShape()

endShape

public void endShape()

endShape

public void endShape(int mode)

bezierVertex

public void bezierVertex(float x2,
                         float y2,
                         float x3,
                         float y3,
                         float x4,
                         float y4)

bezierVertex

public void bezierVertex(float x2,
                         float y2,
                         float z2,
                         float x3,
                         float y3,
                         float z3,
                         float x4,
                         float y4,
                         float z4)

curveVertex

public void curveVertex(float x,
                        float y)

curveVertex

public void curveVertex(float x,
                        float y,
                        float z)

point

public void point(float x,
                  float y)

point

public void point(float x,
                  float y,
                  float z)

line

public void line(float x1,
                 float y1,
                 float x2,
                 float y2)

line

public void line(float x1,
                 float y1,
                 float z1,
                 float x2,
                 float y2,
                 float z2)

triangle

public void triangle(float x1,
                     float y1,
                     float x2,
                     float y2,
                     float x3,
                     float y3)

quad

public void quad(float x1,
                 float y1,
                 float x2,
                 float y2,
                 float x3,
                 float y3,
                 float x4,
                 float y4)

rectMode

public void rectMode(int mode)

rect

public void rect(float a,
                 float b,
                 float c,
                 float d)

ellipseMode

public void ellipseMode(int mode)

ellipse

public void ellipse(float a,
                    float b,
                    float c,
                    float d)

arc

public void arc(float a,
                float b,
                float c,
                float d,
                float start,
                float stop)

box

public void box(float size)

box

public void box(float w,
                float h,
                float d)

sphereDetail

public void sphereDetail(int res)

sphereDetail

public void sphereDetail(int ures,
                         int vres)

sphere

public void sphere(float r)

bezierPoint

public float bezierPoint(float a,
                         float b,
                         float c,
                         float d,
                         float t)

bezierTangent

public float bezierTangent(float a,
                           float b,
                           float c,
                           float d,
                           float t)

bezierDetail

public void bezierDetail(int detail)

bezier

public void bezier(float x1,
                   float y1,
                   float x2,
                   float y2,
                   float x3,
                   float y3,
                   float x4,
                   float y4)

bezier

public void bezier(float x1,
                   float y1,
                   float z1,
                   float x2,
                   float y2,
                   float z2,
                   float x3,
                   float y3,
                   float z3,
                   float x4,
                   float y4,
                   float z4)

curvePoint

public float curvePoint(float a,
                        float b,
                        float c,
                        float d,
                        float t)

curveTangent

public float curveTangent(float a,
                          float b,
                          float c,
                          float d,
                          float t)

curveDetail

public void curveDetail(int detail)

curveTightness

public void curveTightness(float tightness)

curve

public void curve(float x1,
                  float y1,
                  float x2,
                  float y2,
                  float x3,
                  float y3,
                  float x4,
                  float y4)

curve

public void curve(float x1,
                  float y1,
                  float z1,
                  float x2,
                  float y2,
                  float z2,
                  float x3,
                  float y3,
                  float z3,
                  float x4,
                  float y4,
                  float z4)

smooth

public void smooth()

noSmooth

public void noSmooth()

imageMode

public void imageMode(int mode)

image

public void image(PImage image,
                  float x,
                  float y)

image

public void image(PImage image,
                  float x,
                  float y,
                  float c,
                  float d)

image

public void image(PImage image,
                  float a,
                  float b,
                  float c,
                  float d,
                  int u1,
                  int v1,
                  int u2,
                  int v2)

shapeMode

public void shapeMode(int mode)

shape

public void shape(PShape shape)

shape

public void shape(PShape shape,
                  float x,
                  float y)

shape

public void shape(PShape shape,
                  float x,
                  float y,
                  float c,
                  float d)

textAlign

public void textAlign(int align)

textAlign

public void textAlign(int alignX,
                      int alignY)

textAscent

public float textAscent()

textDescent

public float textDescent()

textFont

public void textFont(PFont which)

textFont

public void textFont(PFont which,
                     float size)

textLeading

public void textLeading(float leading)

textMode

public void textMode(int mode)

textSize

public void textSize(float size)

textWidth

public float textWidth(char c)

textWidth

public float textWidth(java.lang.String str)

text

public void text(char c)

text

public void text(char c,
                 float x,
                 float y)

text

public void text(char c,
                 float x,
                 float y,
                 float z)

text

public void text(java.lang.String str)

text

public void text(java.lang.String str,
                 float x,
                 float y)

text

public void text(char[] chars,
                 int start,
                 int stop,
                 float x,
                 float y)

text

public void text(java.lang.String str,
                 float x,
                 float y,
                 float z)

text

public void text(char[] chars,
                 int start,
                 int stop,
                 float x,
                 float y,
                 float z)

text

public void text(java.lang.String str,
                 float x1,
                 float y1,
                 float x2,
                 float y2)

text

public void text(java.lang.String s,
                 float x1,
                 float y1,
                 float x2,
                 float y2,
                 float z)

text

public void text(int num,
                 float x,
                 float y)

text

public void text(int num,
                 float x,
                 float y,
                 float z)

text

public void text(float num,
                 float x,
                 float y)

text

public void text(float num,
                 float x,
                 float y,
                 float z)

pushMatrix

public void pushMatrix()

popMatrix

public void popMatrix()

translate

public void translate(float tx,
                      float ty)

translate

public void translate(float tx,
                      float ty,
                      float tz)

rotate

public void rotate(float angle)

rotateX

public void rotateX(float angle)

rotateY

public void rotateY(float angle)

rotateZ

public void rotateZ(float angle)

rotate

public void rotate(float angle,
                   float vx,
                   float vy,
                   float vz)

scale

public void scale(float s)

scale

public void scale(float sx,
                  float sy)

scale

public void scale(float x,
                  float y,
                  float z)

resetMatrix

public void resetMatrix()

applyMatrix

public void applyMatrix(PMatrix source)

applyMatrix

public void applyMatrix(PMatrix2D source)

applyMatrix

public void applyMatrix(float n00,
                        float n01,
                        float n02,
                        float n10,
                        float n11,
                        float n12)

applyMatrix

public void applyMatrix(PMatrix3D source)

applyMatrix

public void applyMatrix(float n00,
                        float n01,
                        float n02,
                        float n03,
                        float n10,
                        float n11,
                        float n12,
                        float n13,
                        float n20,
                        float n21,
                        float n22,
                        float n23,
                        float n30,
                        float n31,
                        float n32,
                        float n33)

getMatrix

public PMatrix getMatrix()

getMatrix

public PMatrix2D getMatrix(PMatrix2D target)

getMatrix

public PMatrix3D getMatrix(PMatrix3D target)

setMatrix

public void setMatrix(PMatrix source)

setMatrix

public void setMatrix(PMatrix2D source)

setMatrix

public void setMatrix(PMatrix3D source)

printMatrix

public void printMatrix()

beginCamera

public void beginCamera()

endCamera

public void endCamera()

camera

public void camera()

camera

public void camera(float eyeX,
                   float eyeY,
                   float eyeZ,
                   float centerX,
                   float centerY,
                   float centerZ,
                   float upX,
                   float upY,
                   float upZ)

printCamera

public void printCamera()

ortho

public void ortho()

ortho

public void ortho(float left,
                  float right,
                  float bottom,
                  float top,
                  float near,
                  float far)

perspective

public void perspective()

perspective

public void perspective(float fovy,
                        float aspect,
                        float zNear,
                        float zFar)

frustum

public void frustum(float left,
                    float right,
                    float bottom,
                    float top,
                    float near,
                    float far)

printProjection

public void printProjection()

screenX

public float screenX(float x,
                     float y)

screenY

public float screenY(float x,
                     float y)

screenX

public float screenX(float x,
                     float y,
                     float z)

screenY

public float screenY(float x,
                     float y,
                     float z)

screenZ

public float screenZ(float x,
                     float y,
                     float z)

modelX

public float modelX(float x,
                    float y,
                    float z)

modelY

public float modelY(float x,
                    float y,
                    float z)

modelZ

public float modelZ(float x,
                    float y,
                    float z)

pushStyle

public void pushStyle()

popStyle

public void popStyle()

style

public void style(PStyle s)

strokeWeight

public void strokeWeight(float weight)

strokeJoin

public void strokeJoin(int join)

strokeCap

public void strokeCap(int cap)

noStroke

public void noStroke()

stroke

public void stroke(int rgb)

stroke

public void stroke(int rgb,
                   float alpha)

stroke

public void stroke(float gray)

stroke

public void stroke(float gray,
                   float alpha)

stroke

public void stroke(float x,
                   float y,
                   float z)

stroke

public void stroke(float x,
                   float y,
                   float z,
                   float a)

noTint

public void noTint()

tint

public void tint(int rgb)

tint

public void tint(int rgb,
                 float alpha)

tint

public void tint(float gray)

tint

public void tint(float gray,
                 float alpha)

tint

public void tint(float x,
                 float y,
                 float z)

tint

public void tint(float x,
                 float y,
                 float z,
                 float a)

noFill

public void noFill()

fill

public void fill(int rgb)

fill

public void fill(int rgb,
                 float alpha)

fill

public void fill(float gray)

fill

public void fill(float gray,
                 float alpha)

fill

public void fill(float x,
                 float y,
                 float z)

fill

public void fill(float x,
                 float y,
                 float z,
                 float a)

ambient

public void ambient(int rgb)

ambient

public void ambient(float gray)

ambient

public void ambient(float x,
                    float y,
                    float z)

specular

public void specular(int rgb)

specular

public void specular(float gray)

specular

public void specular(float x,
                     float y,
                     float z)

shininess

public void shininess(float shine)

emissive

public void emissive(int rgb)

emissive

public void emissive(float gray)

emissive

public void emissive(float x,
                     float y,
                     float z)

lights

public void lights()

noLights

public void noLights()

ambientLight

public void ambientLight(float red,
                         float green,
                         float blue)

ambientLight

public void ambientLight(float red,
                         float green,
                         float blue,
                         float x,
                         float y,
                         float z)

directionalLight

public void directionalLight(float red,
                             float green,
                             float blue,
                             float nx,
                             float ny,
                             float nz)

pointLight

public void pointLight(float red,
                       float green,
                       float blue,
                       float x,
                       float y,
                       float z)

spotLight

public void spotLight(float red,
                      float green,
                      float blue,
                      float x,
                      float y,
                      float z,
                      float nx,
                      float ny,
                      float nz,
                      float angle,
                      float concentration)

lightFalloff

public void lightFalloff(float constant,
                         float linear,
                         float quadratic)

lightSpecular

public void lightSpecular(float x,
                          float y,
                          float z)

background

public void background(int rgb)

background

public void background(int rgb,
                       float alpha)

background

public void background(float gray)

background

public void background(float gray,
                       float alpha)

background

public void background(float x,
                       float y,
                       float z)

background

public void background(float x,
                       float y,
                       float z,
                       float a)

background

public void background(PImage image)

colorMode

public void colorMode(int mode)

colorMode

public void colorMode(int mode,
                      float max)

colorMode

public void colorMode(int mode,
                      float maxX,
                      float maxY,
                      float maxZ)

colorMode

public void colorMode(int mode,
                      float maxX,
                      float maxY,
                      float maxZ,
                      float maxA)

alpha

public final float alpha(int what)

red

public final float red(int what)

green

public final float green(int what)

blue

public final float blue(int what)

hue

public final float hue(int what)

saturation

public final float saturation(int what)

brightness

public final float brightness(int what)

lerpColor

public int lerpColor(int c1,
                     int c2,
                     float amt)

lerpColor

public static int lerpColor(int c1,
                            int c2,
                            float amt,
                            int mode)

displayable

public boolean displayable()

setCache

public void setCache(java.lang.Object parent,
                     java.lang.Object storage)

getCache

public java.lang.Object getCache(java.lang.Object parent)

removeCache

public void removeCache(java.lang.Object parent)

get

public int get(int x,
               int y)

get

public PImage get(int x,
                  int y,
                  int w,
                  int h)

get

public PImage get()

set

public void set(int x,
                int y,
                int c)

set

public void set(int x,
                int y,
                PImage src)

mask

public void mask(int[] alpha)

mask

public void mask(PImage alpha)

filter

public void filter(int kind)

filter

public void filter(int kind,
                   float param)

copy

public void copy(int sx,
                 int sy,
                 int sw,
                 int sh,
                 int dx,
                 int dy,
                 int dw,
                 int dh)

copy

public void copy(PImage src,
                 int sx,
                 int sy,
                 int sw,
                 int sh,
                 int dx,
                 int dy,
                 int dw,
                 int dh)

blendColor

public static int blendColor(int c1,
                             int c2,
                             int mode)

blend

public void blend(int sx,
                  int sy,
                  int sw,
                  int sh,
                  int dx,
                  int dy,
                  int dw,
                  int dh,
                  int mode)

blend

public void blend(PImage src,
                  int sx,
                  int sy,
                  int sw,
                  int sh,
                  int dx,
                  int dy,
                  int dw,
                  int dh,
                  int mode)