Class PApplet

  • All Implemented Interfaces:
    PConstants

    public class PApplet
    extends Object
    implements PConstants
    Base class for all sketches that use processing.core.

    The Window Size and Full Screen page on the Wiki has useful information about sizing, multiple displays, full screen, etc.

    Processing uses active mode rendering. 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().

    Starting with 3.0a6, blit operations are on the EDT, so as not to cause GUI problems with Swing and AWT. In the case of the default renderer, the sketch renders to an offscreen image, then the EDT is asked to bring that image to the screen.

    For code that needs to run on the EDT, use EventQueue.invokeLater(). When doing so, be careful to synchronize between that code and the Processing animation thread. That is, you can't call Processing methods from the EDT or at any random time from another 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 Processing 3.0, we have removed Applet as the base class for PApplet. This means that we can remove lots of legacy code, however one downside is that it's no longer possible (without extra code) to embed a PApplet into another Java application.

    As of Processing 3.0, we have discontinued support for versions of Java prior to 1.8. We don't have enough people to support it, and for a project of our (tiny) size, we should be focusing on the future, rather than working around legacy Java code.

    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  PApplet.GraphicsFactory
      Interface to be registered and loaded by ServiceLoader for creating PGraphics.
      static interface  PApplet.MainThreadContext
      A context for running tasks on the main (first) thread of the application.
    • Constructor Summary

      Constructors 
      Constructor Description
      PApplet()  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and Type Method Description
      static float abs​(float n)
      ( begin auto-generated from abs.xml ) Calculates the absolute value (magnitude) of a number.
      static int abs​(int n)  
      static float acos​(float value)
      ( begin auto-generated from acos.xml ) The inverse of cos(), returns the arc cosine of a value.
      float alpha​(int rgb)
      ( begin auto-generated from alpha.xml ) Extracts the alpha value from a color.
      void ambient​(float gray)  
      void ambient​(float v1, float v2, float v3)  
      void ambient​(int rgb)
      ( begin auto-generated from ambient.xml ) Sets the ambient reflectance for shapes drawn to the screen.
      void ambientLight​(float v1, float v2, float v3)
      ( begin auto-generated from ambientLight.xml ) Adds an ambient light.
      void ambientLight​(float v1, float v2, float v3, float x, float y, float z)  
      static byte[] append​(byte[] array, byte value)
      ( begin auto-generated from append.xml ) Expands an array by one element and adds data to the new position.
      static char[] append​(char[] array, char value)  
      static float[] append​(float[] array, float value)  
      static int[] append​(int[] array, int value)  
      static Object append​(Object array, Object value)  
      static String[] append​(String[] array, 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)
      ( begin auto-generated from applyMatrix.xml ) Multiplies the current matrix by the one specified through the parameters.
      void applyMatrix​(PMatrix2D source)  
      void applyMatrix​(PMatrix3D source)  
      void arc​(float a, float b, float c, float d, float start, float stop)
      ( begin auto-generated from arc.xml ) Draws an arc in the display window.
      void arc​(float a, float b, float c, float d, float start, float stop, int mode)  
      static void arraycopy​(Object src, int srcPosition, Object dst, int dstPosition, int length)
      Deprecated.
      static void arraycopy​(Object src, Object dst)
      Deprecated.
      static void arraycopy​(Object src, Object dst, int length)
      Deprecated.
      static void arrayCopy​(Object src, int srcPosition, Object dst, int dstPosition, int length)
      ( begin auto-generated from arrayCopy.xml ) Copies an array (or part of an array) to another array.
      static void arrayCopy​(Object src, Object dst)
      Shortcut to copy the entire contents of the source into the destination array.
      static void arrayCopy​(Object src, Object dst, int length)
      Convenience method for arraycopy().
      static float asin​(float value)
      ( begin auto-generated from asin.xml ) The inverse of sin(), returns the arc sine of a value.
      static float atan​(float value)
      ( begin auto-generated from atan.xml ) The inverse of tan(), returns the arc tangent of a value.
      static float atan2​(float y, float x)
      ( begin auto-generated from atan2.xml ) Calculates the angle (in radians) from a specified point to the coordinate origin as measured from the positive x-axis.
      void attrib​(String name, boolean... values)  
      void attrib​(String name, float... values)  
      void attrib​(String name, int... values)  
      void attribColor​(String name, int color)  
      void attribNormal​(String name, float nx, float ny, float nz)  
      void attribPosition​(String name, float x, float y, float z)  
      void background​(float gray)  
      void background​(float gray, float alpha)  
      void background​(float v1, float v2, float v3)  
      void background​(float v1, float v2, float v3, float alpha)  
      void background​(int rgb)
      ( begin auto-generated from background.xml ) The background() function sets the color used for the background of the Processing window.
      void background​(int rgb, float alpha)  
      void background​(PImage image)
      Takes an RGB or ARGB image and sets it as the background.
      void beginCamera()
      ( begin auto-generated from beginCamera.xml ) The beginCamera() and endCamera() functions enable advanced customization of the camera space.
      void beginContour()  
      PGL beginPGL()  
      PGraphics beginRaw​(String renderer, String filename)
      ( begin auto-generated from beginRaw.xml ) To create vectors from 3D data, use the beginRaw() and endRaw() commands.
      void beginRaw​(PGraphics rawGraphics)  
      PGraphics beginRecord​(String renderer, String filename)
      ( begin auto-generated from beginRecord.xml ) Opens a new file and all subsequent drawing functions are echoed to this file as well as the display window.
      void beginRecord​(PGraphics recorder)  
      void beginShape()
      Start a new shape of type POLYGON
      void beginShape​(int kind)
      ( begin auto-generated from beginShape.xml ) Using the beginShape() and endShape() functions allow creating more complex forms.
      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)
      ( begin auto-generated from bezier.xml ) Draws a Bezier curve on the screen.
      void bezierDetail​(int detail)
      ( begin auto-generated from bezierDetail.xml ) Sets the resolution at which Beziers display.
      float bezierPoint​(float a, float b, float c, float d, float t)
      ( begin auto-generated from bezierPoint.xml ) Evaluates the Bezier at point t for points a, b, c, d.
      float bezierTangent​(float a, float b, float c, float d, float t)
      ( begin auto-generated from bezierTangent.xml ) Calculates the tangent of a point on a Bezier curve.
      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)
      ( begin auto-generated from bezierVertex.xml ) Specifies vertex coordinates for Bezier curves.
      static String binary​(byte value)
      Returns a String that contains the binary value of a byte.
      static String binary​(char value)
      Returns a String that contains the binary value of a char.
      static String binary​(int value)
      Returns a String that contains the binary value of an int.
      static String binary​(int value, int digits)
      ( begin auto-generated from binary.xml ) Converts a byte, char, int, or color to a String containing the equivalent binary notation.
      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)
      ( begin auto-generated from PImage_blend.xml ) Blends a region of pixels into the image specified by the img parameter.
      static int blendColor​(int c1, int c2, int mode)  
      void blendMode​(int mode)
      ( begin auto-generated from blendMode.xml ) This is a new reference entry for Processing 2.0.
      float blue​(int rgb)
      ( begin auto-generated from blue.xml ) Extracts the blue value from a color, scaled to match current colorMode().
      void box​(float size)
      ( begin auto-generated from box.xml ) A box is an extruded rectangle.
      void box​(float w, float h, float d)  
      float brightness​(int rgb)
      ( begin auto-generated from brightness.xml ) Extracts the brightness value from a color.
      protected static String calcSketchPath()  
      void camera()
      ( begin auto-generated from camera.xml ) Sets the position of the camera through setting the eye position, the center of the scene, and which axis is facing upward.
      void camera​(float eyeX, float eyeY, float eyeZ, float centerX, float centerY, float centerZ, float upX, float upY, float upZ)  
      static int ceil​(float n)
      ( begin auto-generated from ceil.xml ) Calculates the closest int value that is greater than or equal to the value of the parameter.
      static String checkExtension​(String filename)
      Get the compression-free extension for this filename.
      void circle​(float x, float y, float extent)
      ( begin auto-generated from circle.xml ) Draws a circle to the screen.
      void clear()  
      void clip​(float a, float b, float c, float d)
      ( begin auto-generated from clip.xml ) Limits the rendering to the boundaries of a rectangle defined by the parameters.
      int color​(float fgray)  
      int color​(float fgray, float falpha)  
      int color​(float v1, float v2, float v3)  
      int color​(float v1, float v2, float v3, float alpha)  
      int color​(int gray)
      ( begin auto-generated from color.xml ) Creates colors for storing in variables of the color datatype.
      int color​(int gray, int alpha)
      As of 0116 this also takes color(#FF8800, alpha)
      int color​(int v1, int v2, int v3)  
      int color​(int v1, int v2, int v3, int alpha)  
      void colorMode​(int mode)
      ( begin auto-generated from colorMode.xml ) Changes the way Processing interprets color data.
      void colorMode​(int mode, float max)  
      void colorMode​(int mode, float max1, float max2, float max3)  
      void colorMode​(int mode, float max1, float max2, float max3, float maxA)  
      static boolean[] concat​(boolean[] a, boolean[] b)
      ( begin auto-generated from concat.xml ) Concatenates two arrays.
      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 Object concat​(Object a, Object b)  
      static String[] concat​(String[] a, String[] b)  
      static float constrain​(float amt, float low, float high)
      ( begin auto-generated from constrain.xml ) Constrains a value to not exceed a maximum and minimum value.
      static int constrain​(int amt, int low, int high)  
      PImage copy()  
      void copy​(int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh)
      ( begin auto-generated from PImage_copy.xml ) Copies a region of pixels from one image into another.
      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)
      ( begin auto-generated from cos.xml ) Calculates the cosine of an angle.
      PFont createFont​(String name, float size)  
      PFont createFont​(String name, float size, boolean smooth)  
      PFont createFont​(String name, float size, boolean smooth, char[] charset)
      ( begin auto-generated from createFont.xml ) Dynamically converts a font to the format used by Processing from either a font name that's installed on the computer, or from a .ttf or .otf file inside the sketches "data" folder.
      PGraphics createGraphics​(int w, int h)  
      PGraphics createGraphics​(int w, int h, String renderer)
      ( begin auto-generated from createGraphics.xml ) Creates and returns a new PGraphics object of the types P2D or P3D.
      PGraphics createGraphics​(int w, int h, String renderer, String path)
      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 w, int h, int format)
      ( begin auto-generated from createImage.xml ) Creates a new PImage (the datatype for storing images).
      static InputStream createInput​(File file)  
      InputStream createInput​(String filename)
      ( begin auto-generated from createInput.xml ) This is a function for advanced programmers to open a Java InputStream.
      InputStream createInputRaw​(String filename)
      Call openStream() without automatic gzip decompression.
      static OutputStream createOutput​(File file)  
      OutputStream createOutput​(String filename)
      ( begin auto-generated from createOutput.xml ) Similar to createInput(), this creates a Java OutputStream for a given filename or path.
      static void createPath​(File file)  
      static void createPath​(String path)
      Takes a path and creates any in-between folders if they don't already exist.
      protected PGraphics createPrimaryGraphics()
      Create default renderer, likely to be resized, but needed for surface init.
      static BufferedReader createReader​(File file)  
      static BufferedReader createReader​(InputStream input)  
      BufferedReader createReader​(String filename)
      ( begin auto-generated from createReader.xml ) Creates a BufferedReader object that can be used to read files line-by-line as individual String objects.
      PShape createShape()  
      PShape createShape​(int type)  
      PShape createShape​(int kind, float... p)  
      static PrintWriter createWriter​(File file)  
      static PrintWriter createWriter​(OutputStream output)  
      PrintWriter createWriter​(String filename)
      ( begin auto-generated from createWriter.xml ) Creates a new file in the sketch folder, and a PrintWriter object to write to it.
      void cursor()
      Show the cursor after noCursor() was called.
      void cursor​(int kind)
      Set the cursor type
      void cursor​(PImage img)
      Replace the cursor with the specified PImage.
      void cursor​(PImage img, int x, int y)
      ( begin auto-generated from cursor.xml ) Sets the cursor to a predefined symbol, an image, or makes it visible if already hidden.
      void curve​(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
      ( begin auto-generated from curve.xml ) Draws a curved line on the screen.
      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)
      ( begin auto-generated from curveDetail.xml ) Sets the resolution at which curves display.
      float curvePoint​(float a, float b, float c, float d, float t)
      ( begin auto-generated from curvePoint.xml ) Evalutes the curve at point t for points a, b, c, d.
      float curveTangent​(float a, float b, float c, float d, float t)
      ( begin auto-generated from curveTangent.xml ) Calculates the tangent of a point on a curve.
      void curveTightness​(float tightness)
      ( begin auto-generated from curveTightness.xml ) Modifies the quality of forms created with curve() and curveVertex().
      void curveVertex​(float x, float y)
      ( begin auto-generated from curveVertex.xml ) Specifies vertex coordinates for curves.
      void curveVertex​(float x, float y, float z)  
      File dataFile​(String where)
      Return a full path to an item in the data folder as a File object.
      String dataPath​(String where)
      This function almost certainly does not do the thing you want it to. The data path is handled differently on each platform, and should not be considered a location to write files.
      static int day()
      ( begin auto-generated from day.xml ) Processing communicates with the clock on your computer.
      static void debug​(String msg)  
      static float degrees​(float radians)
      ( begin auto-generated from degrees.xml ) Converts a radian measurement to its corresponding value in degrees.
      void delay​(int napTime)
      ( begin auto-generated from delay.xml ) The delay() function causes the program to halt for a specified time.
      protected void dequeueEvents()  
      static File desktopFile​(String what)
      Not a supported function.
      static String desktopPath​(String what)
      Not a supported function.
      void die​(String what)
      Function for an applet/application to kill itself and display an error.
      void die​(String what, Exception e)
      Same as above but with an exception.
      void directionalLight​(float v1, float v2, float v3, float nx, float ny, float nz)
      ( begin auto-generated from directionalLight.xml ) Adds a directional light.
      int displayDensity()
      ( begin auto-generated from displayDensity.xml ) This function returns the number "2" if the screen is a high-density screen (called a Retina display on OS X or high-dpi on Windows and Linux) and a "1" if not.
      int displayDensity​(int display)  
      void dispose()
      Called to dispose of resources and shut down the sketch.
      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)
      ( begin auto-generated from dist.xml ) Calculates the distance between two points.
      void draw()
      ( begin auto-generated from draw.xml ) Called directly after setup() and continuously executes the lines of code contained inside its block until the program is stopped or noLoop() is called.
      void edge​(boolean edge)
      Sets whether the upcoming vertex is part of an edge.
      void ellipse​(float a, float b, float c, float d)
      ( begin auto-generated from ellipse.xml ) Draws an ellipse (oval) in the display window.
      void ellipseMode​(int mode)
      ( begin auto-generated from ellipseMode.xml ) The origin of the ellipse is modified by the ellipseMode() function.
      void emissive​(float gray)
      gray number specifying value between white and black
      void emissive​(float v1, float v2, float v3)  
      void emissive​(int rgb)
      ( begin auto-generated from emissive.xml ) Sets the emissive color of the material used for drawing shapes drawn to the screen.
      void endCamera()
      ( begin auto-generated from endCamera.xml ) The beginCamera() and endCamera() functions enable advanced customization of the camera space.
      void endContour()  
      void endPGL()  
      void endRaw()
      ( begin auto-generated from endRaw.xml ) Complement to beginRaw(); they must always be used together.
      void endRecord()
      ( begin auto-generated from endRecord.xml ) Stops the recording process started by beginRecord() and closes the file.
      void endShape()  
      void endShape​(int mode)
      ( begin auto-generated from endShape.xml ) The endShape() function is the companion to beginShape() and may only be called after beginShape().
      static Process exec​(String... args)
      Pass a set of arguments directly to the command line.
      static int exec​(StringList stdout, StringList stderr, String... args)
      Alternative version of exec() that retrieves stdout and stderr into the StringList objects provided.
      void exit()
      ( begin auto-generated from exit.xml ) Quits/stops/exits the program.
      void exitActual()
      Some subclasses (I'm looking at you, processing.py) might wish to do something other than actually terminate the JVM.
      boolean exitCalled()  
      static float exp​(float n)
      ( begin auto-generated from exp.xml ) Returns Euler's number e (2.71828...) raised to the power of the value parameter.
      static boolean[] expand​(boolean[] list)
      ( begin auto-generated from expand.xml ) Increases the size of an array.
      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 double[] expand​(double[] list)  
      static double[] expand​(double[] 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 long[] expand​(long[] list)  
      static long[] expand​(long[] list, int newSize)  
      static Object expand​(Object array)  
      static Object expand​(Object list, int newSize)  
      static String[] expand​(String[] list)  
      static String[] expand​(String[] list, int newSize)  
      void fill​(float gray)  
      void fill​(float gray, float alpha)  
      void fill​(float v1, float v2, float v3)  
      void fill​(float v1, float v2, float v3, float alpha)  
      void fill​(int rgb)
      ( begin auto-generated from fill.xml ) Sets the color used to fill shapes.
      void fill​(int rgb, float alpha)  
      void filter​(int kind)  
      void filter​(int kind, float param)
      ( begin auto-generated from PImage_filter.xml ) Filters an image as defined by one of the following modes:

      THRESHOLD - converts the image to black and white pixels depending if they are above or below the threshold defined by the level parameter.
      void filter​(PShader shader)  
      static int floor​(float n)
      ( begin auto-generated from floor.xml ) Calculates the closest int value that is less than or equal to the value of the parameter.
      void flush()  
      void focusGained()  
      void focusLost()  
      void frameMoved​(int x, int y)  
      void frameRate​(float fps)
      ( begin auto-generated from frameRate.xml ) Specifies the number of frames to be displayed every second.
      void frameResized​(int w, int h)  
      void frustum​(float left, float right, float bottom, float top, float near, float far)
      ( begin auto-generated from frustum.xml ) Sets a perspective matrix defined through the parameters.
      void fullScreen()
      Create a full-screen sketch using the default renderer.
      void fullScreen​(int display)  
      void fullScreen​(String renderer)
      ( begin auto-generated from fullScreen.xml ) Description to come...
      void fullScreen​(String renderer, int display)  
      PImage get()
      Returns a copy of this PImage.
      int get​(int x, int y)
      ( begin auto-generated from PImage_get.xml ) Reads the color of any pixel or grabs a section of an image.
      PImage get​(int x, int y, int w, int h)  
      static String getExtension​(String filename)  
      PGraphics getGraphics()  
      PMatrix getMatrix()  
      PMatrix2D getMatrix​(PMatrix2D target)
      Copy the current transformation matrix into the specified target.
      PMatrix3D getMatrix​(PMatrix3D target)
      Copy the current transformation matrix into the specified target.
      PSurface getSurface()  
      float green​(int rgb)
      ( begin auto-generated from green.xml ) Extracts the green value from a color, scaled to match current colorMode().
      void handleDraw()  
      protected void handleKeyEvent​(KeyEvent event)  
      protected void handleMethods​(String methodName)  
      protected void handleMethods​(String methodName, Object[] args)  
      protected void handleMouseEvent​(MouseEvent event)
      Actually take action based on a mouse event.
      static String hex​(byte value)
      ( begin auto-generated from hex.xml ) Converts a byte, char, int, or color to a String containing the equivalent hexadecimal notation.
      static String hex​(char value)  
      static String hex​(int value)  
      static String hex​(int value, int digits)  
      static void hideMenuBar()  
      void hint​(int which)  
      static int hour()
      ( begin auto-generated from hour.xml ) Processing communicates with the clock on your computer.
      float hue​(int rgb)
      ( begin auto-generated from hue.xml ) Extracts the hue value from a color.
      void image​(PImage img, float a, float b)
      ( begin auto-generated from image.xml ) Displays images to the screen.
      void image​(PImage img, float a, float b, float c, float d)  
      void image​(PImage img, float a, float b, float c, float d, int u1, int v1, int u2, int v2)
      Draw an image(), also specifying u/v coordinates.
      void imageMode​(int mode)
      ( begin auto-generated from imageMode.xml ) Modifies the location from which images draw.
      protected PSurface initSurface()  
      String insertFrame​(String what)
      Check a string for #### signs to see if the frame number should be inserted.
      boolean isLooping()  
      static String join​(String[] list, char separator)
      ( begin auto-generated from join.xml ) Combines an array of Strings into one String, each separated by the character(s) used for the separator parameter.
      static String join​(String[] list, String separator)  
      void keyPressed()
      ( begin auto-generated from keyPressed.xml ) The keyPressed() function is called once every time a key is pressed.
      void keyPressed​(KeyEvent event)  
      void keyReleased()
      ( begin auto-generated from keyReleased.xml ) The keyReleased() function is called once every time a key is released.
      void keyReleased​(KeyEvent event)  
      void keyTyped()
      ( begin auto-generated from keyTyped.xml ) The keyTyped() function is called once every time a key is pressed, but action keys such as Ctrl, Shift, and Alt are ignored.
      void keyTyped​(KeyEvent event)  
      static Process launch​(String... args)
      ( begin auto-generated from launch.xml ) Attempts to open an application or file using your platform's launcher.
      static float lerp​(float start, float stop, float amt)
      ( begin auto-generated from lerp.xml ) Calculates a number between two numbers at a specific increment.
      int lerpColor​(int c1, int c2, float amt)
      ( begin auto-generated from lerpColor.xml ) Calculates a color or colors between two color at a specific increment.
      static int lerpColor​(int c1, int c2, float amt, int mode)  
      void lightFalloff​(float constant, float linear, float quadratic)
      ( begin auto-generated from lightFalloff.xml ) Sets the falloff rates for point lights, spot lights, and ambient lights.
      void lights()
      ( begin auto-generated from lights.xml ) Sets the default ambient light, directional light, falloff, and specular values.
      void lightSpecular​(float v1, float v2, float v3)
      ( begin auto-generated from lightSpecular.xml ) Sets the specular color for lights.
      void line​(float x1, float y1, float x2, float y2)
      ( begin auto-generated from line.xml ) Draws a line (a direct path between two points) to the screen.
      void line​(float x1, float y1, float z1, float x2, float y2, float z2)  
      void link​(String url)
      Links to a webpage either in the same window or in a new window.
      static File[] listFiles​(File base, String... options)  
      File[] listFiles​(String path, String... options)  
      String[] listPaths​(String path, String... options)  
      static byte[] loadBytes​(File file)  
      static byte[] loadBytes​(InputStream input)  
      byte[] loadBytes​(String filename)
      ( begin auto-generated from loadBytes.xml ) Reads the contents of a file or url and places it in a byte array.
      PFont loadFont​(String filename)
      ( begin auto-generated from loadFont.xml ) Loads a font into a variable of type PFont.
      PImage loadImage​(String filename)
      ( begin auto-generated from loadImage.xml ) Loads an image into a variable of type PImage.
      PImage loadImage​(String filename, String extension)  
      protected PImage loadImageIO​(String filename)
      Use Java 1.4 ImageIO methods to load an image.
      protected PImage loadImageTGA​(String filename)
      Targa image loader for RLE-compressed TGA files.
      static JSONArray loadJSONArray​(File file)  
      JSONArray loadJSONArray​(String filename)  
      static JSONObject loadJSONObject​(File file)  
      JSONObject loadJSONObject​(String filename)  
      void loadPixels()
      ( begin auto-generated from loadPixels.xml ) Loads the pixel data for the display window into the pixels[] array.
      PShader loadShader​(String fragFilename)
      ( begin auto-generated from loadShader.xml ) This is a new reference entry for Processing 2.0.
      PShader loadShader​(String fragFilename, String vertFilename)  
      PShape loadShape​(String filename)  
      PShape loadShape​(String filename, String options)  
      static String[] loadStrings​(BufferedReader reader)  
      static String[] loadStrings​(File file)  
      static String[] loadStrings​(InputStream input)  
      String[] loadStrings​(String filename)
      ( begin auto-generated from loadStrings.xml ) Reads the contents of a file or url and creates a String array of its individual lines.
      Table loadTable​(String filename)  
      Table loadTable​(String filename, String options)
      Options may contain "header", "tsv", "csv", or "bin" separated by commas.
      XML loadXML​(String filename)  
      XML loadXML​(String filename, String options)  
      static float log​(float n)
      ( begin auto-generated from log.xml ) Calculates the natural logarithm (the base-e logarithm) of a number.
      void loop()
      ( begin auto-generated from loop.xml ) Causes Processing to continuously execute the code within draw().
      static float mag​(float a, float b)  
      static float mag​(float a, float b, float c)
      ( begin auto-generated from mag.xml ) Calculates the magnitude (or length) of a vector.
      static void main​(Class<?> mainClass, String... args)
      Convenience method so that PApplet.main(YourSketch.class) launches a sketch, rather than having to call getName() on it.
      static void main​(String mainClass)
      Convenience method so that PApplet.main("YourSketch") launches a sketch, rather than having to wrap it into a single element String array.
      static void main​(String[] args)
      main() method for running this class from the command line.
      static void main​(String mainClass, String[] sketchArgs)
      Convenience method so that PApplet.main("YourSketch", args) launches a sketch, rather than having to wrap it into a String array, and appending the 'args' array when not null.
      static void main​(PApplet sketch, String... sketchArgs)
      Run the provided sketch.
      static PApplet.MainThreadContext mainThread()
      Access the main thread context.
      protected PGraphics makeGraphics​(int w, int h, String renderer, String path, boolean primary)
      Version of createGraphics() used internally.
      static float map​(float value, float start1, float stop1, float start2, float stop2)
      ( begin auto-generated from map.xml ) Re-maps a number from one range to another.
      void mask​(PImage img)
      ( begin auto-generated from PImage_mask.xml ) Masks part of an image from displaying by loading another image and using it as an alpha channel.
      static String[] match​(String str, String regexp)
      ( begin auto-generated from match.xml ) The match() function is used to apply a regular expression to a piece of text, and return matching groups (elements found inside parentheses) as a String array.
      static String[][] matchAll​(String str, String regexp)
      ( begin auto-generated from matchAll.xml ) This function is used to apply a regular expression to a piece of text, and return a list of matching groups (elements found inside parentheses) as a two-dimensional String array.
      static float max​(float[] list)  
      static float max​(float a, float b)  
      static float max​(float a, float b, float c)  
      static int max​(int[] list)  
      static int max​(int a, int b)
      ( begin auto-generated from max.xml ) Determines the largest value in a sequence of numbers.
      static int max​(int a, int b, int c)  
      void method​(String name)
      Call a method in the current class based on its name.
      int millis()
      ( begin auto-generated from millis.xml ) Returns the number of milliseconds (thousandths of a second) since starting an applet.
      static float min​(float[] list)  
      static float min​(float a, float b)  
      static float min​(float a, float b, float c)
      ( begin auto-generated from min.xml ) Determines the smallest value in a sequence of numbers.
      static int min​(int[] list)  
      static int min​(int a, int b)  
      static int min​(int a, int b, int c)  
      static int minute()
      ( begin auto-generated from minute.xml ) Processing communicates with the clock on your computer.
      float modelX​(float x, float y, float z)
      ( begin auto-generated from modelX.xml ) Returns the three-dimensional X, Y, Z position in model space.
      float modelY​(float x, float y, float z)
      ( begin auto-generated from modelY.xml ) Returns the three-dimensional X, Y, Z position in model space.
      float modelZ​(float x, float y, float z)
      ( begin auto-generated from modelZ.xml ) Returns the three-dimensional X, Y, Z position in model space.
      static int month()
      ( begin auto-generated from month.xml ) Processing communicates with the clock on your computer.
      void mouseClicked()
      ( begin auto-generated from mouseClicked.xml ) The mouseClicked() function is called once after a mouse button has been pressed and then released.
      void mouseClicked​(MouseEvent event)  
      void mouseDragged()
      ( begin auto-generated from mouseDragged.xml ) The mouseDragged() function is called once every time the mouse moves and a mouse button is pressed.
      void mouseDragged​(MouseEvent event)  
      void mouseEntered()  
      void mouseEntered​(MouseEvent event)  
      void mouseExited()  
      void mouseExited​(MouseEvent event)  
      void mouseMoved()
      ( begin auto-generated from mouseMoved.xml ) The mouseMoved() function is called every time the mouse moves and a mouse button is not pressed.
      void mouseMoved​(MouseEvent event)  
      void mousePressed()
      ( begin auto-generated from mousePressed.xml ) The mousePressed() function is called once after every time a mouse button is pressed.
      void mousePressed​(MouseEvent event)  
      void mouseReleased()
      ( begin auto-generated from mouseReleased.xml ) The mouseReleased() function is called every time a mouse button is released.
      void mouseReleased​(MouseEvent event)  
      void mouseWheel()  
      void mouseWheel​(MouseEvent event)
      The event.getAmount() method returns negative values if the mouse wheel if rotated up or away from the user and positive in the other direction.
      static String nf​(float num)  
      static String[] nf​(float[] nums)  
      static String[] nf​(float[] nums, int left, int right)  
      static String nf​(float num, int left, int right)  
      static String[] nf​(int[] nums, int digits)
      ( begin auto-generated from nf.xml ) Utility function for formatting numbers into strings.
      static String nf​(int num, int digits)  
      static String[] nfc​(float[] nums, int right)  
      static String nfc​(float num, int right)  
      static String nfc​(int num)  
      static String[] nfc​(int[] nums)
      ( begin auto-generated from nfc.xml ) Utility function for formatting numbers into strings and placing appropriate commas to mark units of 1000.
      static String[] nfp​(float[] nums, int left, int right)  
      static String nfp​(float num, int left, int right)  
      static String[] nfp​(int[] nums, int digits)  
      static String nfp​(int num, int digits)
      ( begin auto-generated from nfp.xml ) Utility function for formatting numbers into strings.
      static String[] nfs​(float[] nums, int left, int right)  
      static String nfs​(float num, int left, int right)  
      static String[] nfs​(int[] nums, int digits)  
      static String nfs​(int num, int digits)
      ( begin auto-generated from nfs.xml ) Utility function for formatting numbers into strings.
      void noClip()
      ( begin auto-generated from noClip.xml ) Disables the clipping previously started by the clip() function.
      void noCursor()
      ( begin auto-generated from noCursor.xml ) Hides the cursor from view.
      void noFill()
      ( begin auto-generated from noFill.xml ) Disables filling geometry.
      float noise​(float x)  
      float noise​(float x, float y)  
      float noise​(float x, float y, float z)
      ( begin auto-generated from noise.xml ) Returns the Perlin noise value at specified coordinates.
      void noiseDetail​(int lod)
      ( begin auto-generated from noiseDetail.xml ) Adjusts the character and level of detail produced by the Perlin noise function.
      void noiseDetail​(int lod, float falloff)  
      void noiseSeed​(long seed)
      ( begin auto-generated from noiseSeed.xml ) Sets the seed value for noise().
      void noLights()
      ( begin auto-generated from noLights.xml ) Disable all lighting.
      void noLoop()
      ( begin auto-generated from noLoop.xml ) Stops Processing from continuously executing the code within draw().
      static float norm​(float value, float start, float stop)
      ( begin auto-generated from norm.xml ) Normalizes a number from another range into a value between 0 and 1.
      void normal​(float nx, float ny, float nz)
      ( begin auto-generated from normal.xml ) Sets the current normal vector.
      void noSmooth()  
      void noStroke()
      ( begin auto-generated from noStroke.xml ) Disables drawing the stroke (outline).
      void noTexture()
      Removes texture image for current shape.
      void noTint()
      ( begin auto-generated from noTint.xml ) Removes the current fill value for displaying images and reverts to displaying images with their original hues.
      void orientation​(int which)  
      void ortho()
      ( begin auto-generated from ortho.xml ) Sets an orthographic projection and defines a parallel clipping volume.
      void ortho​(float left, float right, float bottom, float top)  
      void ortho​(float left, float right, float bottom, float top, float near, float far)  
      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​(String what)
      Convert the string "true" or "false" to a boolean.
      static boolean[] parseBoolean​(String[] what)  
      static byte parseByte​(boolean what)  
      static byte[] parseByte​(boolean[] 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​(byte[] what)  
      static float parseFloat​(int what)
      Convert an int to a float value.
      static float[] parseFloat​(int[] what)  
      static float parseFloat​(String what)  
      static float[] parseFloat​(String[] what)  
      static float[] parseFloat​(String[] what, float missing)  
      static float parseFloat​(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​(String what)
      Parse a String into an int value.
      static int[] parseInt​(String[] what)
      Make an array of int elements from an array of String objects.
      static int[] parseInt​(String[] what, int missing)
      Make an array of int elements from an array of String objects.
      static int parseInt​(String what, int otherwise)
      Parse a String to an int, and provide an alternate value that should be used when the number is invalid.
      JSONArray parseJSONArray​(String input)  
      JSONObject parseJSONObject​(String input)  
      XML parseXML​(String xmlString)  
      XML parseXML​(String xmlString, String options)  
      void pause()
      Sketch has been paused.
      void perspective()
      ( begin auto-generated from perspective.xml ) Sets a perspective projection applying foreshortening, making distant objects appear smaller than closer ones.
      void perspective​(float fovy, float aspect, float zNear, float zFar)  
      void pixelDensity​(int density)  
      void point​(float x, float y)
      ( begin auto-generated from point.xml ) Draws a point, a coordinate in space at the dimension of one pixel.
      void point​(float x, float y, float z)  
      void pointLight​(float v1, float v2, float v3, float x, float y, float z)
      ( begin auto-generated from pointLight.xml ) Adds a point light.
      void pop()
      ( begin auto-generated from pop.xml ) The pop() function restores the previous drawing style settings and transformations after push() has changed them.
      void popMatrix()
      ( begin auto-generated from popMatrix.xml ) Pops the current transformation matrix off the matrix stack.
      void popStyle()
      ( begin auto-generated from popStyle.xml ) The pushStyle() function saves the current style settings and popStyle() restores the prior settings; these functions are always used together.
      void postEvent​(Event pe)
      Add an event to the internal event queue, or process it immediately if the sketch is not currently looping.
      static float pow​(float n, float e)
      ( begin auto-generated from pow.xml ) Facilitates exponential expressions.
      static void print​(boolean what)  
      static void print​(byte what)
      ( begin auto-generated from print.xml ) Writes to the console area of the Processing environment.
      static void print​(char what)  
      static void print​(double what)  
      static void print​(float what)  
      static void print​(int what)  
      static void print​(long what)  
      static void print​(Object... variables)  
      static void print​(String what)  
      static void printArray​(Object what)
      ( begin auto-generated from printArray.xml ) To come...
      void printCamera()
      ( begin auto-generated from printCamera.xml ) Prints the current camera matrix to the Console (the text window at the bottom of Processing).
      static void println()
      ( begin auto-generated from println.xml ) Writes to the text area of the Processing environment's console.
      static void println​(boolean what)  
      static void println​(byte what)  
      static void println​(char what)  
      static void println​(double what)  
      static void println​(float what)  
      static void println​(int what)  
      static void println​(long what)  
      static void println​(Object what)
      For arrays, use printArray() instead.
      static void println​(Object... variables)  
      static void println​(String what)  
      void printMatrix()
      ( begin auto-generated from printMatrix.xml ) Prints the current matrix to the Console (the text window at the bottom of Processing).
      void printProjection()
      ( begin auto-generated from printProjection.xml ) Prints the current projection matrix to the Console (the text window at the bottom of Processing).
      protected void printStackTrace​(Throwable t)
      Better way of handling e.printStackTrace() calls so that they can be handled by subclasses as necessary.
      void push()
      ( begin auto-generated from push.xml ) The push() function saves the current drawing style settings and transformations, while pop() restores these settings.
      void pushMatrix()
      ( begin auto-generated from pushMatrix.xml ) Pushes the current transformation matrix onto the matrix stack.
      void pushStyle()
      ( begin auto-generated from pushStyle.xml ) The pushStyle() function saves the current style settings and popStyle() restores the prior settings.
      void quad​(float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4)
      ( begin auto-generated from quad.xml ) A quad is a quadrilateral, a four sided polygon.
      void quadraticVertex​(float cx, float cy, float x3, float y3)  
      void quadraticVertex​(float cx, float cy, float cz, float x3, float y3, float z3)  
      static float radians​(float degrees)
      ( begin auto-generated from radians.xml ) Converts a degree measurement to its corresponding value in radians.
      float random​(float high)  
      float random​(float low, float high)
      ( begin auto-generated from random.xml ) Generates random numbers.
      float randomGaussian()
      ( begin auto-generated from randomGaussian.xml ) Returns a float from a random series of numbers having a mean of 0 and standard deviation of 1.
      void randomSeed​(long seed)
      ( begin auto-generated from randomSeed.xml ) Sets the seed value for random().
      void rect​(float a, float b, float c, float d)
      ( begin auto-generated from rect.xml ) Draws a rectangle to the screen.
      void rect​(float a, float b, float c, float d, float r)  
      void rect​(float a, float b, float c, float d, float tl, float tr, float br, float bl)  
      void rectMode​(int mode)
      ( begin auto-generated from rectMode.xml ) Modifies the location from which rectangles draw.
      float red​(int rgb)
      ( begin auto-generated from red.xml ) Extracts the red value from a color, scaled to match current colorMode().
      void redraw()
      ( begin auto-generated from redraw.xml ) Executes the code within draw() one time.
      void registerMethod​(String methodName, Object target)
      Register a built-in event so that it can be fired for libraries, etc.
      PImage requestImage​(String filename)  
      PImage requestImage​(String filename, String extension)
      ( begin auto-generated from requestImage.xml ) This function load images on a separate thread so that your sketch does not freeze while images load during setup().
      void resetMatrix()
      ( begin auto-generated from resetMatrix.xml ) Replaces the current matrix with the identity matrix.
      void resetShader()
      ( begin auto-generated from resetShader.xml ) This is a new reference entry for Processing 2.0.
      void resetShader​(int kind)  
      void resume()
      Sketch has resumed.
      static boolean[] reverse​(boolean[] list)
      ( begin auto-generated from reverse.xml ) Reverses the order of an array.
      static byte[] reverse​(byte[] list)  
      static char[] reverse​(char[] list)  
      static float[] reverse​(float[] list)  
      static int[] reverse​(int[] list)  
      static Object reverse​(Object list)  
      static String[] reverse​(String[] list)  
      void rotate​(float angle)
      ( begin auto-generated from rotate.xml ) Rotates a shape the amount specified by the angle parameter.
      void rotate​(float angle, float x, float y, float z)
      Advanced
      void rotateX​(float angle)
      ( begin auto-generated from rotateX.xml ) Rotates a shape around the x-axis the amount specified by the angle parameter.
      void rotateY​(float angle)
      ( begin auto-generated from rotateY.xml ) Rotates a shape around the y-axis the amount specified by the angle parameter.
      void rotateZ​(float angle)
      ( begin auto-generated from rotateZ.xml ) Rotates a shape around the z-axis the amount specified by the angle parameter.
      static int round​(float n)
      ( begin auto-generated from round.xml ) Calculates the integer closest to the value parameter.
      protected void runSketch()
      Convenience method for Python Mode
      protected void runSketch​(String[] args)
      Convenience method for Python Mode to run an already-constructed sketch.
      static void runSketch​(String[] args, PApplet constructedSketch)  
      float saturation​(int rgb)
      ( begin auto-generated from saturation.xml ) Extracts the saturation value from a color.
      void save​(String filename)
      ( begin auto-generated from save.xml ) Saves an image from the display window.
      static void saveBytes​(File file, byte[] data)  
      static void saveBytes​(OutputStream output, byte[] data)  
      void saveBytes​(String filename, byte[] data)
      ( begin auto-generated from saveBytes.xml ) Opposite of loadBytes(), will write an entire array of bytes to a file.
      File saveFile​(String where)
      Identical to savePath(), but returns a File object.
      void saveFrame()  
      void saveFrame​(String filename)
      ( begin auto-generated from saveFrame.xml ) Saves a numbered sequence of images, one image each time the function is run.
      boolean saveJSONArray​(JSONArray json, String filename)  
      boolean saveJSONArray​(JSONArray json, String filename, String options)  
      boolean saveJSONObject​(JSONObject json, String filename)  
      boolean saveJSONObject​(JSONObject json, String filename, String options)  
      String savePath​(String where)
      Returns a path inside the applet folder to save to.
      static boolean saveStream​(File target, InputStream source)  
      boolean saveStream​(File target, String source)
      Identical to the other saveStream(), but writes to a File object, for greater control over the file location.
      static void saveStream​(OutputStream target, InputStream source)  
      boolean saveStream​(String target, InputStream source)  
      boolean saveStream​(String target, String source)
      ( begin auto-generated from saveStream.xml ) Save the contents of a stream to a file in the sketch folder.
      static void saveStrings​(File file, String[] data)  
      static void saveStrings​(OutputStream output, String[] data)  
      void saveStrings​(String filename, String[] data)
      ( begin auto-generated from saveStrings.xml ) Writes an array of strings to a file, one line per string.
      boolean saveTable​(Table table, String filename)  
      boolean saveTable​(Table table, String filename, String options)  
      boolean saveXML​(XML xml, String filename)  
      boolean saveXML​(XML xml, String filename, String options)  
      void scale​(float s)
      ( begin auto-generated from scale.xml ) Increases or decreases the size of a shape by expanding and contracting vertices.
      void scale​(float x, float y)
      Advanced
      void scale​(float x, float y, float z)  
      float screenX​(float x, float y)
      ( begin auto-generated from screenX.xml ) Takes a three-dimensional X, Y, Z position and returns the X value for where it will appear on a (two-dimensional) screen.
      float screenX​(float x, float y, float z)  
      float screenY​(float x, float y)
      ( begin auto-generated from screenY.xml ) Takes a three-dimensional X, Y, Z position and returns the Y value for where it will appear on a (two-dimensional) screen.
      float screenY​(float x, float y, float z)  
      float screenZ​(float x, float y, float z)
      ( begin auto-generated from screenZ.xml ) Takes a three-dimensional X, Y, Z position and returns the Z value for where it will appear on a (two-dimensional) screen.
      static int second()
      ( begin auto-generated from second.xml ) Processing communicates with the clock on your computer.
      void selectFolder​(String prompt, String callback)
      See selectInput() for details.
      void selectFolder​(String prompt, String callback, File file)  
      void selectFolder​(String prompt, String callback, File file, Object callbackObject)  
      static void selectFolder​(String prompt, String callbackMethod, File defaultSelection, Object callbackObject, Frame parentFrame)  
      static void selectFolder​(String prompt, String callbackMethod, File defaultSelection, Object callbackObject, Frame parentFrame, PApplet sketch)  
      protected static void selectImpl​(String prompt, String callbackMethod, File defaultSelection, Object callbackObject, Frame parentFrame, int mode, PApplet sketch)  
      void selectInput​(String prompt, String callback)
      Open a platform-specific file chooser dialog to select a file for input.
      void selectInput​(String prompt, String callback, File file)  
      void selectInput​(String prompt, String callback, File file, Object callbackObject)  
      static void selectInput​(String prompt, String callbackMethod, File file, Object callbackObject, Frame parent)  
      static void selectInput​(String prompt, String callbackMethod, File file, Object callbackObject, Frame parent, PApplet sketch)  
      void selectOutput​(String prompt, String callback)
      See selectInput() for details.
      void selectOutput​(String prompt, String callback, File file)  
      void selectOutput​(String prompt, String callback, File file, Object callbackObject)  
      static void selectOutput​(String prompt, String callbackMethod, File file, Object callbackObject, Frame parent)  
      static void selectOutput​(String prompt, String callbackMethod, File file, Object callbackObject, Frame parent, PApplet sketch)  
      void set​(int x, int y, int c)
      ( begin auto-generated from PImage_set.xml ) Changes the color of any pixel or writes an image directly into the display window.

      The x and y parameters specify the pixel to change and the color parameter specifies the color value.
      void set​(int x, int y, PImage img)
      Advanced
      static void setMainThreadContext​(PApplet.MainThreadContext mainThread)
      Override the default main thread context for embedding the library in an application.
      void setMatrix​(PMatrix source)
      Set the current transformation matrix to the contents of another.
      void setMatrix​(PMatrix2D source)
      Set the current transformation to the contents of the specified source.
      void setMatrix​(PMatrix3D source)
      Set the current transformation to the contents of the specified source.
      void setSize​(int width, int height)
      Called by PSurface objects to set the width and height variables, and update the pixelWidth and pixelHeight variables.
      void settings()
      ( begin auto-generated from settings.xml ) Description to come...
      void setup()
      ( begin auto-generated from setup.xml ) The setup() function is called once when the program starts.
      void shader​(PShader shader)
      ( begin auto-generated from shader.xml ) This is a new reference entry for Processing 2.0.
      void shader​(PShader shader, int kind)  
      void shape​(PShape shape)  
      void shape​(PShape shape, float x, float y)
      ( begin auto-generated from shape.xml ) Displays shapes to the screen.
      void shape​(PShape shape, float a, float b, float c, float d)  
      void shapeMode​(int mode)
      ( begin auto-generated from shapeMode.xml ) Modifies the location from which shapes draw.
      void shearX​(float angle)
      ( begin auto-generated from shearX.xml ) Shears a shape around the x-axis the amount specified by the angle parameter.
      void shearY​(float angle)
      ( begin auto-generated from shearY.xml ) Shears a shape around the y-axis the amount specified by the angle parameter.
      static int shell​(StringList stdout, StringList stderr, String... args)
      Same as exec() above, but prefixes the call with a shell.
      void shininess​(float shine)
      ( begin auto-generated from shininess.xml ) Sets the amount of gloss in the surface of shapes.
      static boolean[] shorten​(boolean[] list)
      ( begin auto-generated from shorten.xml ) Decreases an array by one element and returns the shortened array.
      static byte[] shorten​(byte[] list)  
      static char[] shorten​(char[] list)  
      static float[] shorten​(float[] list)  
      static int[] shorten​(int[] list)  
      static Object shorten​(Object list)  
      static String[] shorten​(String[] list)  
      static void showDepthWarning​(String method)
      Display a warning that the specified method is only available with 3D.
      static void showDepthWarningXYZ​(String method)
      Display a warning that the specified method that takes x, y, z parameters can only be used with x and y parameters in this renderer.
      static void showMethodWarning​(String method)
      Display a warning that the specified method is simply unavailable.
      static void showMissingWarning​(String method)
      Display a warning that the specified method is not implemented, meaning that it could be either a completely missing function, although other variations of it may still work properly.
      protected void showSurface()
      Danger: available for advanced subclassing, but here be dragons.
      static void showVariationWarning​(String str)
      Error that a particular variation of a method is unavailable (even though other variations are).
      static float sin​(float angle)
      ( begin auto-generated from sin.xml ) Calculates the sine of an angle.
      void size​(int width, int height)
      ( begin auto-generated from size.xml ) Defines the dimension of the display window in units of pixels.
      void size​(int width, int height, String renderer)  
      void size​(int width, int height, String renderer, String path)  
      int sketchDisplay()  
      File sketchFile​(String where)  
      boolean sketchFullScreen()  
      int sketchHeight()  
      String sketchOutputPath()  
      OutputStream sketchOutputStream()  
      String sketchPath()  
      String sketchPath​(String where)
      Prepend the sketch folder path to the filename (or path) that is passed in.
      int sketchPixelDensity()  
      String sketchRenderer()  
      int sketchSmooth()  
      int sketchWidth()  
      int sketchWindowColor()  
      void smooth()  
      void smooth​(int level)  
      static byte[] sort​(byte[] list)
      ( begin auto-generated from sort.xml ) Sorts an array of numbers from smallest to largest and puts an array of words in alphabetical order.
      static byte[] sort​(byte[] list, int count)  
      static char[] sort​(char[] list)  
      static char[] sort​(char[] list, int count)  
      static float[] sort​(float[] list)  
      static float[] sort​(float[] list, int count)  
      static int[] sort​(int[] list)  
      static int[] sort​(int[] list, int count)  
      static String[] sort​(String[] list)  
      static String[] sort​(String[] list, int count)  
      void specular​(float gray)
      gray number specifying value between white and black
      void specular​(float v1, float v2, float v3)  
      void specular​(int rgb)
      ( begin auto-generated from specular.xml ) Sets the specular color of the materials used for shapes drawn to the screen, which sets the color of hightlights.
      void sphere​(float r)
      ( begin auto-generated from sphere.xml ) A sphere is a hollow ball made from tessellated triangles.
      void sphereDetail​(int res)
      ( begin auto-generated from sphereDetail.xml ) Controls the detail used to render a sphere by adjusting the number of vertices of the sphere mesh.
      void sphereDetail​(int ures, int vres)  
      static boolean[] splice​(boolean[] list, boolean[] value, int index)  
      static boolean[] splice​(boolean[] list, boolean value, int index)
      ( begin auto-generated from splice.xml ) Inserts a value or array of values into an existing array.
      static byte[] splice​(byte[] list, byte[] value, int index)  
      static byte[] splice​(byte[] list, byte value, int index)  
      static char[] splice​(char[] list, char[] value, int index)  
      static char[] splice​(char[] list, char value, int index)  
      static float[] splice​(float[] list, float[] value, int index)  
      static float[] splice​(float[] list, float value, int index)  
      static int[] splice​(int[] list, int[] value, int index)  
      static int[] splice​(int[] list, int value, int index)  
      static Object splice​(Object list, Object value, int index)  
      static String[] splice​(String[] list, String[] value, int index)  
      static String[] splice​(String[] list, String value, int index)  
      static String[] split​(String value, char delim)
      ( begin auto-generated from split.xml ) The split() function breaks a string into pieces using a character or string as the divider.
      static String[] split​(String value, String delim)  
      static String[] splitTokens​(String value)  
      static String[] splitTokens​(String value, String delim)
      ( begin auto-generated from splitTokens.xml ) The splitTokens() function splits a String at one or many character "tokens." The tokens parameter specifies the character or characters to be used as a boundary.
      void spotLight​(float v1, float v2, float v3, float x, float y, float z, float nx, float ny, float nz, float angle, float concentration)
      ( begin auto-generated from spotLight.xml ) Adds a spot light.
      static float sq​(float n)
      ( begin auto-generated from sq.xml ) Squares a number (multiplies a number by itself).
      static float sqrt​(float n)
      ( begin auto-generated from sqrt.xml ) Calculates the square root of a number.
      void square​(float x, float y, float extent)
      ( begin auto-generated from square.xml ) Draws a square to the screen.
      void start()
      Called by the browser or applet viewer to inform this applet that it should start its execution.
      protected void startSurface()
      See warning in showSurface()
      void stop()
      Called by the browser or applet viewer to inform this applet that it should stop its execution.
      static String str​(boolean x)  
      static String[] str​(boolean[] x)  
      static String str​(byte x)  
      static String[] str​(byte[] x)  
      static String str​(char x)  
      static String[] str​(char[] x)  
      static String str​(float x)  
      static String[] str​(float[] x)  
      static String str​(int x)  
      static String[] str​(int[] x)  
      void stroke​(float gray)  
      void stroke​(float gray, float alpha)  
      void stroke​(float v1, float v2, float v3)  
      void stroke​(float v1, float v2, float v3, float alpha)  
      void stroke​(int rgb)
      ( begin auto-generated from stroke.xml ) Sets the color used to draw lines and borders around shapes.
      void stroke​(int rgb, float alpha)  
      void strokeCap​(int cap)
      ( begin auto-generated from strokeCap.xml ) Sets the style for rendering line endings.
      void strokeJoin​(int join)
      ( begin auto-generated from strokeJoin.xml ) Sets the style of the joints which connect line segments.
      void strokeWeight​(float weight)
      ( begin auto-generated from strokeWeight.xml ) Sets the width of the stroke used for lines, points, and the border around shapes.
      void style​(PStyle s)  
      static boolean[] subset​(boolean[] list, int start)  
      static boolean[] subset​(boolean[] list, int start, int count)
      ( begin auto-generated from subset.xml ) Extracts an array of elements from an existing array.
      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 double[] subset​(double[] list, int start)  
      static double[] subset​(double[] 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 long[] subset​(long[] list, int start)  
      static long[] subset​(long[] list, int start, int count)  
      static Object subset​(Object list, int start)  
      static Object subset​(Object list, int start, int count)  
      static String[] subset​(String[] list, int start)  
      static String[] subset​(String[] list, int start, int count)  
      static float tan​(float angle)
      ( begin auto-generated from tan.xml ) Calculates the ratio of the sine and cosine of an angle.
      void text​(char[] chars, int start, int stop, float x, float y)
      Advanced
      void text​(char[] chars, int start, int stop, float x, float y, float z)  
      void text​(char c, float x, float y)
      ( begin auto-generated from text.xml ) Draws text to the screen.
      void text​(char c, float x, float y, float z)  
      void text​(float num, float x, float y)
      This does a basic number formatting, to avoid the generally ugly appearance of printing floats.
      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​(String str, float x, float y)
      Advanced
      void text​(String str, float x, float y, float z)
      Same as above but with a z coordinate.
      void text​(String str, float x1, float y1, float x2, float y2)
      Advanced
      void textAlign​(int alignX)  
      void textAlign​(int alignX, int alignY)
      ( begin auto-generated from textAlign.xml ) Sets the current alignment for drawing text.
      float textAscent()
      ( begin auto-generated from textAscent.xml ) Returns ascent of the current font at its current size.
      float textDescent()
      ( begin auto-generated from textDescent.xml ) Returns descent of the current font at its current size.
      void textFont​(PFont which)
      ( begin auto-generated from textFont.xml ) Sets the current font that will be drawn with the text() function.
      void textFont​(PFont which, float size)  
      void textLeading​(float leading)
      ( begin auto-generated from textLeading.xml ) Sets the spacing between lines of text in units of pixels.
      void textMode​(int mode)
      ( begin auto-generated from textMode.xml ) Sets the way text draws to the screen.
      void textSize​(float size)
      ( begin auto-generated from textSize.xml ) Sets the current font size.
      void texture​(PImage image)
      ( begin auto-generated from texture.xml ) Sets a texture to be applied to vertex points.
      void textureMode​(int mode)
      ( begin auto-generated from textureMode.xml ) Sets the coordinate space for texture mapping.
      void textureWrap​(int wrap)
      ( begin auto-generated from textureWrap.xml ) Description to come...
      float textWidth​(char c)  
      float textWidth​(char[] chars, int start, int length)  
      float textWidth​(String str)
      ( begin auto-generated from textWidth.xml ) Calculates and returns the width of any character or text string.
      void thread​(String name)
      Launch a new thread and call the specified function from that new thread.
      void tint​(float gray)  
      void tint​(float gray, float alpha)  
      void tint​(float v1, float v2, float v3)  
      void tint​(float v1, float v2, float v3, float alpha)  
      void tint​(int rgb)
      ( begin auto-generated from tint.xml ) Sets the fill value for displaying images.
      void tint​(int rgb, float alpha)  
      void translate​(float x, float y)
      ( begin auto-generated from translate.xml ) Specifies an amount to displace objects within the display window.
      void translate​(float x, float y, float z)  
      void triangle​(float x1, float y1, float x2, float y2, float x3, float y3)
      ( begin auto-generated from triangle.xml ) A triangle is a plane created by connecting three points.
      static String trim​(String str)
      ( begin auto-generated from trim.xml ) Removes whitespace characters from the beginning and end of a String.
      static String[] trim​(String[] array)  
      static int unbinary​(String value)
      ( begin auto-generated from unbinary.xml ) Converts a String representation of a binary number to its equivalent integer value.
      static int unhex​(String value)
      ( begin auto-generated from unhex.xml ) Converts a String representation of a hexadecimal number to its equivalent integer value.
      void unregisterMethod​(String name, Object target)  
      void updatePixels()
      ( begin auto-generated from updatePixels.xml ) Updates the display window with the data in the pixels[] array.
      void updatePixels​(int x1, int y1, int x2, int y2)  
      static String urlDecode​(String str)  
      static String urlEncode​(String str)  
      void vertex​(float[] v)
      Used by renderer subclasses or PShape to efficiently pass in already formatted vertex information.
      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)
      ( begin auto-generated from vertex.xml ) All shapes are constructed by connecting a series of vertices.
      static int year()
      ( begin auto-generated from year.xml ) Processing communicates with the clock on your computer.
    • Field Detail

      • javaVersionName

        public static final String javaVersionName
        Full name of the Java version (i.e. 1.5.0_11).
      • javaPlatform

        public static final int javaPlatform
      • javaVersion

        @Deprecated
        public static final float javaVersion
        Deprecated.
        Do not use; javaPlatform or javaVersionName are better options. For instance, javaPlatform is useful when you need a number for comparison, i.e. "if (javaPlatform >= 9)".
      • platform

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

        public static boolean useNativeSelect
        Whether to use native (AWT) dialogs for selectInput and selectOutput. The native dialogs on some platforms can be ugly, buggy, or missing features. For 3.3.5, this defaults to true on all platforms.
      • g

        public PGraphics g
        The PGraphics renderer associated with this PApplet
      • displayWidth

        public int displayWidth
        ( begin auto-generated from displayWidth.xml ) System variable which stores the width of the computer screen. For example, if the current screen resolution is 1024x768, displayWidth is 1024 and displayHeight is 768. These dimensions are useful when exporting full-screen applications.

        To ensure that the sketch takes over the entire screen, use "Present" instead of "Run". Otherwise the window will still have a frame border around it and not be placed in the upper corner of the screen. On Mac OS X, the menu bar will remain present unless "Present" mode is used. ( end auto-generated )
      • displayHeight

        public int displayHeight
        ( begin auto-generated from displayHeight.xml ) System variable that stores the height of the computer screen. For example, if the current screen resolution is 1024x768, displayWidth is 1024 and displayHeight is 768. These dimensions are useful when exporting full-screen applications.

        To ensure that the sketch takes over the entire screen, use "Present" instead of "Run". Otherwise the window will still have a frame border around it and not be placed in the upper corner of the screen. On Mac OS X, the menu bar will remain present unless "Present" mode is used. ( end auto-generated )
      • recorder

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

        public String[] args
        Command line options passed in from main(). This does not include the arguments passed in to PApplet itself.
        See Also:
        main(java.lang.String[])
      • DEFAULT_WIDTH

        public static final int DEFAULT_WIDTH
        Default width and height for sketch when not specified
        See Also:
        Constant Field Values
      • pixels

        public int[] pixels
        ( begin auto-generated from pixels.xml ) Array containing the values for all the pixels in the display window. These values are of the color datatype. This array is the size of the display window. For example, if the image is 100x100 pixels, there will be 10000 values and if the window is 200x300 pixels, there will be 60000 values. The index value defines the position of a value within the array. For example, the statement color b = pixels[230] will set the variable b to be equal to the value at that location in the array.

        Before accessing this array, the data must loaded with the loadPixels() function. After the array data has been modified, the updatePixels() function must be run to update the changes. Without loadPixels(), running the code may (or will in future releases) result in a NullPointerException. ( end auto-generated )
        See Also:
        loadPixels(), updatePixels(), get(int, int, int, int), set(int, int, int), PImage
      • width

        public int width
        ( begin auto-generated from width.xml ) System variable which stores the width of the display window. This value is set by the first parameter of the size() function. For example, the function call size(320, 240) sets the width variable to the value 320. The value of width is zero until size() is called. ( end auto-generated )
        See Also:
        height, size(int, int)
      • height

        public int height
        ( begin auto-generated from height.xml ) System variable which stores the height of the display window. This value is set by the second parameter of the size() function. For example, the function call size(320, 240) sets the height variable to the value 240. The value of height is zero until size() is called. ( end auto-generated )
        See Also:
        width, size(int, int)
      • pixelWidth

        public int pixelWidth
        ( begin auto-generated from pixelWidth.xml ) When pixelDensity(2) is used to make use of a high resolution display (called a Retina display on OS X or high-dpi on Windows and Linux), the width and height of the sketch do not change, but the number of pixels is doubled. As a result, all operations that use pixels (like loadPixels(), get(), set(), etc.) happen in this doubled space. As a convenience, the variables pixelWidth and pixelHeight hold the actual width and height of the sketch in pixels. This is useful for any sketch that uses the pixels[] array, for instance, because the number of elements in the array will be pixelWidth*pixelHeight, not width*height. ( end auto-generated )
        See Also:
        pixelHeight, pixelDensity(int), displayDensity()
      • pixelHeight

        public int pixelHeight
        ( begin auto-generated from pixelHeight.xml ) When pixelDensity(2) is used to make use of a high resolution display (called a Retina display on OS X or high-dpi on Windows and Linux), the width and height of the sketch do not change, but the number of pixels is doubled. As a result, all operations that use pixels (like loadPixels(), get(), set(), etc.) happen in this doubled space. As a convenience, the variables pixelWidth and pixelHeight hold the actual width and height of the sketch in pixels. This is useful for any sketch that uses the pixels[] array, for instance, because the number of elements in the array will be pixelWidth*pixelHeight, not width*height. ( end auto-generated )
        See Also:
        pixelWidth, pixelDensity(int), displayDensity()
      • keyRepeatEnabled

        protected boolean keyRepeatEnabled
        Keeps track of ENABLE_KEY_REPEAT hint
      • pmouseX

        public int pmouseX
        ( begin auto-generated from pmouseX.xml ) The system variable pmouseX always contains the horizontal position of the mouse in the frame previous to the current frame.

        You may find that pmouseX and pmouseY have different values inside draw() and inside events like mousePressed() and mouseMoved(). This is because they're used for different roles, so don't mix them. Inside draw(), pmouseX and pmouseY update only once per frame (once per trip through your draw()). But, inside mouse events, they update each time the event is called. If they weren't separated, then the mouse would be read only once per frame, making response choppy. If the mouse variables were always updated multiple times per frame, using line(pmouseX, pmouseY, mouseX, mouseY) inside draw() would have lots of gaps, because pmouseX may have changed several times in between the calls to line(). Use pmouseX and pmouseY inside draw() if you want values relative to the previous frame. Use pmouseX and pmouseY inside the mouse functions if you want continuous response. ( end auto-generated )
        See Also:
        mouseX, mouseY, pmouseY, mousePressed, mousePressed(), mouseReleased(), mouseClicked(), mouseMoved(), mouseDragged(), mouseButton, mouseWheel(MouseEvent)
      • dmouseX

        protected int dmouseX
        Previous mouseX/Y for the draw loop, separated out because this is separate from the pmouseX/Y when inside the mouse event handlers. See emouseX/Y for an explanation.
      • dmouseY

        protected int dmouseY
        Previous mouseX/Y for the draw loop, separated out because this is separate from the pmouseX/Y when inside the mouse event handlers. See emouseX/Y for an explanation.
      • emouseX

        protected int emouseX
        The pmouseX/Y for the event handlers (mousePressed(), mouseDragged() etc) these are different because mouse events are queued to the end of draw, so the previous position has to be updated on each event, as opposed to the pmouseX/Y that's used inside draw, which is expected to be updated once per trip through draw().
      • emouseY

        protected int emouseY
        The pmouseX/Y for the event handlers (mousePressed(), mouseDragged() etc) these are different because mouse events are queued to the end of draw, so the previous position has to be updated on each event, as opposed to the pmouseX/Y that's used inside draw, which is expected to be updated once per trip through draw().
      • firstMouse

        @Deprecated
        public boolean firstMouse
        Deprecated.
        Please refrain from using this variable, it will be removed from future releases of Processing because it cannot be used consistently across platforms and input methods.
        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.

      • mouseEvent

        @Deprecated
        public MouseEvent mouseEvent
        Deprecated.
        Use a mouse event handler that passes an event instead.
      • key

        public char key
        ( begin auto-generated from key.xml ) The system variable key always contains the value of the most recent key on the keyboard that was used (either pressed or released).

        For non-ASCII keys, use the keyCode variable. The keys included in the ASCII specification (BACKSPACE, TAB, ENTER, RETURN, ESC, and DELETE) do not require checking to see if they key is coded, and you should simply use the key variable instead of keyCode If you're making cross-platform projects, note that the ENTER key is commonly used on PCs and Unix and the RETURN key is used instead on Macintosh. Check for both ENTER and RETURN to make sure your program will work for all platforms. ( end auto-generated )

        Advanced

        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).

        See Also:
        keyCode, keyPressed, keyPressed(), keyReleased()
      • keyCode

        public int keyCode
        ( begin auto-generated from keyCode.xml ) The variable keyCode is used to detect special keys such as the UP, DOWN, LEFT, RIGHT arrow keys and ALT, CONTROL, SHIFT. When checking for these keys, it's first necessary to check and see if the key is coded. This is done with the conditional "if (key == CODED)" as shown in the example.

        The keys included in the ASCII specification (BACKSPACE, TAB, ENTER, RETURN, ESC, and DELETE) do not require checking to see if they key is coded, and you should simply use the key variable instead of keyCode If you're making cross-platform projects, note that the ENTER key is commonly used on PCs and Unix and the RETURN key is used instead on Macintosh. Check for both ENTER and RETURN to make sure your program will work for all platforms.

        For users familiar with Java, the values for UP and DOWN are simply shorter versions of Java's KeyEvent.VK_UP and KeyEvent.VK_DOWN. Other keyCode values can be found in the Java KeyEvent reference. ( end auto-generated )

        Advanced

        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.

        See Also:
        key, keyPressed, keyPressed(), keyReleased()
      • keyPressed

        public boolean keyPressed
        ( begin auto-generated from keyPressed_var.xml ) The boolean system variable keyPressed is true if any key is pressed and false if no keys are pressed. ( end auto-generated )
        See Also:
        key, keyCode, keyPressed(), keyReleased()
      • keyEvent

        @Deprecated
        public KeyEvent keyEvent
        Deprecated.
        Use a key event handler that passes an event instead.
        The last KeyEvent object passed into a mouse function.
      • focused

        public boolean focused
        ( begin auto-generated from focused.xml ) Confirms if a Processing program is "focused", meaning that it is active and will accept input from mouse or keyboard. This variable is "true" if it is focused and "false" if not. This variable is often used when you want to warn people they need to click on or roll over an applet before it will work. ( end auto-generated )
      • frameRate

        public float frameRate
        ( begin auto-generated from frameRate_var.xml ) The system variable frameRate contains the approximate frame rate of the software as it executes. The initial value is 10 fps and is updated with each frame. The value is averaged (integrated) over several frames. As such, this value won't be valid until after 5-10 frames. ( end auto-generated )
        See Also:
        frameRate(float), frameCount
      • looping

        protected boolean looping
      • redraw

        protected boolean redraw
        flag set to true when a redraw is asked for by the user
      • frameCount

        public int frameCount
        ( begin auto-generated from frameCount.xml ) The system variable frameCount contains the number of frames displayed since the program started. Inside setup() the value is 0 and and after the first iteration of draw it is 1, etc. ( end auto-generated )
        See Also:
        frameRate(float), frameRate
      • finished

        public volatile boolean finished
        true if the sketch has stopped permanently.
      • exitCalled

        protected boolean exitCalled
        true if exit() has been called so that things shut down once the main thread kicks off.
      • ARGS_EDITOR_LOCATION

        public static final String ARGS_EDITOR_LOCATION
        Position of the upper-lefthand corner of the editor window that launched this applet.
        See Also:
        Constant Field Values
      • ARGS_LOCATION

        public static final String ARGS_LOCATION
        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_DISPLAY

        public static final String ARGS_DISPLAY
        Used by the PDE to suggest a display (set in prefs, passed on Run)
        See Also:
        Constant Field Values
      • ARGS_SKETCH_FOLDER

        public static final 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 String EXTERNAL_STOP
        When run externally to a PdeEditor, this is sent by the sketch when it quits.
        See Also:
        Constant Field Values
      • EXTERNAL_MOVE

        public static final 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
      • pixelDensity

        public int pixelDensity
      • insideDraw

        protected boolean insideDraw
      • frameRateLastNanos

        protected long frameRateLastNanos
        Last time in nanoseconds that frameRate was checked
      • loadImageFormats

        protected String[] loadImageFormats
    • Constructor Detail

      • PApplet

        public PApplet()
    • Method Detail

      • getSurface

        public PSurface getSurface()
      • settings

        public void settings()
        ( begin auto-generated from settings.xml ) Description to come... ( end auto-generated ) Override this method to call size() when not using the PDE.
        See Also:
        fullScreen(), setup(), size(int,int), smooth()
      • sketchWidth

        public final int sketchWidth()
      • sketchHeight

        public final int sketchHeight()
      • sketchRenderer

        public final String sketchRenderer()
      • sketchSmooth

        public final int sketchSmooth()
      • sketchFullScreen

        public final boolean sketchFullScreen()
      • sketchDisplay

        public final int sketchDisplay()
      • sketchOutputPath

        public final String sketchOutputPath()
      • sketchOutputStream

        public final OutputStream sketchOutputStream()
      • sketchWindowColor

        public final int sketchWindowColor()
      • sketchPixelDensity

        public final int sketchPixelDensity()
      • displayDensity

        public int displayDensity()
        ( begin auto-generated from displayDensity.xml ) This function returns the number "2" if the screen is a high-density screen (called a Retina display on OS X or high-dpi on Windows and Linux) and a "1" if not. This information is useful for a program to adapt to run at double the pixel density on a screen that supports it. ( end auto-generated )
        See Also:
        pixelDensity(int), size(int,int)
      • displayDensity

        public int displayDensity​(int display)
        Parameters:
        display - the display number to check
      • pixelDensity

        public void pixelDensity​(int density)
        Parameters:
        density - 1 or 2
      • setSize

        public void setSize​(int width,
                            int height)
        Called by PSurface objects to set the width and height variables, and update the pixelWidth and pixelHeight variables.
      • smooth

        public void smooth()
      • smooth

        public void smooth​(int level)
        Parameters:
        level - either 2, 3, 4, or 8 depending on the renderer
      • noSmooth

        public void noSmooth()
      • getGraphics

        public PGraphics getGraphics()
      • orientation

        public void orientation​(int which)
      • 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.

      • 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.

      • pause

        public void pause()
        Sketch has been paused. Called when switching tabs in a browser or swapping to a different application on Android. Also called just before quitting. Use to safely disable things like serial, sound, or sensors.
      • resume

        public void resume()
        Sketch has resumed. Called when switching tabs in a browser or swapping to this application on Android. Also called on startup. Use this to safely disable things like serial, sound, or sensors.
      • registerMethod

        public void registerMethod​(String methodName,
                                   Object target)
        Register a built-in event so that it can be fired for libraries, etc. Supported events include:
        • pre – at the very top of the draw() method (safe to draw)
        • draw – at the end of the draw() method (safe to draw)
        • post – after draw() has exited (not safe to draw)
        • pause – called when the sketch is paused
        • resume – called when the sketch is resumed
        • dispose – when the sketch is shutting down (definitely not safe to draw)
            In addition, the new (for 2.0) processing.event classes are passed to the following event types:
            • mouseEvent
            • keyEvent
            • touchEvent
            The older java.awt events are no longer supported. See the Library Wiki page for more details.
        Parameters:
        methodName - name of the method to be called
        target - the target object that should receive the event
      • unregisterMethod

        public void unregisterMethod​(String name,
                                     Object target)
      • handleMethods

        protected void handleMethods​(String methodName)
      • handleMethods

        protected void handleMethods​(String methodName,
                                     Object[] args)
      • setup

        public void setup()
        ( begin auto-generated from setup.xml ) The setup() function is called once when the program starts. It's used to define initial enviroment properties such as screen size and background color and to load media such as images and fonts as the program starts. There can only be one setup() function for each program and it shouldn't be called again after its initial execution. Note: Variables declared within setup() are not accessible within other functions, including draw(). ( end auto-generated )
        See Also:
        size(int, int), loop(), noLoop(), draw()
      • draw

        public void draw()
        ( begin auto-generated from draw.xml ) Called directly after setup() and continuously executes the lines of code contained inside its block until the program is stopped or noLoop() is called. The draw() function is called automatically and should never be called explicitly. It should always be controlled with noLoop(), redraw() and loop(). After noLoop() stops the code in draw() from executing, redraw() causes the code inside draw() to execute once and loop() will causes the code inside draw() to execute continuously again. The number of times draw() executes in each second may be controlled with frameRate() function. There can only be one draw() function for each sketch and draw() must exist if you want the code to run continuously or to process events such as mousePressed(). Sometimes, you might have an empty call to draw() in your program as shown in the above example. ( end auto-generated )
        See Also:
        setup(), loop(), noLoop(), redraw(), frameRate(float), PGraphics.background(float, float, float, float)
      • fullScreen

        public void fullScreen()
        Create a full-screen sketch using the default renderer.
      • fullScreen

        public void fullScreen​(int display)
      • fullScreen

        public void fullScreen​(String renderer)
        ( begin auto-generated from fullScreen.xml ) Description to come... ( end auto-generated )
        Parameters:
        renderer - the renderer to use, e.g. P2D, P3D, JAVA2D (default)
        See Also:
        settings(), setup(), size(int,int), smooth()
      • fullScreen

        public void fullScreen​(String renderer,
                               int display)
        Parameters:
        display - the screen to run the sketch on (1, 2, 3, etc. or on multiple screens using SPAN)
      • size

        public void size​(int width,
                         int height)
        ( begin auto-generated from size.xml ) Defines the dimension of the display window in units of pixels. The size() function must be the first line in setup(). If size() is not used, the default size of the window is 100x100 pixels. The system variables width and height are set by the parameters passed to this function.

        Do not use variables as the parameters to size() function, because it will cause problems when exporting your sketch. When variables are used, the dimensions of your sketch cannot be determined during export. Instead, employ numeric values in the size() statement, and then use the built-in width and height variables inside your program when the dimensions of the display window are needed.

        The size() function can only be used once inside a sketch, and cannot be used for resizing.

        renderer parameter selects which rendering engine to use. For example, if you will be drawing 3D shapes, use P3D, if you want to export images from a program as a PDF file use PDF. A brief description of the three primary renderers follows:

        P2D (Processing 2D) - The default renderer that supports two dimensional drawing.

        P3D (Processing 3D) - 3D graphics renderer that makes use of OpenGL-compatible graphics hardware.

        PDF - The PDF renderer draws 2D graphics directly to an Acrobat PDF file. This produces excellent results when you need vector shapes for high resolution output or printing. You must first use Import Library → PDF to make use of the library. More information can be found in the PDF library reference.

        The P3D renderer doesn't support strokeCap() or strokeJoin(), which can lead to ugly results when using strokeWeight(). (Issue 123)

        The maximum width and height is limited by your operating system, and is usually the width and height of your actual screen. On some machines it may simply be the number of pixels on your current screen, meaning that a screen of 800x600 could support size(1600, 300), since it's the same number of pixels. This varies widely so you'll have to try different rendering modes and sizes until you get what you're looking for. If you need something larger, use createGraphics to create a non-visible drawing surface.

        Again, the size() function must be the first line of the code (or first item inside setup). Any code that appears before the size() command may run more than once, which can lead to confusing results. ( end auto-generated )

        Advanced

        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.

        Parameters:
        width - width of the display window in units of pixels
        height - height of the display window in units of pixels
        See Also:
        width, height
      • size

        public void size​(int width,
                         int height,
                         String renderer)
      • size

        public void size​(int width,
                         int height,
                         String renderer,
                         String path)
      • createGraphics

        public PGraphics createGraphics​(int w,
                                        int h)
      • createGraphics

        public PGraphics createGraphics​(int w,
                                        int h,
                                        String renderer)
        ( begin auto-generated from createGraphics.xml ) Creates and returns a new PGraphics object of the types P2D or P3D. Use this class if you need to draw into an off-screen graphics buffer. The PDF renderer requires the filename parameter. The DXF renderer should not be used with createGraphics(), it's only built for use with beginRaw() and endRaw().

        It's important to call any drawing functions between beginDraw() and endDraw() statements. This is also true for any functions that affect drawing, such as smooth() or colorMode().

        the main drawing surface which is completely opaque, surfaces created with createGraphics() can have transparency. This makes it possible to draw into a graphics and maintain the alpha channel. By using save() to write a PNG or TGA file, the transparency of the graphics object will be honored. Note that transparency levels are binary: pixels are either complete opaque or transparent. For the time being, this means that text characters will be opaque blocks. This will be fixed in a future release (Issue 80). ( end auto-generated )

        Advanced

        Create an offscreen PGraphics object for drawing. This can be used for bitmap or vector images drawing or rendering.
        • Do not use "new PGraphicsXxxx()", use this method. This method ensures that internal variables are set up properly that tie the new graphics context back to its parent PApplet.
        • The basic way to create bitmap images is to use the saveFrame() function.
        • If you want to create a really large scene and write that, first make sure that you've allocated a lot of memory in the Preferences.
        • If you want to create images that are larger than the screen, you should create your own PGraphics object, draw to that, and use save().
          
           PGraphics big;
          
           void setup() {
             big = createGraphics(3000, 3000);
          
             big.beginDraw();
             big.background(128);
             big.line(20, 1800, 1800, 900);
             // etc..
             big.endDraw();
          
             // make sure the file is written to the sketch folder
             big.save("big.tif");
           }
          
           
        • It's important to always wrap drawing to createGraphics() with beginDraw() and endDraw() (beginFrame() and endFrame() prior to revision 0115). The reason is that the renderer needs to know when drawing has stopped, so that it can update itself internally. This also handles calling the defaults() method, for people familiar with that.
        • With Processing 0115 and later, it's possible to write images in formats other than the default .tga and .tiff. The exact formats and background information can be found in the developer's reference for PImage.save().
        Parameters:
        w - width in pixels
        h - height in pixels
        renderer - Either P2D, P3D, or PDF
        See Also:
        PGraphics()
      • createGraphics

        public PGraphics createGraphics​(int w,
                                        int h,
                                        String renderer,
                                        String path)
        Create an offscreen graphics surface for drawing, in this case for a renderer that writes to a file (such as PDF or DXF).
        Parameters:
        path - the name of the file (can be an absolute or relative path)
      • makeGraphics

        protected PGraphics makeGraphics​(int w,
                                         int h,
                                         String renderer,
                                         String path,
                                         boolean primary)
        Version of createGraphics() used internally.
        Parameters:
        path - A path (or null if none), can be absolute or relative (savePath(java.lang.String) will be called)
      • createPrimaryGraphics

        protected PGraphics createPrimaryGraphics()
        Create default renderer, likely to be resized, but needed for surface init.
      • createImage

        public PImage createImage​(int w,
                                  int h,
                                  int format)
        ( begin auto-generated from createImage.xml ) Creates a new PImage (the datatype for storing images). This provides a fresh buffer of pixels to play with. Set the size of the buffer with the width and height parameters. The format parameter defines how the pixels are stored. See the PImage reference for more information.

        Be sure to include all three parameters, specifying only the width and height (but no format) will produce a strange error.

        Advanced users please note that createImage() should be used instead of the syntax new PImage(). ( end auto-generated )

        Advanced

        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.
        Parameters:
        w - width in pixels
        h - height in pixels
        format - Either RGB, ARGB, ALPHA (grayscale alpha channel)
        See Also:
        PImage, PGraphics
      • handleDraw

        public void handleDraw()
      • redraw

        public void redraw()
        ( begin auto-generated from redraw.xml ) Executes the code within draw() one time. This functions allows the program to update the display window only when necessary, for example when an event registered by mousePressed() or keyPressed() occurs.

        structuring a program, it only makes sense to call redraw() within events such as mousePressed(). This is because redraw() does not run draw() immediately (it only sets a flag that indicates an update is needed).

        redraw() within draw() has no effect because draw() is continuously called anyway. ( end auto-generated )
        See Also:
        draw(), loop(), noLoop(), frameRate(float)
      • loop

        public void loop()
        ( begin auto-generated from loop.xml ) Causes Processing to continuously execute the code within draw(). If noLoop() is called, the code in draw() stops executing. ( end auto-generated )
        See Also:
        noLoop(), redraw(), draw()
      • noLoop

        public void noLoop()
        ( begin auto-generated from noLoop.xml ) Stops Processing from continuously executing the code within draw(). If loop() is called, the code in draw() begin to run continuously again. If using noLoop() in setup(), it should be the last line inside the block.

        When noLoop() is used, it's not possible to manipulate or access the screen inside event handling functions such as mousePressed() or keyPressed(). Instead, use those functions to call redraw() or loop(), which will run draw(), which can update the screen properly. This means that when noLoop() has been called, no drawing can happen, and functions like saveFrame() or loadPixels() may not be used.

        Note that if the sketch is resized, redraw() will be called to update the sketch, even after noLoop() has been specified. Otherwise, the sketch would enter an odd state until loop() was called. ( end auto-generated )
        See Also:
        loop(), redraw(), draw()
      • isLooping

        public boolean isLooping()
      • postEvent

        public void postEvent​(Event pe)
        Add an event to the internal event queue, or process it immediately if the sketch is not currently looping.
      • dequeueEvents

        protected void dequeueEvents()
      • handleMouseEvent

        protected void handleMouseEvent​(MouseEvent event)
        Actually take action based on a mouse event. Internally updates mouseX, mouseY, mousePressed, and mouseEvent. Then it calls the event type with no params, i.e. mousePressed() or mouseReleased() that the user may have overloaded to do something more useful.
      • mousePressed

        public void mousePressed()
        ( begin auto-generated from mousePressed.xml ) The mousePressed() function is called once after every time a mouse button is pressed. The mouseButton variable (see the related reference entry) can be used to determine which button has been pressed. ( end auto-generated )

        Advanced

        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.
        See Also:
        mouseX, mouseY, pmouseX, pmouseY, mousePressed, mouseReleased(), mouseClicked(), mouseMoved(), mouseDragged(), mouseButton, mouseWheel(MouseEvent)
      • mousePressed

        public void mousePressed​(MouseEvent event)
      • mouseReleased

        public void mouseReleased​(MouseEvent event)
      • mouseClicked

        public void mouseClicked​(MouseEvent event)
      • mouseDragged

        public void mouseDragged​(MouseEvent event)
      • mouseMoved

        public void mouseMoved​(MouseEvent event)
      • mouseEntered

        public void mouseEntered()
      • mouseEntered

        public void mouseEntered​(MouseEvent event)
      • mouseExited

        public void mouseExited()
      • mouseExited

        public void mouseExited​(MouseEvent event)
      • mouseWheel

        public void mouseWheel()
      • handleKeyEvent

        protected void handleKeyEvent​(KeyEvent event)
      • keyPressed

        public void keyPressed()
        ( begin auto-generated from keyPressed.xml ) The keyPressed() function is called once every time a key is pressed. The key that was pressed is stored in the key variable.

        For non-ASCII keys, use the keyCode variable. The keys included in the ASCII specification (BACKSPACE, TAB, ENTER, RETURN, ESC, and DELETE) do not require checking to see if they key is coded, and you should simply use the key variable instead of keyCode If you're making cross-platform projects, note that the ENTER key is commonly used on PCs and Unix and the RETURN key is used instead on Macintosh. Check for both ENTER and RETURN to make sure your program will work for all platforms.

        Because of how operating systems handle key repeats, holding down a key may cause multiple calls to keyPressed() (and keyReleased() as well). The rate of repeat is set by the operating system and how each computer is configured. ( end auto-generated )

        Advanced

        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.
         
        See Also:
        key, keyCode, keyPressed, keyReleased()
      • keyPressed

        public void keyPressed​(KeyEvent event)
      • keyReleased

        public void keyReleased()
        ( begin auto-generated from keyReleased.xml ) The keyReleased() function is called once every time a key is released. The key that was released will be stored in the key variable. See key and keyReleased for more information. ( end auto-generated )
        See Also:
        key, keyCode, keyPressed, keyPressed()
      • keyReleased

        public void keyReleased​(KeyEvent event)
      • keyTyped

        public void keyTyped()
        ( begin auto-generated from keyTyped.xml ) The keyTyped() function is called once every time a key is pressed, but action keys such as Ctrl, Shift, and Alt are ignored. Because of how operating systems handle key repeats, holding down a key will cause multiple calls to keyTyped(), the rate is set by the operating system and how each computer is configured. ( end auto-generated )
        See Also:
        keyPressed, key, keyCode, keyReleased()
      • keyTyped

        public void keyTyped​(KeyEvent event)
      • focusGained

        public void focusGained()
      • focusLost

        public void focusLost()
      • millis

        public int millis()
        ( begin auto-generated from millis.xml ) Returns the number of milliseconds (thousandths of a second) since starting an applet. This information is often used for timing animation sequences. ( end auto-generated )

        Advanced

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

        See Also:
        second(), minute(), hour(), day(), month(), year()
      • second

        public static int second()
        ( begin auto-generated from second.xml ) Processing communicates with the clock on your computer. The second() function returns the current second as a value from 0 - 59. ( end auto-generated )
        See Also:
        millis(), minute(), hour(), day(), month(), year()
      • minute

        public static int minute()
        ( begin auto-generated from minute.xml ) Processing communicates with the clock on your computer. The minute() function returns the current minute as a value from 0 - 59. ( end auto-generated )
        See Also:
        millis(), second(), hour(), day(), month(), year()
      • hour

        public static int hour()
        ( begin auto-generated from hour.xml ) Processing communicates with the clock on your computer. The hour() function returns the current hour as a value from 0 - 23. ( end auto-generated )
        See Also:
        millis(), second(), minute(), day(), month(), year()
      • day

        public static int day()
        ( begin auto-generated from day.xml ) Processing communicates with the clock on your computer. The day() function returns the current day as a value from 1 - 31. ( end auto-generated )

        Advanced

        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()

        See Also:
        millis(), second(), minute(), hour(), month(), year()
      • month

        public static int month()
        ( begin auto-generated from month.xml ) Processing communicates with the clock on your computer. The month() function returns the current month as a value from 1 - 12. ( end auto-generated )
        See Also:
        millis(), second(), minute(), hour(), day(), year()
      • year

        public static int year()
        ( begin auto-generated from year.xml ) Processing communicates with the clock on your computer. The year() function returns the current year as an integer (2003, 2004, 2005, etc). ( end auto-generated ) The year() function returns the current year as an integer (2003, 2004, 2005, etc).
        See Also:
        millis(), second(), minute(), hour(), day(), month()
      • delay

        public void delay​(int napTime)
        ( begin auto-generated from delay.xml ) 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. The screen only updates when the end of draw() is reached, so delay() cannot be used to slow down drawing. For instance, you cannot use delay() to control the timing of an animation. The delay() function should only be used for pausing scripts (i.e. a script that needs to pause a few seconds before attempting a download, or a sketch that needs to wait a few milliseconds before reading from the serial port). ( end auto-generated )
        Parameters:
        napTime - milliseconds to pause before running draw() again
        See Also:
        frameRate, draw()
      • frameRate

        public void frameRate​(float fps)
        ( begin auto-generated from frameRate.xml ) Specifies the number of frames to be displayed every second. If the processor is not fast enough to maintain the specified rate, it will not be achieved. For example, the function call frameRate(30) will attempt to refresh 30 times a second. It is recommended to set the frame rate within setup(). The default rate is 60 frames per second. ( end auto-generated )
        Parameters:
        fps - number of desired frames per second
        See Also:
        frameRate, frameCount, setup(), draw(), loop(), noLoop(), redraw()
      • link

        public void link​(String url)
        Links to a webpage either in the same window or in a new window. The complete URL must be specified.

        Advanced

        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.

        Parameters:
        url - the complete URL, as a String in quotes
      • launch

        public static Process launch​(String... args)
        ( begin auto-generated from launch.xml ) Attempts to open an application or file using your platform's launcher. The file parameter is a String specifying the file name and location. The location parameter must be a full path name, or the name of an executable in the system's PATH. In most cases, using a full path is the best option, rather than relying on the system PATH. Be sure to make the file executable before attempting to open it (chmod +x).

        The args parameter is a String or String array which is passed to the command line. If you have multiple parameters, e.g. an application and a document, or a command with multiple switches, use the version that takes a String array, and place each individual item in a separate element.

        If args is a String (not an array), then it can only be a single file or application with no parameters. It's not the same as executing that String using a shell. For instance, launch("javac -help") will not work properly.

        This function behaves differently on each platform. On Windows, the parameters are sent to the Windows shell via "cmd /c". On Mac OS X, the "open" command is used (type "man open" in Terminal.app for documentation). On Linux, it first tries gnome-open, then kde-open, but if neither are available, it sends the command to the shell without any alterations.

        For users familiar with Java, this is not quite the same as Runtime.exec(), because the launcher command is prepended. Instead, the exec(String[]) function is a shortcut for Runtime.getRuntime.exec(String[]). ( end auto-generated )
        Parameters:
        args - arguments to the launcher, eg. a filename.
      • exec

        public static Process exec​(String... args)
        Pass a set of arguments directly to the command line. Uses Java's Runtime.exec() method. This is different from the launch() method, which uses the operating system's launcher to open the files. It's always a good idea to use a full path to the executable here.
         exec("/usr/bin/say", "welcome to the command line");
         
        Or if you want to wait until it's completed, something like this:
         Process p = exec("/usr/bin/say", "waiting until done");
         try {
           int result = p.waitFor();
           println("the process returned " + result);
         } catch (InterruptedException e) { }
         
        You can also get the system output and error streams from the Process object, but that's more that we'd like to cover here.
        Returns:
        a Process object
      • exec

        public static int exec​(StringList stdout,
                               StringList stderr,
                               String... args)
        Alternative version of exec() that retrieves stdout and stderr into the StringList objects provided. This is a convenience function that handles simple exec() calls. If the results will be more than a couple lines, you shouldn't use this function, you should use a more elaborate method that makes use of proper threading (to drain the shell output) and error handling to address the many things that can go wrong within this method.
        Parameters:
        stdout - a non-null StringList object to be filled with any output
        stderr - a non-null StringList object to be filled with error lines
        args - each argument to be passed as a series of String objects
        Returns:
        the result returned from the application, or -1 if an Exception occurs before the application is able to return a result.
      • shell

        public static int shell​(StringList stdout,
                                StringList stderr,
                                String... args)
        Same as exec() above, but prefixes the call with a shell.
      • printStackTrace

        protected void printStackTrace​(Throwable t)
        Better way of handling e.printStackTrace() calls so that they can be handled by subclasses as necessary.
      • die

        public void die​(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​(String what,
                        Exception e)
        Same as above but with an exception. Also needs work.
      • exit

        public void exit()
        ( begin auto-generated from exit.xml ) Quits/stops/exits the program. Programs without a draw() function exit automatically after the last line has run, but programs with draw() run continuously until the program is manually stopped or exit() is run.

        Rather than terminating immediately, exit() will cause the sketch to exit after draw() has completed (or after setup() completes if called during the setup() function).

        For Java programmers, this is not the same as System.exit(). Further, System.exit() should not be used because closing out an application while draw() is running may cause a crash (particularly with P3D). ( end auto-generated )
      • exitCalled

        public boolean exitCalled()
      • exitActual

        public void exitActual()
        Some subclasses (I'm looking at you, processing.py) might wish to do something other than actually terminate the JVM. This gives them a chance to do whatever they have in mind when cleaning up.
      • dispose

        public void dispose()
        Called to dispose of resources and shut down the sketch. Destroys the thread, dispose the renderer,and notify listeners.

        Not to be called or overriden by users. If called multiple times, will only notify listeners once. Register a dispose listener instead.

      • method

        public void method​(String name)
        Call a method in the current class based on its name.

        Note that the function being called must be public. Inside the PDE, 'public' is automatically added, but when used without the preprocessor, (like from Eclipse) you'll have to do it yourself.

      • thread

        public void thread​(String name)
        Launch a new thread and call the specified function from that new thread. This is a very simple way to do a thread without needing to get into classes, runnables, etc.

        Note that the function being called must be public. Inside the PDE, 'public' is automatically added, but when used without the preprocessor, (like from Eclipse) you'll have to do it yourself.

        Parameters:
        name - name of the function to be executed in a separate thread
        See Also:
        setup(), draw(), loop(), noLoop()
      • save

        public void save​(String filename)
        ( begin auto-generated from save.xml ) Saves an image from the display window. Images are saved in TIFF, TARGA, JPEG, and PNG format depending on the extension within the filename parameter. For example, "image.tif" will have a TIFF image and "image.png" will save a PNG image. If no extension is included in the filename, the image will save in TIFF format and .tif will be added to the name. These files are saved to the sketch's folder, which may be opened by selecting "Show sketch folder" from the "Sketch" menu. It is not possible to use save() while running the program in a web browser.
        images saved from the main drawing window will be opaque. To save images without a background, use createGraphics(). ( end auto-generated )
        Parameters:
        filename - any sequence of letters and numbers
        See Also:
        saveFrame(), createGraphics(int, int, String)
      • saveFrame

        public void saveFrame()
      • saveFrame

        public void saveFrame​(String filename)
        ( begin auto-generated from saveFrame.xml ) Saves a numbered sequence of images, one image each time the function is run. To save an image that is identical to the display window, run the function at the end of draw() or within mouse and key events such as mousePressed() and keyPressed(). If saveFrame() is called without parameters, it will save the files as screen-0000.tif, screen-0001.tif, etc. It is possible to specify the name of the sequence with the filename parameter and make the choice of saving TIFF, TARGA, PNG, or JPEG files with the ext parameter. These image sequences can be loaded into programs such as Apple's QuickTime software and made into movies. These files are saved to the sketch's folder, which may be opened by selecting "Show sketch folder" from the "Sketch" menu.

        It is not possible to use saveXxxxx() functions inside a web browser unless the sketch is signed applet. To save a file back to a server, see the save to web code snippet on the Processing Wiki.

        All images saved from the main drawing window will be opaque. To save images without a background, use createGraphics(). ( end auto-generated )
        Parameters:
        filename - any sequence of letters or numbers that ends with either ".tif", ".tga", ".jpg", or ".png"
        See Also:
        save(String), createGraphics(int, int, String, String), frameCount
      • insertFrame

        public String insertFrame​(String what)
        Check a string for #### signs to see if the frame number should be inserted. Used for functions like saveFrame() and beginRecord() to replace the # marks with the frame number. If only one # is used, it will be ignored, under the assumption that it's probably not intended to be the frame number.
      • cursor

        public void cursor​(int kind)
        Set the cursor type
        Parameters:
        kind - either ARROW, CROSS, HAND, MOVE, TEXT, or WAIT
      • cursor

        public void cursor​(PImage img)
        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 img,
                           int x,
                           int y)
        ( begin auto-generated from cursor.xml ) Sets the cursor to a predefined symbol, an image, or makes it visible if already hidden. If you are trying to set an image as the cursor, it is recommended to make the size 16x16 or 32x32 pixels. It is not possible to load an image as the cursor if you are exporting your program for the Web and not all MODES work with all Web browsers. The values for parameters x and y must be less than the dimensions of the image.

        Setting or hiding the cursor generally does not work with "Present" mode (when running full-screen). ( end auto-generated )

        Advanced

        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.

        Parameters:
        img - any variable of type PImage
        x - the horizontal active spot of the cursor
        y - the vertical active spot of the cursor
        See Also:
        noCursor()
      • 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()
        ( begin auto-generated from noCursor.xml ) Hides the cursor from view. Will not work when running the program in a web browser or when running in full screen (Present) mode. ( end auto-generated )

        Advanced

        Hide the cursor by creating a transparent image and using it as a custom cursor.
        See Also:
        cursor()
      • print

        public static void print​(byte what)
        ( begin auto-generated from print.xml ) Writes to the console area of the Processing environment. This is often helpful for looking at the data a program is producing. The companion function println() works like print(), but creates a new line of text for each call to the function. Individual elements can be separated with quotes ("") and joined with the addition operator (+).

        Beginning with release 0125, to print the contents of an array, use println(). There's no sensible way to do a print() of an array, because there are too many possibilities for how to separate the data (spaces, commas, etc). If you want to print an array as a single line, use join(). With join(), you can choose any delimiter you like and print() the result.

        Using print() on an object will output null, a memory location that may look like "@10be08," or the result of the toString() method from the object that's being printed. Advanced users who want more useful output when calling print() on their own classes can add a toString() method to the class that returns a String. ( end auto-generated )
        Parameters:
        what - data to print to console
        See Also:
        println(), printArray(Object), join(String[], char)
      • 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​(long what)
      • print

        public static void print​(float what)
      • print

        public static void print​(double what)
      • print

        public static void print​(String what)
      • print

        public static void print​(Object... variables)
        Parameters:
        variables - list of data, separated by commas
      • println

        public static void println()
        ( begin auto-generated from println.xml ) Writes to the text area of the Processing environment's console. This is often helpful for looking at the data a program is producing. Each call to this function creates a new line of output. Individual elements can be separated with quotes ("") and joined with the string concatenation operator (+). See print() for more about what to expect in the output.

        println() on an array (by itself) will write the contents of the array to the console. This is often helpful for looking at the data a program is producing. A new line is put between each element of the array. This function can only print one dimensional arrays. For arrays with higher dimensions, the result will be closer to that of print(). ( end auto-generated )
        See Also:
        print(byte), printArray(Object)
      • println

        public static void println​(byte what)
        Parameters:
        what - data to print to console
      • 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​(long what)
      • println

        public static void println​(float what)
      • println

        public static void println​(double what)
      • println

        public static void println​(String what)
      • println

        public static void println​(Object... variables)
        Parameters:
        variables - list of data, separated by commas
      • println

        public static void println​(Object what)
        For arrays, use printArray() instead. This function causes a warning because the new print(Object...) and println(Object...) functions can't be reliably bound by the compiler.
      • printArray

        public static void printArray​(Object what)
        ( begin auto-generated from printArray.xml ) To come... ( end auto-generated )
        Parameters:
        what - one-dimensional array
        See Also:
        print(byte), println()
      • debug

        public static void debug​(String msg)
      • abs

        public static final float abs​(float n)
        ( begin auto-generated from abs.xml ) Calculates the absolute value (magnitude) of a number. The absolute value of a number is always positive. ( end auto-generated )
        Parameters:
        n - number to compute
      • abs

        public static final int abs​(int n)
      • sq

        public static final float sq​(float n)
        ( begin auto-generated from sq.xml ) Squares a number (multiplies a number by itself). The result is always a positive number, as multiplying two negative numbers always yields a positive result. For example, -1 * -1 = 1. ( end auto-generated )
        Parameters:
        n - number to square
        See Also:
        sqrt(float)
      • sqrt

        public static final float sqrt​(float n)
        ( begin auto-generated from sqrt.xml ) Calculates the square root of a number. The square root of a number is always positive, even though there may be a valid negative root. The square root s of number a is such that s*s = a. It is the opposite of squaring. ( end auto-generated )
        Parameters:
        n - non-negative number
        See Also:
        pow(float, float), sq(float)
      • log

        public static final float log​(float n)
        ( begin auto-generated from log.xml ) Calculates the natural logarithm (the base-e logarithm) of a number. This function expects the values greater than 0.0. ( end auto-generated )
        Parameters:
        n - number greater than 0.0
      • exp

        public static final float exp​(float n)
        ( begin auto-generated from exp.xml ) Returns Euler's number e (2.71828...) raised to the power of the value parameter. ( end auto-generated )
        Parameters:
        n - exponent to raise
      • pow

        public static final float pow​(float n,
                                      float e)
        ( begin auto-generated from pow.xml ) Facilitates exponential expressions. The pow() function is an efficient way of multiplying numbers by themselves (or their reciprocal) in large quantities. For example, pow(3, 5) is equivalent to the expression 3*3*3*3*3 and pow(3, -5) is equivalent to 1 / 3*3*3*3*3. ( end auto-generated )
        Parameters:
        n - base of the exponential expression
        e - power by which to raise the base
        See Also:
        sqrt(float)
      • max

        public static final int max​(int a,
                                    int b)
        ( begin auto-generated from max.xml ) Determines the largest value in a sequence of numbers. ( end auto-generated )
        Parameters:
        a - first number to compare
        b - second number to compare
        See Also:
        min(float, float, float)
      • max

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

        public static final int max​(int a,
                                    int b,
                                    int c)
        Parameters:
        c - third number to compare
      • max

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

        public static final int max​(int[] list)
        Parameters:
        list - array of numbers to compare
      • max

        public static final float max​(float[] list)
      • 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)
        ( begin auto-generated from min.xml ) Determines the smallest value in a sequence of numbers. ( end auto-generated )
        Parameters:
        a - first number
        b - second number
        c - third number
        See Also:
        max(float, float, float)
      • min

        public static final int min​(int[] list)
        Parameters:
        list - array of numbers to compare
      • min

        public static final float min​(float[] list)
      • constrain

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

        public static final float constrain​(float amt,
                                            float low,
                                            float high)
        ( begin auto-generated from constrain.xml ) Constrains a value to not exceed a maximum and minimum value. ( end auto-generated )
        Parameters:
        amt - the value to constrain
        low - minimum limit
        high - maximum limit
        See Also:
        max(float, float, float), min(float, float, float)
      • sin

        public static final float sin​(float angle)
        ( begin auto-generated from sin.xml ) Calculates the sine of an angle. This function expects the values of the angle parameter to be provided in radians (values from 0 to 6.28). Values are returned in the range -1 to 1. ( end auto-generated )
        Parameters:
        angle - an angle in radians
        See Also:
        cos(float), tan(float), radians(float)
      • cos

        public static final float cos​(float angle)
        ( begin auto-generated from cos.xml ) Calculates the cosine of an angle. This function expects the values of the angle parameter to be provided in radians (values from 0 to PI*2). Values are returned in the range -1 to 1. ( end auto-generated )
        Parameters:
        angle - an angle in radians
        See Also:
        sin(float), tan(float), radians(float)
      • tan

        public static final float tan​(float angle)
        ( begin auto-generated from tan.xml ) Calculates the ratio of the sine and cosine of an angle. This function expects the values of the angle parameter to be provided in radians (values from 0 to PI*2). Values are returned in the range infinity to -infinity. ( end auto-generated )
        Parameters:
        angle - an angle in radians
        See Also:
        cos(float), sin(float), radians(float)
      • asin

        public static final float asin​(float value)
        ( begin auto-generated from asin.xml ) The inverse of sin(), returns the arc sine of a value. This function expects the values in the range of -1 to 1 and values are returned in the range -PI/2 to PI/2. ( end auto-generated )
        Parameters:
        value - the value whose arc sine is to be returned
        See Also:
        sin(float), acos(float), atan(float)
      • acos

        public static final float acos​(float value)
        ( begin auto-generated from acos.xml ) The inverse of cos(), returns the arc cosine of a value. This function expects the values in the range of -1 to 1 and values are returned in the range 0 to PI (3.1415927). ( end auto-generated )
        Parameters:
        value - the value whose arc cosine is to be returned
        See Also:
        cos(float), asin(float), atan(float)
      • atan

        public static final float atan​(float value)
        ( begin auto-generated from atan.xml ) The inverse of tan(), returns the arc tangent of a value. This function expects the values in the range of -Infinity to Infinity (exclusive) and values are returned in the range -PI/2 to PI/2 . ( end auto-generated )
        Parameters:
        value - -Infinity to Infinity (exclusive)
        See Also:
        tan(float), asin(float), acos(float)
      • atan2

        public static final float atan2​(float y,
                                        float x)
        ( begin auto-generated from atan2.xml ) Calculates the angle (in radians) from a specified point to the coordinate origin as measured from the positive x-axis. Values are returned as a float in the range from PI to -PI. The atan2() function is most often used for orienting geometry to the position of the cursor. Note: The y-coordinate of the point is the first parameter and the x-coordinate is the second due the the structure of calculating the tangent. ( end auto-generated )
        Parameters:
        y - y-coordinate of the point
        x - x-coordinate of the point
        See Also:
        tan(float)
      • degrees

        public static final float degrees​(float radians)
        ( begin auto-generated from degrees.xml ) Converts a radian measurement to its corresponding value in degrees. Radians and degrees are two ways of measuring the same thing. There are 360 degrees in a circle and 2*PI radians in a circle. For example, 90° = PI/2 = 1.5707964. All trigonometric functions in Processing require their parameters to be specified in radians. ( end auto-generated )
        Parameters:
        radians - radian value to convert to degrees
        See Also:
        radians(float)
      • radians

        public static final float radians​(float degrees)
        ( begin auto-generated from radians.xml ) Converts a degree measurement to its corresponding value in radians. Radians and degrees are two ways of measuring the same thing. There are 360 degrees in a circle and 2*PI radians in a circle. For example, 90° = PI/2 = 1.5707964. All trigonometric functions in Processing require their parameters to be specified in radians. ( end auto-generated )
        Parameters:
        degrees - degree value to convert to radians
        See Also:
        degrees(float)
      • ceil

        public static final int ceil​(float n)
        ( begin auto-generated from ceil.xml ) Calculates the closest int value that is greater than or equal to the value of the parameter. For example, ceil(9.03) returns the value 10. ( end auto-generated )
        Parameters:
        n - number to round up
        See Also:
        floor(float), round(float)
      • floor

        public static final int floor​(float n)
        ( begin auto-generated from floor.xml ) Calculates the closest int value that is less than or equal to the value of the parameter. ( end auto-generated )
        Parameters:
        n - number to round down
        See Also:
        ceil(float), round(float)
      • round

        public static final int round​(float n)
        ( begin auto-generated from round.xml ) Calculates the integer closest to the value parameter. For example, round(9.2) returns the value 9. ( end auto-generated )
        Parameters:
        n - number to round
        See Also:
        floor(float), ceil(float)
      • mag

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

        public static final float mag​(float a,
                                      float b,
                                      float c)
        ( begin auto-generated from mag.xml ) Calculates the magnitude (or length) of a vector. A vector is a direction in space commonly used in computer graphics and linear algebra. Because it has no "start" position, the magnitude of a vector can be thought of as the distance from coordinate (0,0) to its (x,y) value. Therefore, mag() is a shortcut for writing "dist(0, 0, x, y)". ( end auto-generated )
        Parameters:
        a - first value
        b - second value
        c - third value
        See Also:
        dist(float, float, float, float)
      • 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)
        ( begin auto-generated from dist.xml ) Calculates the distance between two points. ( end auto-generated )
        Parameters:
        x1 - x-coordinate of the first point
        y1 - y-coordinate of the first point
        z1 - z-coordinate of the first point
        x2 - x-coordinate of the second point
        y2 - y-coordinate of the second point
        z2 - z-coordinate of the second point
      • norm

        public static final float norm​(float value,
                                       float start,
                                       float stop)
        ( begin auto-generated from norm.xml ) Normalizes a number from another range into a value between 0 and 1.

        Identical to map(value, low, high, 0, 1);

        Numbers outside the range are not clamped to 0 and 1, because out-of-range values are often intentional and useful. ( end auto-generated )
        Parameters:
        value - the incoming value to be converted
        start - lower bound of the value's current range
        stop - upper bound of the value's current range
        See Also:
        map(float, float, float, float, float), lerp(float, float, float)
      • map

        public static final float map​(float value,
                                      float start1,
                                      float stop1,
                                      float start2,
                                      float stop2)
        ( begin auto-generated from map.xml ) Re-maps a number from one range to another. In the example above, the number '25' is converted from a value in the range 0..100 into a value that ranges from the left edge (0) to the right edge (width) of the screen.

        Numbers outside the range are not clamped to 0 and 1, because out-of-range values are often intentional and useful. ( end auto-generated )
        Parameters:
        value - the incoming value to be converted
        start1 - lower bound of the value's current range
        stop1 - upper bound of the value's current range
        start2 - lower bound of the value's target range
        stop2 - upper bound of the value's target range
        See Also:
        norm(float, float, float), lerp(float, float, float)
      • random

        public final float random​(float high)
      • randomGaussian

        public final float randomGaussian()
        ( begin auto-generated from randomGaussian.xml ) Returns a float from a random series of numbers having a mean of 0 and standard deviation of 1. Each time the randomGaussian() function is called, it returns a number fitting a Gaussian, or normal, distribution. There is theoretically no minimum or maximum value that randomGaussian() might return. Rather, there is just a very low probability that values far from the mean will be returned; and a higher probability that numbers near the mean will be returned. ( end auto-generated )
        See Also:
        random(float,float), noise(float, float, float)
      • random

        public final float random​(float low,
                                  float high)
        ( begin auto-generated from random.xml ) Generates random numbers. Each time the random() function is called, it returns an unexpected value within the specified range. If one parameter is passed to the function it will return a float between zero and the value of the high parameter. The function call random(5) returns values between 0 and 5 (starting at zero, up to but not including 5). If two parameters are passed, it will return a float with a value between the the parameters. The function call random(-5, 10.2) returns values starting at -5 up to (but not including) 10.2. To convert a floating-point random number to an integer, use the int() function. ( end auto-generated )
        Parameters:
        low - lower limit
        high - upper limit
        See Also:
        randomSeed(long), noise(float, float, float)
      • randomSeed

        public final void randomSeed​(long seed)
        ( begin auto-generated from randomSeed.xml ) Sets the seed value for random(). By default, random() produces different results each time the program is run. Set the value parameter to a constant to return the same pseudo-random numbers each time the software is run. ( end auto-generated )
        Parameters:
        seed - seed value
        See Also:
        random(float,float), noise(float, float, float), noiseSeed(long)
      • noise

        public float noise​(float x)
      • noise

        public float noise​(float x,
                           float y)
      • noise

        public float noise​(float x,
                           float y,
                           float z)
        ( begin auto-generated from noise.xml ) Returns the Perlin noise value at specified coordinates. Perlin noise is a random sequence generator producing a more natural ordered, harmonic succession of numbers compared to the standard random() function. It was invented by Ken Perlin in the 1980s and been used since in graphical applications to produce procedural textures, natural motion, shapes, terrains etc.

        The main difference to the random() function is that Perlin noise is defined in an infinite n-dimensional space where each pair of coordinates corresponds to a fixed semi-random value (fixed only for the lifespan of the program). The resulting value will always be between 0.0 and 1.0. Processing can compute 1D, 2D and 3D noise, depending on the number of coordinates given. The noise value can be animated by moving through the noise space as demonstrated in the example above. The 2nd and 3rd dimension can also be interpreted as time.

        The actual noise is structured similar to an audio signal, in respect to the function's use of frequencies. Similar to the concept of harmonics in physics, perlin noise is computed over several octaves which are added together for the final result.

        Another way to adjust the character of the resulting sequence is the scale of the input coordinates. As the function works within an infinite space the value of the coordinates doesn't matter as such, only the distance between successive coordinates does (eg. when using noise() within a loop). As a general rule the smaller the difference between coordinates, the smoother the resulting noise sequence will be. Steps of 0.005-0.03 work best for most applications, but this will differ depending on use. ( end auto-generated )
        Parameters:
        x - x-coordinate in noise space
        y - y-coordinate in noise space
        z - z-coordinate in noise space
        See Also:
        noiseSeed(long), noiseDetail(int, float), random(float,float)
      • noiseDetail

        public void noiseDetail​(int lod)
        ( begin auto-generated from noiseDetail.xml ) Adjusts the character and level of detail produced by the Perlin noise function. Similar to harmonics in physics, noise is computed over several octaves. Lower octaves contribute more to the output signal and as such define the overal intensity of the noise, whereas higher octaves create finer grained details in the noise sequence. By default, noise is computed over 4 octaves with each octave contributing exactly half than its predecessor, starting at 50% strength for the 1st octave. This falloff amount can be changed by adding an additional function parameter. Eg. a falloff factor of 0.75 means each octave will now have 75% impact (25% less) of the previous lower octave. Any value between 0.0 and 1.0 is valid, however note that values greater than 0.5 might result in greater than 1.0 values returned by noise().

        By changing these parameters, the signal created by the noise() function can be adapted to fit very specific needs and characteristics. ( end auto-generated )
        Parameters:
        lod - number of octaves to be used by the noise
        See Also:
        noise(float, float, float)
      • noiseDetail

        public void noiseDetail​(int lod,
                                float falloff)
        Parameters:
        falloff - falloff factor for each octave
        See Also:
        noiseDetail(int)
      • noiseSeed

        public void noiseSeed​(long seed)
        ( begin auto-generated from noiseSeed.xml ) Sets the seed value for noise(). By default, noise() produces different results each time the program is run. Set the value parameter to a constant to return the same pseudo-random numbers each time the software is run. ( end auto-generated )
        Parameters:
        seed - seed value
        See Also:
        noise(float, float, float), noiseDetail(int, float), random(float,float), randomSeed(long)
      • loadImage

        public PImage loadImage​(String filename)
        ( begin auto-generated from loadImage.xml ) Loads an image into a variable of type PImage. Four types of images ( .gif, .jpg, .tga, .png) images may be loaded. To load correctly, images must be located in the data directory of the current sketch. In most cases, load all images in setup() to preload them at the start of the program. Loading images inside draw() will reduce the speed of a program.

        filename parameter can also be a URL to a file found online. For security reasons, a Processing sketch found online can only download files from the same server from which it came. Getting around this restriction requires a signed applet.

        extension parameter is used to determine the image type in cases where the image filename does not end with a proper extension. Specify the extension as the second parameter to loadImage(), as shown in the third example on this page.

        an image is not loaded successfully, the null value is returned and an error message will be printed to the console. The error message does not halt the program, however the null value may cause a NullPointerException if your code does not check whether the value returned from loadImage() is null.

        on the type of error, a PImage object may still be returned, but the width and height of the image will be set to -1. This happens if bad image data is returned or cannot be decoded properly. Sometimes this happens with image URLs that produce a 403 error or that redirect to a password prompt, because loadImage() will attempt to interpret the HTML as image data. ( end auto-generated )
        Parameters:
        filename - name of file to load, can be .gif, .jpg, .tga, or a handful of other image types depending on your platform
        See Also:
        PImage, PGraphics.image(PImage, float, float, float, float), PGraphics.imageMode(int), PGraphics.background(float, float, float, float)
      • loadImage

        public PImage loadImage​(String filename,
                                String extension)
        Parameters:
        extension - type of image to load, for example "png", "gif", "jpg"
      • requestImage

        public PImage requestImage​(String filename)
      • requestImage

        public PImage requestImage​(String filename,
                                   String extension)
        ( begin auto-generated from requestImage.xml ) This function load images on a separate thread so that your sketch does not freeze while images load during setup(). While the image is loading, its width and height will be 0. If an error occurs while loading the image, its width and height will be set to -1. You'll know when the image has loaded properly because its width and height will be greater than 0. Asynchronous image loading (particularly when downloading from a server) can dramatically improve performance.

        extension parameter is used to determine the image type in cases where the image filename does not end with a proper extension. Specify the extension as the second parameter to requestImage(). ( end auto-generated )
        Parameters:
        filename - name of the file to load, can be .gif, .jpg, .tga, or a handful of other image types depending on your platform
        extension - the type of image to load, for example "png", "gif", "jpg"
        See Also:
        PImage, loadImage(String, String)
      • loadImageIO

        protected PImage loadImageIO​(String filename)
        Use Java 1.4 ImageIO methods to load an image.
      • loadImageTGA

        protected PImage loadImageTGA​(String filename)
                               throws IOException
        Targa image loader for RLE-compressed TGA files.

        Rewritten for 0115 to read/write RLE-encoded targa images. For 0125, non-RLE encoded images are now supported, along with images whose y-order is reversed (which is standard for TGA files).

        A version of this function is in MovieMaker.java. Any fixes here should be applied over in MovieMaker as well.

        Known issue with RLE encoding and odd behavior in some apps: https://github.com/processing/processing/issues/2096 Please help!

        Throws:
        IOException
      • saveXML

        public boolean saveXML​(XML xml,
                               String filename,
                               String options)
      • loadJSONObject

        public static JSONObject loadJSONObject​(File file)
      • saveJSONObject

        public boolean saveJSONObject​(JSONObject json,
                                      String filename,
                                      String options)
        Parameters:
        options - "compact" and "indent=N", replace N with the number of spaces
      • loadJSONArray

        public static JSONArray loadJSONArray​(File file)
      • saveJSONArray

        public boolean saveJSONArray​(JSONArray json,
                                     String filename,
                                     String options)
        Parameters:
        options - "compact" and "indent=N", replace N with the number of spaces
      • loadTable

        public Table loadTable​(String filename,
                               String options)
        Options may contain "header", "tsv", "csv", or "bin" separated by commas. Another option is "dictionary=filename.tsv", which allows users to specify a "dictionary" file that contains a mapping of the column titles and the data types used in the table file. This can be far more efficient (in terms of speed and memory usage) for loading and parsing tables. The dictionary file can only be tab separated values (.tsv) and its extension will be ignored. This option was added in Processing 2.0.2.
        Parameters:
        options - may contain "header", "tsv", "csv", or "bin" separated by commas
      • saveTable

        public boolean saveTable​(Table table,
                                 String filename)
        Parameters:
        table - the Table object to save to a file
        filename - the filename to which the Table should be saved
        See Also:
        Table, loadTable(String)
      • saveTable

        public boolean saveTable​(Table table,
                                 String filename,
                                 String options)
        Parameters:
        options - can be one of "tsv", "csv", "bin", or "html"
      • loadFont

        public PFont loadFont​(String filename)
        ( begin auto-generated from loadFont.xml ) Loads a font into a variable of type PFont. To load correctly, fonts must be located in the data directory of the current sketch. To create a font to use with Processing, select "Create Font..." from the Tools menu. This will create a font in the format Processing requires and also adds it to the current sketch's data directory.

        Like loadImage() and other functions that load data, the loadFont() function should not be used inside draw(), because it will slow down the sketch considerably, as the font will be re-loaded from the disk (or network) on each frame.

        For most renderers, Processing displays fonts using the .vlw font format, which uses images for each letter, rather than defining them through vector data. When hint(ENABLE_NATIVE_FONTS) is used with the JAVA2D renderer, the native version of a font will be used if it is installed on the user's machine.

        Using createFont() (instead of loadFont) enables vector data to be used with the JAVA2D (default) renderer setting. This can be helpful when many font sizes are needed, or when using any renderer based on JAVA2D, such as the PDF library. ( end auto-generated )
        Parameters:
        filename - name of the font to load
        See Also:
        PFont, PGraphics.textFont(PFont, float), createFont(String, float, boolean, char[])
      • createFont

        public PFont createFont​(String name,
                                float size)
      • createFont

        public PFont createFont​(String name,
                                float size,
                                boolean smooth)
      • createFont

        public PFont createFont​(String name,
                                float size,
                                boolean smooth,
                                char[] charset)
        ( begin auto-generated from createFont.xml ) Dynamically converts a font to the format used by Processing from either a font name that's installed on the computer, or from a .ttf or .otf file inside the sketches "data" folder. This function is an advanced feature for precise control. On most occasions you should create fonts through selecting "Create Font..." from the Tools menu.

        Use the PFont.list() method to first determine the names for the fonts recognized by the computer and are compatible with this function. Because of limitations in Java, not all fonts can be used and some might work with one operating system and not others. When sharing a sketch with other people or posting it on the web, you may need to include a .ttf or .otf version of your font in the data directory of the sketch because other people might not have the font installed on their computer. Only fonts that can legally be distributed should be included with a sketch.

        The size parameter states the font size you want to generate. The smooth parameter specifies if the font should be antialiased or not, and the charset parameter is an array of chars that specifies the characters to generate.

        This function creates a bitmapped version of a font in the same manner as the Create Font tool. It loads a font by name, and converts it to a series of images based on the size of the font. When possible, the text() function will use a native font rather than the bitmapped version created behind the scenes with createFont(). For instance, when using P2D, the actual native version of the font will be employed by the sketch, improving drawing quality and performance. With the P3D renderer, the bitmapped version will be used. While this can drastically improve speed and appearance, results are poor when exporting if the sketch does not include the .otf or .ttf file, and the requested font is not available on the machine running the sketch. ( end auto-generated )
        Parameters:
        name - name of the font to load
        size - point size of the font
        smooth - true for an antialiased font, false for aliased
        charset - array containing characters to be generated
        See Also:
        PFont, PGraphics.textFont(PFont, float), PGraphics.text(String, float, float, float, float), loadFont(String)
      • selectInput

        public void selectInput​(String prompt,
                                String callback)
        Open a platform-specific file chooser dialog to select a file for input. After the selection is made, the selected File will be passed to the 'callback' function. If the dialog is closed or canceled, null will be sent to the function, so that the program is not waiting for additional input. The callback is necessary because of how threading works.
         void setup() {
           selectInput("Select a file to process:", "fileSelected");
         }
        
         void fileSelected(File selection) {
           if (selection == null) {
             println("Window was closed or the user hit cancel.");
           } else {
             println("User selected " + fileSeleted.getAbsolutePath());
           }
         }
         
        For advanced users, the method must be 'public', which is true for all methods inside a sketch when run from the PDE, but must explicitly be set when using Eclipse or other development environments.
        Parameters:
        prompt - message to the user
        callback - name of the method to be called when the selection is made
      • selectInput

        public void selectInput​(String prompt,
                                String callback,
                                File file)
      • selectInput

        public void selectInput​(String prompt,
                                String callback,
                                File file,
                                Object callbackObject)
      • selectInput

        public static void selectInput​(String prompt,
                                       String callbackMethod,
                                       File file,
                                       Object callbackObject,
                                       Frame parent)
      • selectOutput

        public void selectOutput​(String prompt,
                                 String callback)
        See selectInput() for details.
        Parameters:
        prompt - message to the user
        callback - name of the method to be called when the selection is made
      • selectOutput

        public void selectOutput​(String prompt,
                                 String callback,
                                 File file)
      • selectOutput

        public void selectOutput​(String prompt,
                                 String callback,
                                 File file,
                                 Object callbackObject)
      • selectOutput

        public static void selectOutput​(String prompt,
                                        String callbackMethod,
                                        File file,
                                        Object callbackObject,
                                        Frame parent)
      • selectImpl

        protected static void selectImpl​(String prompt,
                                         String callbackMethod,
                                         File defaultSelection,
                                         Object callbackObject,
                                         Frame parentFrame,
                                         int mode,
                                         PApplet sketch)
      • selectFolder

        public void selectFolder​(String prompt,
                                 String callback)
        See selectInput() for details.
        Parameters:
        prompt - message to the user
        callback - name of the method to be called when the selection is made
      • selectFolder

        public void selectFolder​(String prompt,
                                 String callback,
                                 File file)
      • selectFolder

        public void selectFolder​(String prompt,
                                 String callback,
                                 File file,
                                 Object callbackObject)
      • selectFolder

        public static void selectFolder​(String prompt,
                                        String callbackMethod,
                                        File defaultSelection,
                                        Object callbackObject,
                                        Frame parentFrame)
      • selectFolder

        public static void selectFolder​(String prompt,
                                        String callbackMethod,
                                        File defaultSelection,
                                        Object callbackObject,
                                        Frame parentFrame,
                                        PApplet sketch)
      • listFiles

        public static File[] listFiles​(File base,
                                       String... options)
      • checkExtension

        public static String checkExtension​(String filename)
        Get the compression-free extension for this filename.
        Parameters:
        filename - The filename to check
        Returns:
        an extension, skipping past .gz if it's present
      • createReader

        public BufferedReader createReader​(String filename)
        ( begin auto-generated from createReader.xml ) Creates a BufferedReader object that can be used to read files line-by-line as individual String objects. This is the complement to the createWriter() function.

        Starting with Processing release 0134, all files loaded and saved by the Processing API use UTF-8 encoding. In previous releases, the default encoding for your platform was used, which causes problems when files are moved to other platforms. ( end auto-generated )
        Parameters:
        filename - name of the file to be opened
        See Also:
        BufferedReader, createWriter(String), PrintWriter
      • createWriter

        public PrintWriter createWriter​(String filename)
        ( begin auto-generated from createWriter.xml ) Creates a new file in the sketch folder, and a PrintWriter object to write to it. For the file to be made correctly, it should be flushed and must be closed with its flush() and close() methods (see above example).

        Starting with Processing release 0134, all files loaded and saved by the Processing API use UTF-8 encoding. In previous releases, the default encoding for your platform was used, which causes problems when files are moved to other platforms. ( end auto-generated )
        Parameters:
        filename - name of the file to be created
        See Also:
        PrintWriter, createReader(java.lang.String), BufferedReader
      • createInput

        public InputStream createInput​(String filename)
        ( begin auto-generated from createInput.xml ) This is a function for advanced programmers to open a Java InputStream. It's useful if you want to use the facilities provided by PApplet to easily open files from the data folder or from a URL, but want an InputStream object so that you can use other parts of Java to take more control of how the stream is read.

        The filename passed in can be:
        - A URL, for instance openStream("http://processing.org/")
        - A file in the sketch's data folder
        - The full path to a file to be opened locally (when running as an application)

        If the requested item doesn't exist, null is returned. If not online, this will also check to see if the user is asking for a file whose name isn't properly capitalized. If capitalization is different, an error will be printed to the console. This helps prevent issues that appear when a sketch is exported to the web, where case sensitivity matters, as opposed to running from inside the Processing Development Environment on Windows or Mac OS, where case sensitivity is preserved but ignored.

        If the file ends with .gz, the stream will automatically be gzip decompressed. If you don't want the automatic decompression, use the related function createInputRaw().
        In earlier releases, this function was called openStream().

        ( end auto-generated )

        Advanced

        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:

        • A URL, for instance openStream("http://processing.org/");
        • A file in the sketch's data folder
        • Another file to be opened locally (when running as an application)
        Parameters:
        filename - the name of the file to use as input
        See Also:
        createOutput(String), selectOutput(String,String), selectInput(String,String)
      • createInputRaw

        public InputStream createInputRaw​(String filename)
        Call openStream() without automatic gzip decompression.
      • loadBytes

        public byte[] loadBytes​(String filename)
        ( begin auto-generated from loadBytes.xml ) Reads the contents of a file or url and places it in a byte array. If a file is specified, it must be located in the sketch's "data" directory/folder.

        The filename parameter can also be a URL to a file found online. For security reasons, a Processing sketch found online can only download files from the same server from which it came. Getting around this restriction requires a signed applet. ( end auto-generated )
        Parameters:
        filename - name of a file in the data folder or a URL.
        See Also:
        loadStrings(String), saveStrings(String, String[]), saveBytes(String, byte[])
      • loadBytes

        public static byte[] loadBytes​(InputStream input)
      • loadBytes

        public static byte[] loadBytes​(File file)
      • loadStrings

        public static String[] loadStrings​(File file)
      • loadStrings

        public String[] loadStrings​(String filename)
        ( begin auto-generated from loadStrings.xml ) Reads the contents of a file or url and creates a String array of its individual lines. If a file is specified, it must be located in the sketch's "data" directory/folder.

        The filename parameter can also be a URL to a file found online. For security reasons, a Processing sketch found online can only download files from the same server from which it came. Getting around this restriction requires a signed applet.
        If the file is not available or an error occurs, null will be returned and an error message will be printed to the console. The error message does not halt the program, however the null value may cause a NullPointerException if your code does not check whether the value returned is null.

        Starting with Processing release 0134, all files loaded and saved by the Processing API use UTF-8 encoding. In previous releases, the default encoding for your platform was used, which causes problems when files are moved to other platforms. ( end auto-generated )

        Advanced

        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.

        Parameters:
        filename - name of the file or url to load
        See Also:
        loadBytes(String), saveStrings(String, String[]), saveBytes(String, byte[])
      • createOutput

        public OutputStream createOutput​(String filename)
        ( begin auto-generated from createOutput.xml ) Similar to createInput(), 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.

        This function is a convenience over the Java approach that requires you to 1) create a FileOutputStream object, 2) determine the exact file location, and 3) handle exceptions. Exceptions are handled internally by the function, which is more appropriate for "sketch" projects.

        If the output filename ends with .gz, the output will be automatically GZIP compressed as it is written. ( end auto-generated )
        Parameters:
        filename - name of the file to open
        See Also:
        createInput(String), selectOutput(String,String)
      • saveStream

        public boolean saveStream​(String target,
                                  String source)
        ( begin auto-generated from saveStream.xml ) 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).

        When using the targetFile parameter, it writes to a File object for greater control over the file location. (Note that unlike some other functions, this will not automatically compress or uncompress gzip files.) ( end auto-generated )
        Parameters:
        target - name of the file to write to
        source - location to read from (a filename, path, or URL)
        See Also:
        createOutput(String)
      • saveStream

        public boolean saveStream​(File target,
                                  String source)
        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 boolean saveStream​(File target,
                                         InputStream source)
      • saveBytes

        public void saveBytes​(String filename,
                              byte[] data)
        ( begin auto-generated from saveBytes.xml ) Opposite of loadBytes(), will write an entire array of bytes to a file. The data is saved in binary format. This file is saved to the sketch's folder, which is opened by selecting "Show sketch folder" from the "Sketch" menu.

        It is not possible to use saveXxxxx() functions inside a web browser unless the sketch is signed applet. To save a file back to a server, see the save to web code snippet on the Processing Wiki. ( end auto-generated )
        Parameters:
        filename - name of the file to write to
        data - array of bytes to be written
        See Also:
        loadStrings(String), loadBytes(String), saveStrings(String, String[])
      • saveBytes

        public static void saveBytes​(File file,
                                     byte[] data)
      • saveBytes

        public static void saveBytes​(OutputStream output,
                                     byte[] data)
      • saveStrings

        public void saveStrings​(String filename,
                                String[] data)
        ( begin auto-generated from saveStrings.xml ) Writes an array of strings to a file, one line per string. This file is saved to the sketch's folder, which is opened by selecting "Show sketch folder" from the "Sketch" menu.

        It is not possible to use saveXxxxx() functions inside a web browser unless the sketch is signed applet. To save a file back to a server, see the save to web code snippet on the Processing Wiki.

        Starting with Processing 1.0, all files loaded and saved by the Processing API use UTF-8 encoding. In previous releases, the default encoding for your platform was used, which causes problems when files are moved to other platforms. ( end auto-generated )
        Parameters:
        filename - filename for output
        data - string array to be written
        See Also:
        loadStrings(String), loadBytes(String), saveBytes(String, byte[])
      • saveStrings

        public static void saveStrings​(File file,
                                       String[] data)
      • calcSketchPath

        protected static String calcSketchPath()
      • sketchPath

        public String sketchPath()
      • sketchPath

        public String sketchPath​(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 File sketchFile​(String where)
      • savePath

        public String savePath​(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 File saveFile​(String where)
        Identical to savePath(), but returns a File object.
      • desktopFile

        public static File desktopFile​(String what)
        Not a supported function. For testing use only.
      • desktopPath

        public static String desktopPath​(String what)
        Not a supported function. For testing use only.
      • dataPath

        public String dataPath​(String where)
        This function almost certainly does not do the thing you want it to. The data path is handled differently on each platform, and should not be considered a location to write files. It should also not be assumed that this location can be read from or listed. This function is used internally as a possible location for reading files. It's still "public" as a holdover from earlier code.

        Libraries should use createInput() to get an InputStream or createOutput() to get an OutputStream. sketchPath() can be used to get a location relative to the sketch. Again, do not use this to get relative locations of files. You'll be disappointed when your app runs on different platforms.

      • dataFile

        public File dataFile​(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​(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​(File file)
      • getExtension

        public static String getExtension​(String filename)
      • urlEncode

        public static String urlEncode​(String str)
      • urlDecode

        public static String urlDecode​(String str)
      • sort

        public static byte[] sort​(byte[] list)
        ( begin auto-generated from sort.xml ) Sorts an array of numbers from smallest to largest and puts an array of words in alphabetical order. The original array is not modified, a re-ordered array is returned. The count parameter states the number of elements to sort. For example if there are 12 elements in an array and if count is the value 5, only the first five elements on the array will be sorted. ( end auto-generated )
        Parameters:
        list - array to sort
        See Also:
        reverse(boolean[])
      • sort

        public static byte[] sort​(byte[] list,
                                  int count)
        Parameters:
        count - number of elements to sort, starting from 0
      • sort

        public static char[] sort​(char[] list)
      • sort

        public static char[] sort​(char[] list,
                                  int count)
      • sort

        public static int[] sort​(int[] list)
      • sort

        public static int[] sort​(int[] list,
                                 int count)
      • sort

        public static float[] sort​(float[] list)
      • sort

        public static float[] sort​(float[] list,
                                   int count)
      • sort

        public static String[] sort​(String[] list,
                                    int count)
      • arrayCopy

        public static void arrayCopy​(Object src,
                                     int srcPosition,
                                     Object dst,
                                     int dstPosition,
                                     int length)
        ( begin auto-generated from arrayCopy.xml ) Copies an array (or part of an array) to another array. The src array is copied to the dst array, beginning at the position specified by srcPos and into the position specified by dstPos. The number of elements to copy is determined by length. The simplified version with two arguments copies an entire array to another of the same size. It is equivalent to "arrayCopy(src, 0, dst, 0, src.length)". This function is far more efficient for copying array data than iterating through a for and copying each element. ( end auto-generated )
        Parameters:
        src - the source array
        srcPosition - starting position in the source array
        dst - the destination array of the same data type as the source array
        dstPosition - starting position in the destination array
        length - number of array elements to be copied
        See Also:
        concat(boolean[], boolean[])
      • arrayCopy

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

        public static void arrayCopy​(Object src,
                                     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

        @Deprecated
        public static void arraycopy​(Object src,
                                     int srcPosition,
                                     Object dst,
                                     int dstPosition,
                                     int length)
        Deprecated.
        Use arrayCopy() instead.
      • arraycopy

        @Deprecated
        public static void arraycopy​(Object src,
                                     Object dst,
                                     int length)
        Deprecated.
        Use arrayCopy() instead.
      • arraycopy

        @Deprecated
        public static void arraycopy​(Object src,
                                     Object dst)
        Deprecated.
        Use arrayCopy() instead.
      • expand

        public static boolean[] expand​(boolean[] list)
        ( begin auto-generated from expand.xml ) Increases the size of an array. By default, this function doubles the size of the array, but the optional newSize parameter provides precise control over the increase in size.

        When using an array of objects, the data returned from the function must be cast to the object array's data type. For example: SomeClass[] items = (SomeClass[]) expand(originalArray). ( end auto-generated )
        Parameters:
        list - the array to expand
        See Also:
        shorten(boolean[])
      • expand

        public static boolean[] expand​(boolean[] list,
                                       int newSize)
        Parameters:
        newSize - new size for the array
      • 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 long[] expand​(long[] list)
      • expand

        public static long[] expand​(long[] list,
                                    int newSize)
      • expand

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

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

        public static double[] expand​(double[] list)
      • expand

        public static double[] expand​(double[] list,
                                      int newSize)
      • expand

        public static String[] expand​(String[] list,
                                      int newSize)
      • expand

        public static Object expand​(Object list,
                                    int newSize)
      • append

        public static byte[] append​(byte[] array,
                                    byte value)
        ( begin auto-generated from append.xml ) Expands an array by one element and adds data to the new position. The datatype of the element parameter must be the same as the datatype of the array.

        When using an array of objects, the data returned from the function must be cast to the object array's data type. For example: SomeClass[] items = (SomeClass[]) append(originalArray, element). ( end auto-generated )
        Parameters:
        array - array to append
        value - new data for the array
        See Also:
        shorten(boolean[]), expand(boolean[])
      • append

        public static char[] append​(char[] array,
                                    char value)
      • append

        public static int[] append​(int[] array,
                                   int value)
      • append

        public static float[] append​(float[] array,
                                     float value)
      • shorten

        public static boolean[] shorten​(boolean[] list)
        ( begin auto-generated from shorten.xml ) Decreases an array by one element and returns the shortened array.

        When using an array of objects, the data returned from the function must be cast to the object array's data type. For example: SomeClass[] items = (SomeClass[]) shorten(originalArray). ( end auto-generated )
        Parameters:
        list - array to shorten
        See Also:
        append(byte[], byte), expand(boolean[])
      • 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 String[] shorten​(String[] list)
      • splice

        public static final boolean[] splice​(boolean[] list,
                                             boolean value,
                                             int index)
        ( begin auto-generated from splice.xml ) Inserts a value or array of values into an existing array. The first two parameters must be of the same datatype. The array parameter defines the array which will be modified and the second parameter defines the data which will be inserted.

        When using an array of objects, the data returned from the function must be cast to the object array's data type. For example: SomeClass[] items = (SomeClass[]) splice(array1, array2, index). ( end auto-generated )
        Parameters:
        list - array to splice into
        value - value to be spliced in
        index - position in the array from which to insert data
        See Also:
        concat(boolean[], boolean[]), subset(boolean[], int, int)
      • splice

        public static final boolean[] splice​(boolean[] list,
                                             boolean[] value,
                                             int index)
      • splice

        public static final byte[] splice​(byte[] list,
                                          byte value,
                                          int index)
      • splice

        public static final byte[] splice​(byte[] list,
                                          byte[] value,
                                          int index)
      • splice

        public static final char[] splice​(char[] list,
                                          char value,
                                          int index)
      • splice

        public static final char[] splice​(char[] list,
                                          char[] value,
                                          int index)
      • splice

        public static final int[] splice​(int[] list,
                                         int value,
                                         int index)
      • splice

        public static final int[] splice​(int[] list,
                                         int[] value,
                                         int index)
      • splice

        public static final float[] splice​(float[] list,
                                           float value,
                                           int index)
      • splice

        public static final float[] splice​(float[] list,
                                           float[] value,
                                           int index)
      • splice

        public static final String[] splice​(String[] list,
                                            String value,
                                            int index)
      • splice

        public static final String[] splice​(String[] list,
                                            String[] value,
                                            int index)
      • subset

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

        public static boolean[] subset​(boolean[] list,
                                       int start,
                                       int count)
        ( begin auto-generated from subset.xml ) Extracts an array of elements from an existing array. The array parameter defines the array from which the elements will be copied and the offset and length parameters determine which elements to extract. If no length is given, elements will be extracted from the offset to the end of the array. When specifying the offset remember the first array element is 0. This function does not change the source array.

        When using an array of objects, the data returned from the function must be cast to the object array's data type. For example: SomeClass[] items = (SomeClass[]) subset(originalArray, 0, 4). ( end auto-generated )
        Parameters:
        list - array to extract from
        start - position to begin
        count - number of values to extract
        See Also:
        splice(boolean[], boolean, int)
      • 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 long[] subset​(long[] list,
                                    int start)
      • subset

        public static long[] subset​(long[] 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 double[] subset​(double[] list,
                                      int start)
      • subset

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

        public static String[] subset​(String[] list,
                                      int start)
      • subset

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

        public static Object subset​(Object list,
                                    int start)
      • subset

        public static Object subset​(Object list,
                                    int start,
                                    int count)
      • concat

        public static boolean[] concat​(boolean[] a,
                                       boolean[] b)
        ( begin auto-generated from concat.xml ) Concatenates two arrays. For example, concatenating the array { 1, 2, 3 } and the array { 4, 5, 6 } yields { 1, 2, 3, 4, 5, 6 }. Both parameters must be arrays of the same datatype.

        When using an array of objects, the data returned from the function must be cast to the object array's data type. For example: SomeClass[] items = (SomeClass[]) concat(array1, array2). ( end auto-generated )
        Parameters:
        a - first array to concatenate
        b - second array to concatenate
        See Also:
        splice(boolean[], boolean, int), arrayCopy(Object, int, Object, int, int)
      • 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)
      • reverse

        public static boolean[] reverse​(boolean[] list)
        ( begin auto-generated from reverse.xml ) Reverses the order of an array. ( end auto-generated )
        Parameters:
        list - booleans[], bytes[], chars[], ints[], floats[], or Strings[]
        See Also:
        sort(String[], int)
      • 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 String[] reverse​(String[] list)
      • trim

        public static String trim​(String str)
        ( begin auto-generated from trim.xml ) Removes whitespace characters from the beginning and end of a String. In addition to standard whitespace characters such as space, carriage return, and tab, this function also removes the Unicode "nbsp" character. ( end auto-generated )
        Parameters:
        str - any string
        See Also:
        split(String, String), join(String[], char)
      • trim

        public static String[] trim​(String[] array)
        Parameters:
        array - a String array
      • join

        public static String join​(String[] list,
                                  char separator)
        ( begin auto-generated from join.xml ) Combines an array of Strings into one String, each separated by the character(s) used for the separator parameter. To join arrays of ints or floats, it's necessary to first convert them to strings using nf() or nfs(). ( end auto-generated )
        Parameters:
        list - array of Strings
        separator - char or String to be placed between each item
        See Also:
        split(String, String), trim(String), nf(float, int, int), nfs(float, int, int)
      • splitTokens

        public static String[] splitTokens​(String value)
      • splitTokens

        public static String[] splitTokens​(String value,
                                           String delim)
        ( begin auto-generated from splitTokens.xml ) The splitTokens() function splits a String at one or many character "tokens." The tokens parameter specifies the character or characters to be used as a boundary.

        If no tokens character is specified, any whitespace character is used to split. Whitespace characters include tab (\\t), line feed (\\n), carriage return (\\r), form feed (\\f), and space. To convert a String to an array of integers or floats, use the datatype conversion functions int() and float() to convert the array of Strings. ( end auto-generated )
        Parameters:
        value - the String to be split
        delim - list of individual characters that will be used as separators
        See Also:
        split(String, String), join(String[], String), trim(String)
      • split

        public static String[] split​(String value,
                                     char delim)
        ( begin auto-generated from split.xml ) The split() function breaks a string into pieces using a character or string as the divider. The delim parameter specifies the character or characters that mark the boundaries between each piece. A String[] array is returned that contains each of the pieces.

        If the result is a set of numbers, you can convert the String[] array to to a float[] or int[] array using the datatype conversion functions int() and float() (see example above).

        The splitTokens() function works in a similar fashion, except that it splits using a range of characters instead of a specific character or sequence. ( end auto-generated )
        Parameters:
        value - the String to be split
        delim - the character or String used to separate the data
      • match

        public static String[] match​(String str,
                                     String regexp)
        ( begin auto-generated from match.xml ) The match() function is used to apply a regular expression to a piece of text, and return matching groups (elements found inside parentheses) as a String array. No match will return null. If no groups are specified in the regexp, but the sequence matches, an array of length one (with the matched text as the first element of the array) will be returned.

        To use the function, first check to see if the result is null. If the result is null, then the sequence did not match. If the sequence did match, an array is returned. If there are groups (specified by sets of parentheses) in the regexp, then the contents of each will be returned in the array. Element [0] of a regexp match returns the entire matching string, and the match groups start at element [1] (the first group is [1], the second [2], and so on).

        The syntax can be found in the reference for Java's Pattern class. For regular expression syntax, read the Java Tutorial on the topic. ( end auto-generated )
        Parameters:
        str - the String to be searched
        regexp - the regexp to be used for matching
        See Also:
        matchAll(String, String), split(String, String), splitTokens(String, String), join(String[], String), trim(String)
      • matchAll

        public static String[][] matchAll​(String str,
                                          String regexp)
        ( begin auto-generated from matchAll.xml ) This function is used to apply a regular expression to a piece of text, and return a list of matching groups (elements found inside parentheses) as a two-dimensional String array. No matches will return null. If no groups are specified in the regexp, but the sequence matches, a two dimensional array is still returned, but the second dimension is only of length one.

        To use the function, first check to see if the result is null. If the result is null, then the sequence did not match at all. If the sequence did match, a 2D array is returned. If there are groups (specified by sets of parentheses) in the regexp, then the contents of each will be returned in the array. Assuming, a loop with counter variable i, element [i][0] of a regexp match returns the entire matching string, and the match groups start at element [i][1] (the first group is [i][1], the second [i][2], and so on).

        The syntax can be found in the reference for Java's Pattern class. For regular expression syntax, read the Java Tutorial on the topic. ( end auto-generated )
        Parameters:
        str - the String to be searched
        regexp - the regexp to be used for matching
        See Also:
        match(String, String), split(String, String), splitTokens(String, String), join(String[], String), trim(String)
      • 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​(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​(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​(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​(String what)
        Parse a String into an int value. Returns 0 if the value is bad.
      • parseInt

        public static final int parseInt​(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​(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​(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​(String what)
      • parseFloat

        public static final float parseFloat​(String what,
                                             float otherwise)
      • parseFloat

        public static final float[] parseFloat​(byte[] what)
      • parseFloat

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

        public static final float[] parseFloat​(String[] what)
      • parseFloat

        public static final float[] parseFloat​(String[] what,
                                               float missing)
      • str

        public static final String str​(boolean x)
      • str

        public static final String str​(byte x)
      • str

        public static final String str​(char x)
      • str

        public static final String str​(int x)
      • str

        public static final String str​(float x)
      • str

        public static final String[] str​(boolean[] x)
      • str

        public static final String[] str​(byte[] x)
      • str

        public static final String[] str​(char[] x)
      • str

        public static final String[] str​(int[] x)
      • str

        public static final String[] str​(float[] x)
      • nf

        public static String nf​(float num)
      • nf

        public static String[] nf​(float[] nums)
      • nf

        public static String[] nf​(int[] nums,
                                  int digits)
        ( begin auto-generated from nf.xml ) Utility function for formatting numbers into strings. There are two versions, one for formatting floats and one for formatting ints. The values for the digits, left, and right parameters should always be positive integers.

        As shown in the above example, nf() is used to add zeros to the left and/or right of a number. This is typically for aligning a list of numbers. To remove digits from a floating-point number, use the int(), ceil(), floor(), or round() functions. ( end auto-generated )
        Parameters:
        nums - the numbers to format
        digits - number of digits to pad with zero
        See Also:
        nfs(float, int, int), nfp(float, int, int), nfc(float, int), int(float)
      • nf

        public static String nf​(int num,
                                int digits)
        Parameters:
        num - the number to format
      • nfc

        public static String[] nfc​(int[] nums)
        ( begin auto-generated from nfc.xml ) Utility function for formatting numbers into strings and placing appropriate commas to mark units of 1000. There are two versions, one for formatting ints and one for formatting an array of ints. The value for the digits parameter should always be a positive integer.

        For a non-US locale, this will insert periods instead of commas, or whatever is apprioriate for that region. ( end auto-generated )
        Parameters:
        nums - the numbers to format
        See Also:
        nf(float, int, int), nfp(float, int, int), nfs(float, int, int)
      • nfc

        public static String nfc​(int num)
        Parameters:
        num - the number to format
      • nfs

        public static String nfs​(int num,
                                 int digits)
        ( begin auto-generated from nfs.xml ) Utility function for formatting numbers into strings. Similar to nf() but leaves a blank space in front of positive numbers so they align with negative numbers in spite of the minus symbol. There are two versions, one for formatting floats and one for formatting ints. The values for the digits, left, and right parameters should always be positive integers. ( end auto-generated )
        Parameters:
        num - the number to format
        digits - number of digits to pad with zeroes
        See Also:
        nf(float, int, int), nfp(float, int, int), nfc(float, int)
      • nfs

        public static String[] nfs​(int[] nums,
                                   int digits)
        Parameters:
        nums - the numbers to format
      • nfp

        public static String nfp​(int num,
                                 int digits)
        ( begin auto-generated from nfp.xml ) Utility function for formatting numbers into strings. Similar to nf() but puts a "+" in front of positive numbers and a "-" in front of negative numbers. There are two versions, one for formatting floats and one for formatting ints. The values for the digits, left, and right parameters should always be positive integers. ( end auto-generated )
        Parameters:
        num - the number to format
        digits - number of digits to pad with zeroes
        See Also:
        nf(float, int, int), nfs(float, int, int), nfc(float, int)
      • nfp

        public static String[] nfp​(int[] nums,
                                   int digits)
        Parameters:
        nums - the numbers to format
      • nf

        public static String[] nf​(float[] nums,
                                  int left,
                                  int right)
        Parameters:
        left - number of digits to the left of the decimal point
        right - number of digits to the right of the decimal point
      • nf

        public static String nf​(float num,
                                int left,
                                int right)
      • nfc

        public static String[] nfc​(float[] nums,
                                   int right)
        Parameters:
        right - number of digits to the right of the decimal point
      • nfc

        public static String nfc​(float num,
                                 int right)
      • nfs

        public static String[] nfs​(float[] nums,
                                   int left,
                                   int right)
        Parameters:
        left - the number of digits to the left of the decimal point
        right - the number of digits to the right of the decimal point
      • nfs

        public static String nfs​(float num,
                                 int left,
                                 int right)
      • nfp

        public static String[] nfp​(float[] nums,
                                   int left,
                                   int right)
        Parameters:
        left - the number of digits to the left of the decimal point
        right - the number of digits to the right of the decimal point
      • nfp

        public static String nfp​(float num,
                                 int left,
                                 int right)
      • hex

        public static final String hex​(byte value)
        ( begin auto-generated from hex.xml ) Converts a byte, char, int, or color to a String containing the equivalent hexadecimal notation. For example color(0, 102, 153) will convert to the String "FF006699". This function can help make your geeky debugging sessions much happier.

        Note that the maximum number of digits is 8, because an int value can only represent up to 32 bits. Specifying more than eight digits will simply shorten the string to eight anyway. ( end auto-generated )
        Parameters:
        value - the value to convert
        See Also:
        unhex(String), binary(byte), unbinary(String)
      • hex

        public static final String hex​(char value)
      • hex

        public static final String hex​(int value)
      • hex

        public static final String hex​(int value,
                                       int digits)
        Parameters:
        digits - the number of digits (maximum 8)
      • unhex

        public static final int unhex​(String value)
        ( begin auto-generated from unhex.xml ) Converts a String representation of a hexadecimal number to its equivalent integer value. ( end auto-generated )
        Parameters:
        value - String to convert to an integer
        See Also:
        hex(int, int), binary(byte), unbinary(String)
      • binary

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

        public static final String binary​(char value)
        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 String binary​(int value)
        Returns a String that contains the binary value of an int. The length depends on the size of the number itself. If you want a specific number of digits use binary(int what, int digits) to specify how many.
      • binary

        public static final String binary​(int value,
                                          int digits)
        ( begin auto-generated from binary.xml ) Converts a byte, char, int, or color to a String containing the equivalent binary notation. For example color(0, 102, 153, 255) will convert to the String "11111111000000000110011010011001". This function can help make your geeky debugging sessions much happier.

        Note that the maximum number of digits is 32, because an int value can only represent up to 32 bits. Specifying more than 32 digits will simply shorten the string to 32 anyway. ( end auto-generated )
        Parameters:
        value - value to convert
        digits - number of digits to return
        See Also:
        unbinary(String), hex(int,int), unhex(String)
      • unbinary

        public static final int unbinary​(String value)
        ( begin auto-generated from unbinary.xml ) Converts a String representation of a binary number to its equivalent integer value. For example, unbinary("00001000") will return 8. ( end auto-generated )
        Parameters:
        value - String to convert to an integer
        See Also:
        binary(byte), hex(int,int), unhex(String)
      • color

        public final int color​(int gray)
        ( begin auto-generated from color.xml ) Creates colors for storing in variables of the color datatype. The parameters are interpreted as RGB or HSB values depending on the current colorMode(). The default mode is RGB values from 0 to 255 and therefore, the function call color(255, 204, 0) will return a bright yellow color. More about how colors are stored can be found in the reference for the color datatype. ( end auto-generated )
        Parameters:
        gray - number specifying value between white and black
        See Also:
        colorMode(int)
      • color

        public final int color​(float fgray)
        Parameters:
        fgray - number specifying value between white and black
      • color

        public final int color​(int gray,
                               int alpha)
        As of 0116 this also takes color(#FF8800, alpha)
        Parameters:
        alpha - relative to current color range
      • color

        public final int color​(float fgray,
                               float falpha)
      • color

        public final int color​(int v1,
                               int v2,
                               int v3)
        Parameters:
        v1 - red or hue values relative to the current color range
        v2 - green or saturation values relative to the current color range
        v3 - blue or brightness values relative to the current color range
      • color

        public final int color​(int v1,
                               int v2,
                               int v3,
                               int alpha)
      • color

        public final int color​(float v1,
                               float v2,
                               float v3)
      • color

        public final int color​(float v1,
                               float v2,
                               float v3,
                               float alpha)
      • lerpColor

        public int lerpColor​(int c1,
                             int c2,
                             float amt)
        ( begin auto-generated from lerpColor.xml ) Calculates a color or colors between two color at a specific increment. The amt parameter is the amount to interpolate between the two values where 0.0 equal to the first point, 0.1 is very near the first point, 0.5 is half-way in between, etc. ( end auto-generated )
        Parameters:
        c1 - interpolate from this color
        c2 - interpolate to this color
        amt - between 0.0 and 1.0
        See Also:
        PImage.blendColor(int, int, int), PGraphics.color(float, float, float, float), lerp(float, float, float)
      • blendColor

        public static int blendColor​(int c1,
                                     int c2,
                                     int mode)
      • frameMoved

        public void frameMoved​(int x,
                               int y)
      • frameResized

        public void frameResized​(int w,
                                 int h)
      • main

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

        Usage: PApplet [options] <class name> [sketch args]

        • The [options] are one or several of the parameters seen below.
        • The class name is required. If you're running outside the PDE and your class is in a package, this should include the full name. That means that if the class is called Sketchy and the package is com.sketchycompany then com.sketchycompany.Sketchy should be used as the class name.
        • The [sketch args] are any command line parameters you want to send to the sketch itself. These will be passed into the args[] array in PApplet.

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

          static public void main(String args[]) {
             PApplet.main("YourSketchName");
           }
          That will properly launch your code 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              Presentation mode: blanks the entire screen and
                                  shows the sketch by itself. If the sketch is
                                  smaller than the screen, the background around it
                                  will use the --window-color setting.
          
           --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.
          
           --window-color=#xxxxxx Background color of the window. The color used
                                  around the sketch when it's smaller than the
                                  minimum window size for the OS, and the matte
                                  color when using 'present' mode.
          
           --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 sketch.
                                  Displays are numbered starting from 1. This will
                                  be overridden by fullScreen() calls that specify
                                  a display. Omitting this option will cause the
                                  default display to be used.
          
           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
          
           All parameters *after* the sketch class name are passed to the sketch
           itself and available from its 'args' array while the sketch is running.
        See Also:
        args
      • main

        public static void main​(Class<?> mainClass,
                                String... args)
        Convenience method so that PApplet.main(YourSketch.class) launches a sketch, rather than having to call getName() on it.
      • main

        public static void main​(String mainClass)
        Convenience method so that PApplet.main("YourSketch") launches a sketch, rather than having to wrap it into a single element String array.
        Parameters:
        mainClass - name of the class to load (with package if any)
      • main

        public static void main​(String mainClass,
                                String[] sketchArgs)
        Convenience method so that PApplet.main("YourSketch", args) launches a sketch, rather than having to wrap it into a String array, and appending the 'args' array when not null.
        Parameters:
        mainClass - name of the class to load (with package if any)
        sketchArgs - command line arguments to pass to the sketch's 'args' array. Note that this is not the same as the args passed to (and understood by) PApplet such as --display.
      • main

        public static void main​(PApplet sketch,
                                String... sketchArgs)
        Run the provided sketch.
        Parameters:
        sketch - sketch to run
        sketchArgs - optional additional arguments
      • runSketch

        public static void runSketch​(String[] args,
                                     PApplet constructedSketch)
      • showSurface

        protected void showSurface()
        Danger: available for advanced subclassing, but here be dragons.
      • startSurface

        protected void startSurface()
        See warning in showSurface()
      • initSurface

        protected PSurface initSurface()
      • hideMenuBar

        public static void hideMenuBar()
      • runSketch

        protected void runSketch​(String[] args)
        Convenience method for Python Mode to run an already-constructed sketch. This makes it makes it easy to launch a sketch in Jython:
        class MySketch(PApplet):
             pass
        
        MySketch().runSketch();
      • runSketch

        protected void runSketch()
        Convenience method for Python Mode
      • beginRecord

        public PGraphics beginRecord​(String renderer,
                                     String filename)
        ( begin auto-generated from beginRecord.xml ) Opens a new file and all subsequent drawing functions are echoed to this file as well as the display window. The beginRecord() function requires two parameters, the first is the renderer and the second is the file name. This function is always used with endRecord() to stop the recording process and close the file.

        Note that beginRecord() will only pick up any settings that happen after it has been called. For instance, if you call textFont() before beginRecord(), then that font will not be set for the file that you're recording to. ( end auto-generated )
        Parameters:
        renderer - PDF or SVG
        filename - filename for output
        See Also:
        endRecord()
      • beginRecord

        public void beginRecord​(PGraphics recorder)
      • endRecord

        public void endRecord()
        ( begin auto-generated from endRecord.xml ) Stops the recording process started by beginRecord() and closes the file. ( end auto-generated )
        See Also:
        beginRecord(String, String)
      • beginRaw

        public PGraphics beginRaw​(String renderer,
                                  String filename)
        ( begin auto-generated from beginRaw.xml ) To create vectors from 3D data, use the beginRaw() and endRaw() commands. These commands will grab the shape data just before it is rendered to the screen. At this stage, your entire scene is nothing but a long list of individual lines and triangles. This means that a shape created with sphere() function will be made up of hundreds of triangles, rather than a single object. Or that a multi-segment line shape (such as a curve) will be rendered as individual segments.

        When using beginRaw() and endRaw(), it's possible to write to either a 2D or 3D renderer. For instance, beginRaw() with the PDF library will write the geometry as flattened triangles and lines, even if recording from the P3D renderer.

        If you want a background to show up in your files, use rect(0, 0, width, height) after setting the fill() to the background color. Otherwise the background will not be rendered to the file because the background is not shape.

        Using hint(ENABLE_DEPTH_SORT) can improve the appearance of 3D geometry drawn to 2D file formats. See the hint() reference for more details.

        See examples in the reference for the PDF and DXF libraries for more information. ( end auto-generated )
        Parameters:
        renderer - for example, PDF or DXF
        filename - filename for output
        See Also:
        endRaw(), hint(int)
      • beginRaw

        public void beginRaw​(PGraphics rawGraphics)
        Parameters:
        rawGraphics - ???
      • endRaw

        public void endRaw()
        ( begin auto-generated from endRaw.xml ) Complement to beginRaw(); they must always be used together. See the beginRaw() reference for details. ( end auto-generated )
        See Also:
        beginRaw(String, String)
      • loadPixels

        public void loadPixels()
        ( begin auto-generated from loadPixels.xml ) Loads the pixel data for the display window into the pixels[] array. This function must always be called before reading from or writing to pixels[].

        renderers may or may not seem to require loadPixels() or updatePixels(). However, the rule is that any time you want to manipulate the pixels[] array, you must first call loadPixels(), and after changes have been made, call updatePixels(). Even if the renderer may not seem to use this function in the current Processing release, this will always be subject to change. ( end auto-generated )

        Advanced

        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[].
        See Also:
        pixels, updatePixels()
      • updatePixels

        public void updatePixels()
        ( begin auto-generated from updatePixels.xml ) Updates the display window with the data in the pixels[] array. Use in conjunction with loadPixels(). If you're only reading pixels from the array, there's no need to call updatePixels() unless there are changes.

        renderers may or may not seem to require loadPixels() or updatePixels(). However, the rule is that any time you want to manipulate the pixels[] array, you must first call loadPixels(), and after changes have been made, call updatePixels(). Even if the renderer may not seem to use this function in the current Processing release, this will always be subject to change.

        Currently, none of the renderers use the additional parameters to updatePixels(), however this may be implemented in the future. ( end auto-generated )
        See Also:
        loadPixels(), pixels
      • updatePixels

        public void updatePixels​(int x1,
                                 int y1,
                                 int x2,
                                 int y2)
        Parameters:
        x1 - x-coordinate of the upper-left corner
        y1 - y-coordinate of the upper-left corner
        x2 - width of the region
        y2 - height of the region
      • beginPGL

        public PGL beginPGL()
      • endPGL

        public void endPGL()
      • flush

        public void flush()
      • hint

        public void hint​(int which)
      • beginShape

        public void beginShape()
        Start a new shape of type POLYGON
      • beginShape

        public void beginShape​(int kind)
        ( begin auto-generated from beginShape.xml ) Using the beginShape() and endShape() functions allow creating more complex forms. beginShape() begins recording vertices for a shape and endShape() stops recording. The value of the MODE parameter tells it which types of shapes to create from the provided vertices. With no mode specified, the shape can be any irregular polygon. The parameters available for beginShape() are POINTS, LINES, TRIANGLES, TRIANGLE_FAN, TRIANGLE_STRIP, QUADS, and QUAD_STRIP. After calling the beginShape() function, a series of vertex() commands must follow. To stop drawing the shape, call endShape(). The vertex() function with two parameters specifies a position in 2D and the vertex() function with three parameters specifies a position in 3D. Each shape will be outlined with the current stroke color and filled with the fill color.

        Transformations such as translate(), rotate(), and scale() do not work within beginShape(). It is also not possible to use other shapes, such as ellipse() or rect() within beginShape().

        The P3D renderer settings allow stroke() and fill() settings to be altered per-vertex, however the default P2D renderer does not. Settings such as strokeWeight(), strokeCap(), and strokeJoin() cannot be changed while inside a beginShape()/endShape() block with any renderer. ( end auto-generated )
        Parameters:
        kind - Either POINTS, LINES, TRIANGLES, TRIANGLE_FAN, TRIANGLE_STRIP, QUADS, or QUAD_STRIP
        See Also:
        PShape, PGraphics.endShape(), PGraphics.vertex(float, float, float, float, float), PGraphics.curveVertex(float, float, float), PGraphics.bezierVertex(float, float, float, float, float, float, float, float, float)
      • edge

        public void edge​(boolean edge)
        Sets whether the upcoming vertex is part of an edge. Equivalent to glEdgeFlag(), for people familiar with OpenGL.
      • normal

        public void normal​(float nx,
                           float ny,
                           float nz)
        ( begin auto-generated from normal.xml ) Sets the current normal vector. This is for drawing three dimensional shapes and surfaces and specifies a vector perpendicular to the surface of the shape which determines how lighting affects it. Processing attempts to automatically assign normals to shapes, but since that's imperfect, this is a better option when you want more control. This function is identical to glNormal3f() in OpenGL. ( end auto-generated )
        Parameters:
        nx - x direction
        ny - y direction
        nz - z direction
        See Also:
        PGraphics.beginShape(int), PGraphics.endShape(int), PGraphics.lights()
      • attribPosition

        public void attribPosition​(String name,
                                   float x,
                                   float y,
                                   float z)
      • attribNormal

        public void attribNormal​(String name,
                                 float nx,
                                 float ny,
                                 float nz)
      • attribColor

        public void attribColor​(String name,
                                int color)
      • attrib

        public void attrib​(String name,
                           float... values)
      • attrib

        public void attrib​(String name,
                           int... values)
      • attrib

        public void attrib​(String name,
                           boolean... values)
      • textureMode

        public void textureMode​(int mode)
        ( begin auto-generated from textureMode.xml ) Sets the coordinate space for texture mapping. There are two options, IMAGE, which refers to the actual coordinates of the image, and NORMAL, which refers to a normalized space of values ranging from 0 to 1. The default mode is IMAGE. In IMAGE, if an image is 100 x 200 pixels, mapping the image onto the entire size of a quad would require the points (0,0) (0,100) (100,200) (0,200). The same mapping in NORMAL_SPACE is (0,0) (0,1) (1,1) (0,1). ( end auto-generated )
        Parameters:
        mode - either IMAGE or NORMAL
        See Also:
        PGraphics.texture(PImage), PGraphics.textureWrap(int)
      • textureWrap

        public void textureWrap​(int wrap)
        ( begin auto-generated from textureWrap.xml ) Description to come... ( end auto-generated from textureWrap.xml )
        Parameters:
        wrap - Either CLAMP (default) or REPEAT
        See Also:
        PGraphics.texture(PImage), PGraphics.textureMode(int)
      • noTexture

        public void noTexture()
        Removes texture image for current shape. Needs to be called between beginShape and endShape
      • vertex

        public void vertex​(float x,
                           float y)
      • vertex

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

        public void vertex​(float[] v)
        Used by renderer subclasses or PShape to efficiently pass in already formatted vertex information.
        Parameters:
        v - vertex parameters, as a float array of length VERTEX_FIELD_COUNT
      • 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)
        ( begin auto-generated from vertex.xml ) All shapes are constructed by connecting a series of vertices. vertex() is used to specify the vertex coordinates for points, lines, triangles, quads, and polygons and is used exclusively within the beginShape() and endShape() function.

        Drawing a vertex in 3D using the z parameter requires the P3D parameter in combination with size as shown in the above example.

        This function is also used to map a texture onto the geometry. The texture() function declares the texture to apply to the geometry and the u and v coordinates set define the mapping of this texture to the form. By default, the coordinates used for u and v are specified in relation to the image's size in pixels, but this relation can be changed with textureMode(). ( end auto-generated )
        Parameters:
        x - x-coordinate of the vertex
        y - y-coordinate of the vertex
        z - z-coordinate of the vertex
        u - horizontal coordinate for the texture mapping
        v - vertical coordinate for the texture mapping
        See Also:
        PGraphics.beginShape(int), PGraphics.endShape(int), PGraphics.bezierVertex(float, float, float, float, float, float, float, float, float), PGraphics.quadraticVertex(float, float, float, float, float, float), PGraphics.curveVertex(float, float, float), PGraphics.texture(PImage)
      • beginContour

        public void beginContour()
      • endContour

        public void endContour()
      • endShape

        public void endShape()
      • endShape

        public void endShape​(int mode)
        ( begin auto-generated from endShape.xml ) The endShape() function is the companion to beginShape() and may only be called after beginShape(). When endshape() is called, all of image data defined since the previous call to beginShape() is written into the image buffer. The constant CLOSE as the value for the MODE parameter to close the shape (to connect the beginning and the end). ( end auto-generated )
        Parameters:
        mode - use CLOSE to close the shape
        See Also:
        PShape, PGraphics.beginShape(int)
      • loadShape

        public PShape loadShape​(String filename)
        Parameters:
        filename - name of file to load, can be .svg or .obj
        See Also:
        PShape, createShape()
      • createShape

        public PShape createShape​(int type)
      • createShape

        public PShape createShape​(int kind,
                                  float... p)
        Parameters:
        kind - either POINT, LINE, TRIANGLE, QUAD, RECT, ELLIPSE, ARC, BOX, SPHERE
        p - parameters that match the kind of shape
      • loadShader

        public PShader loadShader​(String fragFilename)
        ( begin auto-generated from loadShader.xml ) This is a new reference entry for Processing 2.0. It will be updated shortly. ( end auto-generated )
        Parameters:
        fragFilename - name of fragment shader file
      • loadShader

        public PShader loadShader​(String fragFilename,
                                  String vertFilename)
        Parameters:
        vertFilename - name of vertex shader file
      • shader

        public void shader​(PShader shader)
        ( begin auto-generated from shader.xml ) This is a new reference entry for Processing 2.0. It will be updated shortly. ( end auto-generated )
        Parameters:
        shader - name of shader file
      • shader

        public void shader​(PShader shader,
                           int kind)
        Parameters:
        kind - type of shader, either POINTS, LINES, or TRIANGLES
      • resetShader

        public void resetShader()
        ( begin auto-generated from resetShader.xml ) This is a new reference entry for Processing 2.0. It will be updated shortly. ( end auto-generated )
      • resetShader

        public void resetShader​(int kind)
        Parameters:
        kind - type of shader, either POINTS, LINES, or TRIANGLES
      • filter

        public void filter​(PShader shader)
        Parameters:
        shader - the fragment shader to apply
      • clip

        public void clip​(float a,
                         float b,
                         float c,
                         float d)
        ( begin auto-generated from clip.xml ) Limits the rendering to the boundaries of a rectangle defined by the parameters. The boundaries are drawn based on the state of the imageMode() fuction, either CORNER, CORNERS, or CENTER. ( end auto-generated )
        Parameters:
        a - x-coordinate of the rectangle, by default
        b - y-coordinate of the rectangle, by default
        c - width of the rectangle, by default
        d - height of the rectangle, by default
      • noClip

        public void noClip()
        ( begin auto-generated from noClip.xml ) Disables the clipping previously started by the clip() function. ( end auto-generated )
      • blendMode

        public void blendMode​(int mode)
        ( begin auto-generated from blendMode.xml ) This is a new reference entry for Processing 2.0. It will be updated shortly. ( end auto-generated )
        Parameters:
        mode - the blending mode to use
      • 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)
        ( begin auto-generated from bezierVertex.xml ) Specifies vertex coordinates for Bezier curves. Each call to bezierVertex() defines the position of two control points and one anchor point of a Bezier curve, adding a new segment to a line or shape. The first time bezierVertex() is used within a beginShape() call, it must be prefaced with a call to vertex() to set the first anchor point. This function must be used between beginShape() and endShape() and only when there is no MODE parameter specified to beginShape(). Using the 3D version requires rendering with P3D (see the Environment reference for more information). ( end auto-generated )
        Parameters:
        x2 - the x-coordinate of the 1st control point
        y2 - the y-coordinate of the 1st control point
        z2 - the z-coordinate of the 1st control point
        x3 - the x-coordinate of the 2nd control point
        y3 - the y-coordinate of the 2nd control point
        z3 - the z-coordinate of the 2nd control point
        x4 - the x-coordinate of the anchor point
        y4 - the y-coordinate of the anchor point
        z4 - the z-coordinate of the anchor point
        See Also:
        PGraphics.curveVertex(float, float, float), PGraphics.vertex(float, float, float, float, float), PGraphics.quadraticVertex(float, float, float, float, float, float), PGraphics.bezier(float, float, float, float, float, float, float, float, float, float, float, float)
      • quadraticVertex

        public void quadraticVertex​(float cx,
                                    float cy,
                                    float cz,
                                    float x3,
                                    float y3,
                                    float z3)
        Parameters:
        cz - the z-coordinate of the control point
        z3 - the z-coordinate of the anchor point
      • curveVertex

        public void curveVertex​(float x,
                                float y,
                                float z)
        Parameters:
        z - the z-coordinate of the vertex
      • point

        public void point​(float x,
                          float y)
        ( begin auto-generated from point.xml ) Draws a point, a coordinate in space at the dimension of one pixel. The first parameter is the horizontal value for the point, the second value is the vertical value for the point, and the optional third value is the depth value. Drawing this shape in 3D with the z parameter requires the P3D parameter in combination with size() as shown in the above example. ( end auto-generated )
        Parameters:
        x - x-coordinate of the point
        y - y-coordinate of the point
        See Also:
        PGraphics.stroke(int)
      • point

        public void point​(float x,
                          float y,
                          float z)
        Parameters:
        z - z-coordinate of the point
      • line

        public void line​(float x1,
                         float y1,
                         float x2,
                         float y2)
        ( begin auto-generated from line.xml ) Draws a line (a direct path between two points) to the screen. The version of line() with four parameters draws the line in 2D. To color a line, use the stroke() function. A line cannot be filled, therefore the fill() function will not affect the color of a line. 2D lines are drawn with a width of one pixel by default, but this can be changed with the strokeWeight() function. The version with six parameters allows the line to be placed anywhere within XYZ space. Drawing this shape in 3D with the z parameter requires the P3D parameter in combination with size() as shown in the above example. ( end auto-generated )
        Parameters:
        x1 - x-coordinate of the first point
        y1 - y-coordinate of the first point
        x2 - x-coordinate of the second point
        y2 - y-coordinate of the second point
        See Also:
        PGraphics.strokeWeight(float), PGraphics.strokeJoin(int), PGraphics.strokeCap(int), PGraphics.beginShape()
      • line

        public void line​(float x1,
                         float y1,
                         float z1,
                         float x2,
                         float y2,
                         float z2)
        Parameters:
        z1 - z-coordinate of the first point
        z2 - z-coordinate of the second point
      • triangle

        public void triangle​(float x1,
                             float y1,
                             float x2,
                             float y2,
                             float x3,
                             float y3)
        ( begin auto-generated from triangle.xml ) A triangle is a plane created by connecting three points. The first two arguments specify the first point, the middle two arguments specify the second point, and the last two arguments specify the third point. ( end auto-generated )
        Parameters:
        x1 - x-coordinate of the first point
        y1 - y-coordinate of the first point
        x2 - x-coordinate of the second point
        y2 - y-coordinate of the second point
        x3 - x-coordinate of the third point
        y3 - y-coordinate of the third point
        See Also:
        beginShape()
      • quad

        public void quad​(float x1,
                         float y1,
                         float x2,
                         float y2,
                         float x3,
                         float y3,
                         float x4,
                         float y4)
        ( begin auto-generated from quad.xml ) A quad is a quadrilateral, a four sided polygon. It is similar to a rectangle, but the angles between its edges are not constrained to ninety degrees. The first pair of parameters (x1,y1) sets the first vertex and the subsequent pairs should proceed clockwise or counter-clockwise around the defined shape. ( end auto-generated )
        Parameters:
        x1 - x-coordinate of the first corner
        y1 - y-coordinate of the first corner
        x2 - x-coordinate of the second corner
        y2 - y-coordinate of the second corner
        x3 - x-coordinate of the third corner
        y3 - y-coordinate of the third corner
        x4 - x-coordinate of the fourth corner
        y4 - y-coordinate of the fourth corner
      • rectMode

        public void rectMode​(int mode)
        ( begin auto-generated from rectMode.xml ) Modifies the location from which rectangles draw. The default mode is rectMode(CORNER), which specifies the location to be the upper left corner of the shape and uses the third and fourth parameters of rect() to specify the width and height. The syntax rectMode(CORNERS) uses the first and second parameters of rect() to set the location of one corner and uses the third and fourth parameters to set the opposite corner. The syntax rectMode(CENTER) draws the image from its center point and uses the third and forth parameters of rect() to specify the image's width and height. The syntax rectMode(RADIUS) draws the image from its center point and uses the third and forth parameters of rect() to specify half of the image's width and height. The parameter must be written in ALL CAPS because Processing is a case sensitive language. Note: In version 125, the mode named CENTER_RADIUS was shortened to RADIUS. ( end auto-generated )
        Parameters:
        mode - either CORNER, CORNERS, CENTER, or RADIUS
        See Also:
        PGraphics.rect(float, float, float, float)
      • rect

        public void rect​(float a,
                         float b,
                         float c,
                         float d)
        ( begin auto-generated from rect.xml ) Draws a rectangle to the screen. A rectangle is a four-sided shape with every angle at ninety degrees. By default, the first two parameters set the location of the upper-left corner, the third sets the width, and the fourth sets the height. These parameters may be changed with the rectMode() function. ( end auto-generated )
        Parameters:
        a - x-coordinate of the rectangle by default
        b - y-coordinate of the rectangle by default
        c - width of the rectangle by default
        d - height of the rectangle by default
        See Also:
        PGraphics.rectMode(int), PGraphics.quad(float, float, float, float, float, float, float, float)
      • rect

        public void rect​(float a,
                         float b,
                         float c,
                         float d,
                         float r)
        Parameters:
        r - radii for all four corners
      • rect

        public void rect​(float a,
                         float b,
                         float c,
                         float d,
                         float tl,
                         float tr,
                         float br,
                         float bl)
        Parameters:
        tl - radius for top-left corner
        tr - radius for top-right corner
        br - radius for bottom-right corner
        bl - radius for bottom-left corner
      • square

        public void square​(float x,
                           float y,
                           float extent)
        ( begin auto-generated from square.xml ) Draws a square to the screen. A square is a four-sided shape with every angle at ninety degrees and each side is the same length. By default, the first two parameters set the location of the upper-left corner, the third sets the width and height. The way these parameters are interpreted, however, may be changed with the rectMode() function. ( end auto-generated )
        Parameters:
        x - x-coordinate of the rectangle by default
        y - y-coordinate of the rectangle by default
        extent - width and height of the rectangle by default
        See Also:
        PGraphics.rect(float, float, float, float), PGraphics.rectMode(int)
      • ellipseMode

        public void ellipseMode​(int mode)
        ( begin auto-generated from ellipseMode.xml ) The origin of the ellipse is modified by the ellipseMode() function. The default configuration is ellipseMode(CENTER), which specifies the location of the ellipse as the center of the shape. The RADIUS mode is the same, but the width and height parameters to ellipse() specify the radius of the ellipse, rather than the diameter. The CORNER mode draws the shape from the upper-left corner of its bounding box. The CORNERS mode uses the four parameters to ellipse() to set two opposing corners of the ellipse's bounding box. The parameter must be written in ALL CAPS because Processing is a case-sensitive language. ( end auto-generated )
        Parameters:
        mode - either CENTER, RADIUS, CORNER, or CORNERS
        See Also:
        ellipse(float, float, float, float), arc(float, float, float, float, float, float)
      • ellipse

        public void ellipse​(float a,
                            float b,
                            float c,
                            float d)
        ( begin auto-generated from ellipse.xml ) Draws an ellipse (oval) in the display window. An ellipse with an equal width and height is a circle. The first two parameters set the location, the third sets the width, and the fourth sets the height. The origin may be changed with the ellipseMode() function. ( end auto-generated )
        Parameters:
        a - x-coordinate of the ellipse
        b - y-coordinate of the ellipse
        c - width of the ellipse by default
        d - height of the ellipse by default
        See Also:
        ellipseMode(int), arc(float, float, float, float, float, float)
      • arc

        public void arc​(float a,
                        float b,
                        float c,
                        float d,
                        float start,
                        float stop)
        ( begin auto-generated from arc.xml ) Draws an arc in the display window. Arcs are drawn along the outer edge of an ellipse defined by the x, y, width and height parameters. The origin or the arc's ellipse may be changed with the ellipseMode() function. The start and stop parameters specify the angles at which to draw the arc. ( end auto-generated )
        Parameters:
        a - x-coordinate of the arc's ellipse
        b - y-coordinate of the arc's ellipse
        c - width of the arc's ellipse by default
        d - height of the arc's ellipse by default
        start - angle to start the arc, specified in radians
        stop - angle to stop the arc, specified in radians
        See Also:
        ellipse(float, float, float, float), ellipseMode(int), radians(float), degrees(float)
      • arc

        public void arc​(float a,
                        float b,
                        float c,
                        float d,
                        float start,
                        float stop,
                        int mode)
      • circle

        public void circle​(float x,
                           float y,
                           float extent)
        ( begin auto-generated from circle.xml ) Draws a circle to the screen. By default, the first two parameters set the location of the center, and the third sets the shape's width and height. The origin may be changed with the ellipseMode() function. ( end auto-generated )
        Parameters:
        x - x-coordinate of the ellipse
        y - y-coordinate of the ellipse
        extent - width and height of the ellipse by default
        See Also:
        ellipse(float, float, float, float), ellipseMode(int)
      • box

        public void box​(float size)
        ( begin auto-generated from box.xml ) A box is an extruded rectangle. A box with equal dimension on all sides is a cube. ( end auto-generated )
        Parameters:
        size - dimension of the box in all dimensions (creates a cube)
        See Also:
        PGraphics.sphere(float)
      • box

        public void box​(float w,
                        float h,
                        float d)
        Parameters:
        w - dimension of the box in the x-dimension
        h - dimension of the box in the y-dimension
        d - dimension of the box in the z-dimension
      • sphereDetail

        public void sphereDetail​(int res)
        ( begin auto-generated from sphereDetail.xml ) Controls the detail used to render a sphere by adjusting the number of vertices of the sphere mesh. The default resolution is 30, which creates a fairly detailed sphere definition with vertices every 360/30 = 12 degrees. If you're going to render a great number of spheres per frame, it is advised to reduce the level of detail using this function. The setting stays active until sphereDetail() is called again with a new parameter and so should not be called prior to every sphere() statement, unless you wish to render spheres with different settings, e.g. using less detail for smaller spheres or ones further away from the camera. To control the detail of the horizontal and vertical resolution independently, use the version of the functions with two parameters. ( end auto-generated )

        Advanced

        Code for sphereDetail() submitted by toxi [031031]. Code for enhanced u/v version from davbol [080801].
        Parameters:
        res - number of segments (minimum 3) used per full circle revolution
        See Also:
        PGraphics.sphere(float)
      • sphereDetail

        public void sphereDetail​(int ures,
                                 int vres)
        Parameters:
        ures - number of segments used longitudinally per full circle revolutoin
        vres - number of segments used latitudinally from top to bottom
      • sphere

        public void sphere​(float r)
        ( begin auto-generated from sphere.xml ) A sphere is a hollow ball made from tessellated triangles. ( end auto-generated )

        Advanced

        Implementation notes:

        cache all the points of the sphere in a static array top and bottom are just a bunch of triangles that land in the center point

        sphere is a series of concentric circles who radii vary along the shape, based on, er.. cos or something

         [toxi 031031] new sphere code. removed all multiplies with
         radius, as scale() will take care of that anyway
        
         [toxi 031223] updated sphere code (removed modulos)
         and introduced sphereAt(x,y,z,r)
         to avoid additional translate()'s on the user/sketch side
        
         [davbol 080801] now using separate sphereDetailU/V
         
        Parameters:
        r - the radius of the sphere
        See Also:
        PGraphics.sphereDetail(int)
      • bezierPoint

        public float bezierPoint​(float a,
                                 float b,
                                 float c,
                                 float d,
                                 float t)
        ( begin auto-generated from bezierPoint.xml ) Evaluates the Bezier at point t for points a, b, c, d. The parameter t varies between 0 and 1, a and d are points on the curve, and b and c are the control points. This can be done once with the x coordinates and a second time with the y coordinates to get the location of a bezier curve at t. ( end auto-generated )

        Advanced

        For instance, to convert the following example:
         stroke(255, 102, 0);
         line(85, 20, 10, 10);
         line(90, 90, 15, 80);
         stroke(0, 0, 0);
         bezier(85, 20, 10, 10, 90, 90, 15, 80);
        
         // draw it in gray, using 10 steps instead of the default 20
         // this is a slower way to do it, but useful if you need
         // to do things with the coordinates at each step
         stroke(128);
         beginShape(LINE_STRIP);
         for (int i = 0; i <= 10; i++) {
           float t = i / 10.0f;
           float x = bezierPoint(85, 10, 90, 15, t);
           float y = bezierPoint(20, 10, 90, 80, t);
           vertex(x, y);
         }
         endShape();
        Parameters:
        a - coordinate of first point on the curve
        b - coordinate of first control point
        c - coordinate of second control point
        d - coordinate of second point on the curve
        t - value between 0 and 1
        See Also:
        PGraphics.bezier(float, float, float, float, float, float, float, float, float, float, float, float), PGraphics.bezierVertex(float, float, float, float, float, float), PGraphics.curvePoint(float, float, float, float, float)
      • 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)
        ( begin auto-generated from bezier.xml ) Draws a Bezier curve on the screen. These curves are defined by a series of anchor and control points. The first two parameters specify the first anchor point and the last two parameters specify the other anchor point. The middle parameters specify the control points which define the shape of the curve. Bezier curves were developed by French engineer Pierre Bezier. Using the 3D version requires rendering with P3D (see the Environment reference for more information). ( end auto-generated )

        Advanced

        Draw a cubic bezier curve. The first and last points are the on-curve points. The middle two are the 'control' points, or 'handles' in an application like Illustrator.

        Identical to typing:

        beginShape();
         vertex(x1, y1);
         bezierVertex(x2, y2, x3, y3, x4, y4);
         endShape();
         
        In Postscript-speak, this would be:
        moveto(x1, y1);
         curveto(x2, y2, x3, y3, x4, y4);
        If you were to try and continue that curve like so:
        curveto(x5, y5, x6, y6, x7, y7);
        This would be done in processing by adding these statements:
        bezierVertex(x5, y5, x6, y6, x7, y7)
         
        To draw a quadratic (instead of cubic) curve, use the control point twice by doubling it:
        bezier(x1, y1, cx, cy, cx, cy, x2, y2);
        Parameters:
        x1 - coordinates for the first anchor point
        y1 - coordinates for the first anchor point
        z1 - coordinates for the first anchor point
        x2 - coordinates for the first control point
        y2 - coordinates for the first control point
        z2 - coordinates for the first control point
        x3 - coordinates for the second control point
        y3 - coordinates for the second control point
        z3 - coordinates for the second control point
        x4 - coordinates for the second anchor point
        y4 - coordinates for the second anchor point
        z4 - coordinates for the second anchor point
        See Also:
        PGraphics.bezierVertex(float, float, float, float, float, float), PGraphics.curve(float, float, float, float, float, float, float, float, float, float, float, float)
      • curveTightness

        public void curveTightness​(float tightness)
        ( begin auto-generated from curveTightness.xml ) Modifies the quality of forms created with curve() and curveVertex(). The parameter squishy determines how the curve fits to the vertex points. The value 0.0 is the default value for squishy (this value defines the curves to be Catmull-Rom splines) and the value 1.0 connects all the points with straight lines. Values within the range -5.0 and 5.0 will deform the curves but will leave them recognizable and as values increase in magnitude, they will continue to deform. ( end auto-generated )
        Parameters:
        tightness - amount of deformation from the original vertices
        See Also:
        PGraphics.curve(float, float, float, float, float, float, float, float, float, float, float, float), PGraphics.curveVertex(float, float)
      • curve

        public void curve​(float x1,
                          float y1,
                          float x2,
                          float y2,
                          float x3,
                          float y3,
                          float x4,
                          float y4)
        ( begin auto-generated from curve.xml ) Draws a curved line on the screen. The first and second parameters specify the beginning control point and the last two parameters specify the ending control point. The middle parameters specify the start and stop of the curve. Longer curves can be created by putting a series of curve() functions together or using curveVertex(). An additional function called curveTightness() provides control for the visual quality of the curve. The curve() function is an implementation of Catmull-Rom splines. Using the 3D version requires rendering with P3D (see the Environment reference for more information). ( end auto-generated )

        Advanced

        As of revision 0070, this function no longer doubles the first and last points. The curves are a bit more boring, but it's more mathematically correct, and properly mirrored in curvePoint().

        Identical to typing out:

         beginShape();
         curveVertex(x1, y1);
         curveVertex(x2, y2);
         curveVertex(x3, y3);
         curveVertex(x4, y4);
         endShape();
         
        Parameters:
        x1 - coordinates for the beginning control point
        y1 - coordinates for the beginning control point
        x2 - coordinates for the first point
        y2 - coordinates for the first point
        x3 - coordinates for the second point
        y3 - coordinates for the second point
        x4 - coordinates for the ending control point
        y4 - coordinates for the ending control point
        See Also:
        PGraphics.curveVertex(float, float), PGraphics.curveTightness(float), PGraphics.bezier(float, float, float, float, float, float, float, float, float, float, float, float)
      • 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)
        Parameters:
        z1 - coordinates for the beginning control point
        z2 - coordinates for the first point
        z3 - coordinates for the second point
        z4 - coordinates for the ending control point
      • imageMode

        public void imageMode​(int mode)
        ( begin auto-generated from imageMode.xml ) Modifies the location from which images draw. The default mode is imageMode(CORNER), which specifies the location to be the upper left corner and uses the fourth and fifth parameters of image() to set the image's width and height. The syntax imageMode(CORNERS) uses the second and third parameters of image() to set the location of one corner of the image and uses the fourth and fifth parameters to set the opposite corner. Use imageMode(CENTER) to draw images centered at the given x and y position.

        The parameter to imageMode() must be written in ALL CAPS because Processing is a case-sensitive language. ( end auto-generated )
        Parameters:
        mode - either CORNER, CORNERS, or CENTER
        See Also:
        loadImage(String, String), PImage, PGraphics.image(PImage, float, float, float, float), PGraphics.background(float, float, float, float)
      • image

        public void image​(PImage img,
                          float a,
                          float b)
        ( begin auto-generated from image.xml ) Displays images to the screen. The images must be in the sketch's "data" directory to load correctly. Select "Add file..." from the "Sketch" menu to add the image. Processing currently works with GIF, JPEG, and Targa images. The img parameter specifies the image to display and the x and y parameters define the location of the image from its upper-left corner. The image is displayed at its original size unless the width and height parameters specify a different size.

        The imageMode() function changes the way the parameters work. For example, a call to imageMode(CORNERS) will change the width and height parameters to define the x and y values of the opposite corner of the image.

        The color of an image may be modified with the tint() function. This function will maintain transparency for GIF and PNG images. ( end auto-generated )

        Advanced

        Starting with release 0124, when using the default (JAVA2D) renderer, smooth() will also improve image quality of resized images.
        Parameters:
        img - the image to display
        a - x-coordinate of the image by default
        b - y-coordinate of the image by default
        See Also:
        loadImage(String, String), PImage, PGraphics.imageMode(int), PGraphics.tint(float), PGraphics.background(float, float, float, float), PGraphics.alpha(int)
      • image

        public void image​(PImage img,
                          float a,
                          float b,
                          float c,
                          float d)
        Parameters:
        c - width to display the image by default
        d - height to display the image by default
      • image

        public void image​(PImage img,
                          float a,
                          float b,
                          float c,
                          float d,
                          int u1,
                          int v1,
                          int u2,
                          int v2)
        Draw an image(), also specifying u/v coordinates. In this method, the u, v coordinates are always based on image space location, regardless of the current textureMode().
      • shapeMode

        public void shapeMode​(int mode)
        ( begin auto-generated from shapeMode.xml ) Modifies the location from which shapes draw. The default mode is shapeMode(CORNER), which specifies the location to be the upper left corner of the shape and uses the third and fourth parameters of shape() to specify the width and height. The syntax shapeMode(CORNERS) uses the first and second parameters of shape() to set the location of one corner and uses the third and fourth parameters to set the opposite corner. The syntax shapeMode(CENTER) draws the shape from its center point and uses the third and forth parameters of shape() to specify the width and height. The parameter must be written in "ALL CAPS" because Processing is a case sensitive language. ( end auto-generated )
        Parameters:
        mode - either CORNER, CORNERS, CENTER
        See Also:
        PShape, PGraphics.shape(PShape), PGraphics.rectMode(int)
      • shape

        public void shape​(PShape shape)
      • shape

        public void shape​(PShape shape,
                          float x,
                          float y)
        ( begin auto-generated from shape.xml ) Displays shapes to the screen. The shapes must be in the sketch's "data" directory to load correctly. Select "Add file..." from the "Sketch" menu to add the shape. Processing currently works with SVG shapes only. The sh parameter specifies the shape to display and the x and y parameters define the location of the shape from its upper-left corner. The shape is displayed at its original size unless the width and height parameters specify a different size. The shapeMode() function changes the way the parameters work. A call to shapeMode(CORNERS), for example, will change the width and height parameters to define the x and y values of the opposite corner of the shape.

        Note complex shapes may draw awkwardly with P3D. This renderer does not yet support shapes that have holes or complicated breaks. ( end auto-generated )
        Parameters:
        shape - the shape to display
        x - x-coordinate of the shape
        y - y-coordinate of the shape
        See Also:
        PShape, loadShape(String), Convenience method to draw at a particular location.
      • shape

        public void shape​(PShape shape,
                          float a,
                          float b,
                          float c,
                          float d)
        Parameters:
        a - x-coordinate of the shape
        b - y-coordinate of the shape
        c - width to display the shape
        d - height to display the shape
      • textAlign

        public void textAlign​(int alignX)
      • textAlign

        public void textAlign​(int alignX,
                              int alignY)
        ( begin auto-generated from textAlign.xml ) Sets the current alignment for drawing text. The parameters LEFT, CENTER, and RIGHT set the display characteristics of the letters in relation to the values for the x and y parameters of the text() function.

        In Processing 0125 and later, an optional second parameter can be used to vertically align the text. BASELINE is the default, and the vertical alignment will be reset to BASELINE if the second parameter is not used. The TOP and CENTER parameters are straightforward. The BOTTOM parameter offsets the line based on the current textDescent(). For multiple lines, the final line will be aligned to the bottom, with the previous lines appearing above it.

        When using text() with width and height parameters, BASELINE is ignored, and treated as TOP. (Otherwise, text would by default draw outside the box, since BASELINE is the default setting. BASELINE is not a useful drawing mode for text drawn in a rectangle.)

        The vertical alignment is based on the value of textAscent(), which many fonts do not specify correctly. It may be necessary to use a hack and offset by a few pixels by hand so that the offset looks correct. To do this as less of a hack, use some percentage of textAscent() or textDescent() so that the hack works even if you change the size of the font. ( end auto-generated )
        Parameters:
        alignX - horizontal alignment, either LEFT, CENTER, or RIGHT
        alignY - vertical alignment, either TOP, BOTTOM, CENTER, or BASELINE
        See Also:
        loadFont(String), PFont, PGraphics.text(String, float, float), PGraphics.textSize(float), PGraphics.textAscent(), PGraphics.textDescent()
      • textAscent

        public float textAscent()
        ( begin auto-generated from textAscent.xml ) Returns ascent of the current font at its current size. This information is useful for determining the height of the font above the baseline. For example, adding the textAscent() and textDescent() values will give you the total height of the line. ( end auto-generated )
        See Also:
        PGraphics.textDescent()
      • textDescent

        public float textDescent()
        ( begin auto-generated from textDescent.xml ) Returns descent of the current font at its current size. This information is useful for determining the height of the font below the baseline. For example, adding the textAscent() and textDescent() values will give you the total height of the line. ( end auto-generated )
        See Also:
        PGraphics.textAscent()
      • textFont

        public void textFont​(PFont which)
        ( begin auto-generated from textFont.xml ) Sets the current font that will be drawn with the text() function. Fonts must be loaded with loadFont() before it can be used. This font will be used in all subsequent calls to the text() function. If no size parameter is input, the font will appear at its original size (the size it was created at with the "Create Font..." tool) until it is changed with textSize().

        Because fonts are usually bitmaped, you should create fonts at the sizes that will be used most commonly. Using textFont() without the size parameter will result in the cleanest-looking text.

        With the default (JAVA2D) and PDF renderers, it's also possible to enable the use of native fonts via the command hint(ENABLE_NATIVE_FONTS). This will produce vector text in JAVA2D sketches and PDF output in cases where the vector data is available: when the font is still installed, or the font is created via the createFont() function (rather than the Create Font tool). ( end auto-generated )
        Parameters:
        which - any variable of the type PFont
        See Also:
        createFont(String, float, boolean), loadFont(String), PFont, PGraphics.text(String, float, float), PGraphics.textSize(float)
      • textFont

        public void textFont​(PFont which,
                             float size)
        Parameters:
        size - the size of the letters in units of pixels
      • textMode

        public void textMode​(int mode)
        ( begin auto-generated from textMode.xml ) Sets the way text draws to the screen. In the default configuration, the MODEL mode, it's possible to rotate, scale, and place letters in two and three dimensional space.

        The SHAPE mode draws text using the the glyph outlines of individual characters rather than as textures. This mode is only supported with the PDF and P3D renderer settings. With the PDF renderer, you must call textMode(SHAPE) before any other drawing occurs. If the outlines are not available, then textMode(SHAPE) will be ignored and textMode(MODEL) will be used instead.

        The textMode(SHAPE) option in P3D can be combined with beginRaw() to write vector-accurate text to 2D and 3D output files, for instance DXF or PDF. The SHAPE mode is not currently optimized for P3D, so if recording shape data, use textMode(MODEL) until you're ready to capture the geometry with beginRaw(). ( end auto-generated )
        Parameters:
        mode - either MODEL or SHAPE
        See Also:
        loadFont(String), PFont(java.io.InputStream), PGraphics.text(String, float, float), PGraphics.textFont(PFont), PGraphics.beginRaw(PGraphics), createFont(String, float, boolean)
      • textWidth

        public float textWidth​(char c)
        Parameters:
        c - the character to measure
      • textWidth

        public float textWidth​(char[] chars,
                               int start,
                               int length)
      • text

        public void text​(char c,
                         float x,
                         float y,
                         float z)
        Parameters:
        z - z-coordinate of text
      • text

        public void text​(String str,
                         float x,
                         float y)

        Advanced

        Draw a chunk of text. Newlines that are \n (Unix newline or linefeed char, ascii 10) are honored, but \r (carriage return, Windows and Mac OS) are ignored.
      • text

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

        Advanced

        Method to draw text from an array of chars. This method will usually be more efficient than drawing from a String object, because the String will not be converted to a char array before drawing.
        Parameters:
        chars - the alphanumberic symbols to be displayed
        start - array index at which to start writing characters
        stop - array index at which to stop writing characters
      • text

        public void text​(String str,
                         float x,
                         float y,
                         float z)
        Same as above but with a z coordinate.
      • text

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

        public void text​(String str,
                         float x1,
                         float y1,
                         float x2,
                         float y2)

        Advanced

        Draw text in a box that is constrained to a particular size. The current rectMode() determines what the coordinates mean (whether x1/y1/x2/y2 or x/y/w/h).

        Note that the x,y coords of the start of the box will align with the *ascent* of the text, not the baseline, as is the case for the other text() functions.

        Newlines that are \n (Unix newline or linefeed char, ascii 10) are honored, and \r (carriage return, Windows and Mac OS) are ignored.

        Parameters:
        x1 - by default, the x-coordinate of text, see rectMode() for more info
        y1 - by default, the y-coordinate of text, see rectMode() for more info
        x2 - by default, the width of the text box, see rectMode() for more info
        y2 - by default, the height of the text box, see rectMode() for more info
      • 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)
        This does a basic number formatting, to avoid the generally ugly appearance of printing floats. Users who want more control should use their own nf() cmmand, or if they want the long, ugly version of float, use String.valueOf() to convert the float to a String first.
        Parameters:
        num - the numeric value to be displayed
      • text

        public void text​(float num,
                         float x,
                         float y,
                         float z)
      • push

        public void push()
        ( begin auto-generated from push.xml ) The push() function saves the current drawing style settings and transformations, while pop() restores these settings. Note that these functions are always used together. They allow you to change the style and transformation settings and later return to what you had. When a new state is started with push(), it builds on the current style and transform information.

        push() stores information related to the current transformation state and style settings controlled by the following functions: rotate(), translate(), scale(), fill(), stroke(), tint(), strokeWeight(), strokeCap(), strokeJoin(), imageMode(), rectMode(), ellipseMode(), colorMode(), textAlign(), textFont(), textMode(), textSize(), textLeading().

        The push() and pop() functions were added with Processing 3.5. They can be used in place of pushMatrix(), popMatrix(), pushStyles(), and popStyles(). The difference is that push() and pop() control both the transformations (rotate, scale, translate) and the drawing styles at the same time. ( end auto-generated )
        See Also:
        PGraphics.pop()
      • pop

        public void pop()
        ( begin auto-generated from pop.xml ) The pop() function restores the previous drawing style settings and transformations after push() has changed them. Note that these functions are always used together. They allow you to change the style and transformation settings and later return to what you had. When a new state is started with push(), it builds on the current style and transform information.


        push() stores information related to the current transformation state and style settings controlled by the following functions: rotate(), translate(), scale(), fill(), stroke(), tint(), strokeWeight(), strokeCap(), strokeJoin(), imageMode(), rectMode(), ellipseMode(), colorMode(), textAlign(), textFont(), textMode(), textSize(), textLeading().

        The push() and pop() functions were added with Processing 3.5. They can be used in place of pushMatrix(), popMatrix(), pushStyles(), and popStyles(). The difference is that push() and pop() control both the transformations (rotate, scale, translate) and the drawing styles at the same time. ( end auto-generated )
        See Also:
        PGraphics.push()
      • popMatrix

        public void popMatrix()
        ( begin auto-generated from popMatrix.xml ) Pops the current transformation matrix off the matrix stack. Understanding pushing and popping requires understanding the concept of a matrix stack. The pushMatrix() function saves the current coordinate system to the stack and popMatrix() restores the prior coordinate system. pushMatrix() and popMatrix() are used in conjuction with the other transformation functions and may be embedded to control the scope of the transformations. ( end auto-generated )
        See Also:
        PGraphics.pushMatrix()
      • translate

        public void translate​(float x,
                              float y)
        ( begin auto-generated from translate.xml ) Specifies an amount to displace objects within the display window. The x parameter specifies left/right translation, the y parameter specifies up/down translation, and the z parameter specifies translations toward/away from the screen. Using this function with the z parameter requires using P3D as a parameter in combination with size as shown in the above example. Transformations apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling translate(50, 0) and then translate(20, 0) is the same as translate(70, 0). If translate() is called within draw(), the transformation is reset when the loop begins again. This function can be further controlled by the pushMatrix() and popMatrix(). ( end auto-generated )
        Parameters:
        x - left/right translation
        y - up/down translation
        See Also:
        PGraphics.popMatrix(), PGraphics.pushMatrix(), PGraphics.rotate(float), PGraphics.rotateX(float), PGraphics.rotateY(float), PGraphics.rotateZ(float), PGraphics.scale(float, float, float)
      • translate

        public void translate​(float x,
                              float y,
                              float z)
        Parameters:
        z - forward/backward translation
      • rotate

        public void rotate​(float angle)
        ( begin auto-generated from rotate.xml ) Rotates a shape the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to TWO_PI) or converted to radians with the radians() function.

        Objects are always rotated around their relative position to the origin and positive numbers rotate objects in a clockwise direction. Transformations apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling rotate(HALF_PI) and then rotate(HALF_PI) is the same as rotate(PI). All tranformations are reset when draw() begins again.

        Technically, rotate() multiplies the current transformation matrix by a rotation matrix. This function can be further controlled by the pushMatrix() and popMatrix(). ( end auto-generated )
        Parameters:
        angle - angle of rotation specified in radians
        See Also:
        PGraphics.popMatrix(), PGraphics.pushMatrix(), PGraphics.rotateX(float), PGraphics.rotateY(float), PGraphics.rotateZ(float), PGraphics.scale(float, float, float), radians(float)
      • rotateX

        public void rotateX​(float angle)
        ( begin auto-generated from rotateX.xml ) Rotates a shape around the x-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. Objects are always rotated around their relative position to the origin and positive numbers rotate objects in a counterclockwise direction. Transformations apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling rotateX(PI/2) and then rotateX(PI/2) is the same as rotateX(PI). If rotateX() is called within the draw(), the transformation is reset when the loop begins again. This function requires using P3D as a third parameter to size() as shown in the example above. ( end auto-generated )
        Parameters:
        angle - angle of rotation specified in radians
        See Also:
        PGraphics.popMatrix(), PGraphics.pushMatrix(), PGraphics.rotate(float), PGraphics.rotateY(float), PGraphics.rotateZ(float), PGraphics.scale(float, float, float), PGraphics.translate(float, float, float)
      • rotateY

        public void rotateY​(float angle)
        ( begin auto-generated from rotateY.xml ) Rotates a shape around the y-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. Objects are always rotated around their relative position to the origin and positive numbers rotate objects in a counterclockwise direction. Transformations apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling rotateY(PI/2) and then rotateY(PI/2) is the same as rotateY(PI). If rotateY() is called within the draw(), the transformation is reset when the loop begins again. This function requires using P3D as a third parameter to size() as shown in the examples above. ( end auto-generated )
        Parameters:
        angle - angle of rotation specified in radians
        See Also:
        PGraphics.popMatrix(), PGraphics.pushMatrix(), PGraphics.rotate(float), PGraphics.rotateX(float), PGraphics.rotateZ(float), PGraphics.scale(float, float, float), PGraphics.translate(float, float, float)
      • rotateZ

        public void rotateZ​(float angle)
        ( begin auto-generated from rotateZ.xml ) Rotates a shape around the z-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. Objects are always rotated around their relative position to the origin and positive numbers rotate objects in a counterclockwise direction. Transformations apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling rotateZ(PI/2) and then rotateZ(PI/2) is the same as rotateZ(PI). If rotateZ() is called within the draw(), the transformation is reset when the loop begins again. This function requires using P3D as a third parameter to size() as shown in the examples above. ( end auto-generated )
        Parameters:
        angle - angle of rotation specified in radians
        See Also:
        PGraphics.popMatrix(), PGraphics.pushMatrix(), PGraphics.rotate(float), PGraphics.rotateX(float), PGraphics.rotateY(float), PGraphics.scale(float, float, float), PGraphics.translate(float, float, float)
      • rotate

        public void rotate​(float angle,
                           float x,
                           float y,
                           float z)

        Advanced

        Rotate about a vector in space. Same as the glRotatef() function.
        Parameters:
        x -
        y -
        z -
      • scale

        public void scale​(float s)
        ( begin auto-generated from scale.xml ) Increases or decreases the size of a shape by expanding and contracting vertices. Objects always scale from their relative origin to the coordinate system. Scale values are specified as decimal percentages. For example, the function call scale(2.0) increases the dimension of a shape by 200%. Transformations apply to everything that happens after and subsequent calls to the function multiply the effect. For example, calling scale(2.0) and then scale(1.5) is the same as scale(3.0). If scale() is called within draw(), the transformation is reset when the loop begins again. Using this fuction with the z parameter requires using P3D as a parameter for size() as shown in the example above. This function can be further controlled by pushMatrix() and popMatrix(). ( end auto-generated )
        Parameters:
        s - percentage to scale the object
        See Also:
        PGraphics.pushMatrix(), PGraphics.popMatrix(), PGraphics.translate(float, float, float), PGraphics.rotate(float), PGraphics.rotateX(float), PGraphics.rotateY(float), PGraphics.rotateZ(float)
      • scale

        public void scale​(float x,
                          float y)

        Advanced

        Scale in X and Y. Equivalent to scale(sx, sy, 1). Not recommended for use in 3D, because the z-dimension is just scaled by 1, since there's no way to know what else to scale it by.
        Parameters:
        x - percentage to scale the object in the x-axis
        y - percentage to scale the object in the y-axis
      • scale

        public void scale​(float x,
                          float y,
                          float z)
        Parameters:
        z - percentage to scale the object in the z-axis
      • shearX

        public void shearX​(float angle)
        ( begin auto-generated from shearX.xml ) Shears a shape around the x-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. Objects are always sheared around their relative position to the origin and positive numbers shear objects in a clockwise direction. Transformations apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling shearX(PI/2) and then shearX(PI/2) is the same as shearX(PI). If shearX() is called within the draw(), the transformation is reset when the loop begins again.

        Technically, shearX() multiplies the current transformation matrix by a rotation matrix. This function can be further controlled by the pushMatrix() and popMatrix() functions. ( end auto-generated )
        Parameters:
        angle - angle of shear specified in radians
        See Also:
        PGraphics.popMatrix(), PGraphics.pushMatrix(), PGraphics.shearY(float), PGraphics.scale(float, float, float), PGraphics.translate(float, float, float), radians(float)
      • shearY

        public void shearY​(float angle)
        ( begin auto-generated from shearY.xml ) Shears a shape around the y-axis the amount specified by the angle parameter. Angles should be specified in radians (values from 0 to PI*2) or converted to radians with the radians() function. Objects are always sheared around their relative position to the origin and positive numbers shear objects in a clockwise direction. Transformations apply to everything that happens after and subsequent calls to the function accumulates the effect. For example, calling shearY(PI/2) and then shearY(PI/2) is the same as shearY(PI). If shearY() is called within the draw(), the transformation is reset when the loop begins again.

        Technically, shearY() multiplies the current transformation matrix by a rotation matrix. This function can be further controlled by the pushMatrix() and popMatrix() functions. ( end auto-generated )
        Parameters:
        angle - angle of shear specified in radians
        See Also:
        PGraphics.popMatrix(), PGraphics.pushMatrix(), PGraphics.shearX(float), PGraphics.scale(float, float, float), PGraphics.translate(float, float, float), radians(float)
      • applyMatrix

        public void applyMatrix​(PMatrix2D source)
      • applyMatrix

        public void applyMatrix​(float n00,
                                float n01,
                                float n02,
                                float n10,
                                float n11,
                                float n12)
        Parameters:
        n00 - numbers which define the 4x4 matrix to be multiplied
        n01 - numbers which define the 4x4 matrix to be multiplied
        n02 - numbers which define the 4x4 matrix to be multiplied
        n10 - numbers which define the 4x4 matrix to be multiplied
        n11 - numbers which define the 4x4 matrix to be multiplied
        n12 - numbers which define the 4x4 matrix to be multiplied
      • 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)
        Parameters:
        n03 - numbers which define the 4x4 matrix to be multiplied
        n13 - numbers which define the 4x4 matrix to be multiplied
        n20 - numbers which define the 4x4 matrix to be multiplied
        n21 - numbers which define the 4x4 matrix to be multiplied
        n22 - numbers which define the 4x4 matrix to be multiplied
        n23 - numbers which define the 4x4 matrix to be multiplied
        n30 - numbers which define the 4x4 matrix to be multiplied
        n31 - numbers which define the 4x4 matrix to be multiplied
        n32 - numbers which define the 4x4 matrix to be multiplied
        n33 - numbers which define the 4x4 matrix to be multiplied
      • getMatrix

        public PMatrix getMatrix()
      • getMatrix

        public PMatrix2D getMatrix​(PMatrix2D target)
        Copy the current transformation matrix into the specified target. Pass in null to create a new matrix.
      • getMatrix

        public PMatrix3D getMatrix​(PMatrix3D target)
        Copy the current transformation matrix into the specified target. Pass in null to create a new matrix.
      • setMatrix

        public void setMatrix​(PMatrix source)
        Set the current transformation matrix to the contents of another.
      • setMatrix

        public void setMatrix​(PMatrix2D source)
        Set the current transformation to the contents of the specified source.
      • setMatrix

        public void setMatrix​(PMatrix3D source)
        Set the current transformation to the contents of the specified source.
      • beginCamera

        public void beginCamera()
        ( begin auto-generated from beginCamera.xml ) The beginCamera() and endCamera() functions enable advanced customization of the camera space. The functions are useful if you want to more control over camera movement, however for most users, the camera() function will be sufficient.

        The camera functions will replace any transformations (such as rotate() or translate()) that occur before them in draw(), but they will not automatically replace the camera transform itself. For this reason, camera functions should be placed at the beginning of draw() (so that transformations happen afterwards), and the camera() function can be used after beginCamera() if you want to reset the camera before applying transformations.

        This function sets the matrix mode to the camera matrix so calls such as translate(), rotate(), applyMatrix() and resetMatrix() affect the camera. beginCamera() should always be used with a following endCamera() and pairs of beginCamera() and endCamera() cannot be nested. ( end auto-generated )
        See Also:
        PGraphics.camera(), PGraphics.endCamera(), PGraphics.applyMatrix(PMatrix), PGraphics.resetMatrix(), PGraphics.translate(float, float, float), PGraphics.scale(float, float, float)
      • camera

        public void camera()
        ( begin auto-generated from camera.xml ) Sets the position of the camera through setting the eye position, the center of the scene, and which axis is facing upward. Moving the eye position and the direction it is pointing (the center of the scene) allows the images to be seen from different angles. The version without any parameters sets the camera to the default position, pointing to the center of the display window with the Y axis as up. The default values are camera(width/2.0, height/2.0, (height/2.0) / tan(PI*30.0 / 180.0), width/2.0, height/2.0, 0, 0, 1, 0). This function is similar to gluLookAt() in OpenGL, but it first clears the current camera settings. ( end auto-generated )
        See Also:
        PGraphics.beginCamera(), PGraphics.endCamera(), PGraphics.frustum(float, float, float, float, float, float)
      • camera

        public void camera​(float eyeX,
                           float eyeY,
                           float eyeZ,
                           float centerX,
                           float centerY,
                           float centerZ,
                           float upX,
                           float upY,
                           float upZ)
        Parameters:
        eyeX - x-coordinate for the eye
        eyeY - y-coordinate for the eye
        eyeZ - z-coordinate for the eye
        centerX - x-coordinate for the center of the scene
        centerY - y-coordinate for the center of the scene
        centerZ - z-coordinate for the center of the scene
        upX - usually 0.0, 1.0, or -1.0
        upY - usually 0.0, 1.0, or -1.0
        upZ - usually 0.0, 1.0, or -1.0
      • ortho

        public void ortho()
        ( begin auto-generated from ortho.xml ) Sets an orthographic projection and defines a parallel clipping volume. All objects with the same dimension appear the same size, regardless of whether they are near or far from the camera. The parameters to this function specify the clipping volume where left and right are the minimum and maximum x values, top and bottom are the minimum and maximum y values, and near and far are the minimum and maximum z values. If no parameters are given, the default is used: ortho(0, width, 0, height, -10, 10). ( end auto-generated )
      • ortho

        public void ortho​(float left,
                          float right,
                          float bottom,
                          float top)
        Parameters:
        left - left plane of the clipping volume
        right - right plane of the clipping volume
        bottom - bottom plane of the clipping volume
        top - top plane of the clipping volume
      • ortho

        public void ortho​(float left,
                          float right,
                          float bottom,
                          float top,
                          float near,
                          float far)
        Parameters:
        near - maximum distance from the origin to the viewer
        far - maximum distance from the origin away from the viewer
      • perspective

        public void perspective()
        ( begin auto-generated from perspective.xml ) Sets a perspective projection applying foreshortening, making distant objects appear smaller than closer ones. The parameters define a viewing volume with the shape of truncated pyramid. Objects near to the front of the volume appear their actual size, while farther objects appear smaller. This projection simulates the perspective of the world more accurately than orthographic projection. The version of perspective without parameters sets the default perspective and the version with four parameters allows the programmer to set the area precisely. The default values are: perspective(PI/3.0, width/height, cameraZ/10.0, cameraZ*10.0) where cameraZ is ((height/2.0) / tan(PI*60.0/360.0)); ( end auto-generated )
      • perspective

        public void perspective​(float fovy,
                                float aspect,
                                float zNear,
                                float zFar)
        Parameters:
        fovy - field-of-view angle (in radians) for vertical direction
        aspect - ratio of width to height
        zNear - z-position of nearest clipping plane
        zFar - z-position of farthest clipping plane
      • frustum

        public void frustum​(float left,
                            float right,
                            float bottom,
                            float top,
                            float near,
                            float far)
        ( begin auto-generated from frustum.xml ) Sets a perspective matrix defined through the parameters. Works like glFrustum, except it wipes out the current perspective matrix rather than muliplying itself with it. ( end auto-generated )
        Parameters:
        left - left coordinate of the clipping plane
        right - right coordinate of the clipping plane
        bottom - bottom coordinate of the clipping plane
        top - top coordinate of the clipping plane
        near - near component of the clipping plane; must be greater than zero
        far - far component of the clipping plane; must be greater than the near value
        See Also:
        PGraphics.camera(float, float, float, float, float, float, float, float, float), PGraphics.beginCamera(), PGraphics.endCamera(), PGraphics.perspective(float, float, float, float)
      • screenX

        public float screenX​(float x,
                             float y)
        ( begin auto-generated from screenX.xml ) Takes a three-dimensional X, Y, Z position and returns the X value for where it will appear on a (two-dimensional) screen. ( end auto-generated )
        Parameters:
        x - 3D x-coordinate to be mapped
        y - 3D y-coordinate to be mapped
        See Also:
        PGraphics.screenY(float, float, float), PGraphics.screenZ(float, float, float)
      • screenY

        public float screenY​(float x,
                             float y)
        ( begin auto-generated from screenY.xml ) Takes a three-dimensional X, Y, Z position and returns the Y value for where it will appear on a (two-dimensional) screen. ( end auto-generated )
        Parameters:
        x - 3D x-coordinate to be mapped
        y - 3D y-coordinate to be mapped
        See Also:
        PGraphics.screenX(float, float, float), PGraphics.screenZ(float, float, float)
      • screenX

        public float screenX​(float x,
                             float y,
                             float z)
        Parameters:
        z - 3D z-coordinate to be mapped
      • screenY

        public float screenY​(float x,
                             float y,
                             float z)
        Parameters:
        z - 3D z-coordinate to be mapped
      • screenZ

        public float screenZ​(float x,
                             float y,
                             float z)
        ( begin auto-generated from screenZ.xml ) Takes a three-dimensional X, Y, Z position and returns the Z value for where it will appear on a (two-dimensional) screen. ( end auto-generated )
        Parameters:
        x - 3D x-coordinate to be mapped
        y - 3D y-coordinate to be mapped
        z - 3D z-coordinate to be mapped
        See Also:
        PGraphics.screenX(float, float, float), PGraphics.screenY(float, float, float)
      • modelX

        public float modelX​(float x,
                            float y,
                            float z)
        ( begin auto-generated from modelX.xml ) Returns the three-dimensional X, Y, Z position in model space. This returns the X value for a given coordinate based on the current set of transformations (scale, rotate, translate, etc.) The X value can be used to place an object in space relative to the location of the original point once the transformations are no longer in use.

        In the example, the modelX(), modelY(), and modelZ() functions record the location of a box in space after being placed using a series of translate and rotate commands. After popMatrix() is called, those transformations no longer apply, but the (x, y, z) coordinate returned by the model functions is used to place another box in the same location. ( end auto-generated )
        Parameters:
        x - 3D x-coordinate to be mapped
        y - 3D y-coordinate to be mapped
        z - 3D z-coordinate to be mapped
        See Also:
        PGraphics.modelY(float, float, float), PGraphics.modelZ(float, float, float)
      • modelY

        public float modelY​(float x,
                            float y,
                            float z)
        ( begin auto-generated from modelY.xml ) Returns the three-dimensional X, Y, Z position in model space. This returns the Y value for a given coordinate based on the current set of transformations (scale, rotate, translate, etc.) The Y value can be used to place an object in space relative to the location of the original point once the transformations are no longer in use.

        In the example, the modelX(), modelY(), and modelZ() functions record the location of a box in space after being placed using a series of translate and rotate commands. After popMatrix() is called, those transformations no longer apply, but the (x, y, z) coordinate returned by the model functions is used to place another box in the same location. ( end auto-generated )
        Parameters:
        x - 3D x-coordinate to be mapped
        y - 3D y-coordinate to be mapped
        z - 3D z-coordinate to be mapped
        See Also:
        PGraphics.modelX(float, float, float), PGraphics.modelZ(float, float, float)
      • modelZ

        public float modelZ​(float x,
                            float y,
                            float z)
        ( begin auto-generated from modelZ.xml ) Returns the three-dimensional X, Y, Z position in model space. This returns the Z value for a given coordinate based on the current set of transformations (scale, rotate, translate, etc.) The Z value can be used to place an object in space relative to the location of the original point once the transformations are no longer in use.

        In the example, the modelX(), modelY(), and modelZ() functions record the location of a box in space after being placed using a series of translate and rotate commands. After popMatrix() is called, those transformations no longer apply, but the (x, y, z) coordinate returned by the model functions is used to place another box in the same location. ( end auto-generated )
        Parameters:
        x - 3D x-coordinate to be mapped
        y - 3D y-coordinate to be mapped
        z - 3D z-coordinate to be mapped
        See Also:
        PGraphics.modelX(float, float, float), PGraphics.modelY(float, float, float)
      • pushStyle

        public void pushStyle()
        ( begin auto-generated from pushStyle.xml ) The pushStyle() function saves the current style settings and popStyle() restores the prior settings. Note that these functions are always used together. They allow you to change the style settings and later return to what you had. When a new style is started with pushStyle(), it builds on the current style information. The pushStyle() and popStyle() functions can be embedded to provide more control (see the second example above for a demonstration.)

        The style information controlled by the following functions are included in the style: fill(), stroke(), tint(), strokeWeight(), strokeCap(), strokeJoin(), imageMode(), rectMode(), ellipseMode(), shapeMode(), colorMode(), textAlign(), textFont(), textMode(), textSize(), textLeading(), emissive(), specular(), shininess(), ambient() ( end auto-generated )
        See Also:
        PGraphics.popStyle()
      • popStyle

        public void popStyle()
        ( begin auto-generated from popStyle.xml ) The pushStyle() function saves the current style settings and popStyle() restores the prior settings; these functions are always used together. They allow you to change the style settings and later return to what you had. When a new style is started with pushStyle(), it builds on the current style information. The pushStyle() and popStyle() functions can be embedded to provide more control (see the second example above for a demonstration.) ( end auto-generated )
        See Also:
        PGraphics.pushStyle()
      • style

        public void style​(PStyle s)
      • strokeWeight

        public void strokeWeight​(float weight)
        ( begin auto-generated from strokeWeight.xml ) Sets the width of the stroke used for lines, points, and the border around shapes. All widths are set in units of pixels.

        When drawing with P3D, series of connected lines (such as the stroke around a polygon, triangle, or ellipse) produce unattractive results when a thick stroke weight is set (see Issue 123). With P3D, the minimum and maximum values for strokeWeight() are controlled by the graphics card and the operating system's OpenGL implementation. For instance, the thickness may not go higher than 10 pixels. ( end auto-generated )
        Parameters:
        weight - the weight (in pixels) of the stroke
        See Also:
        PGraphics.stroke(int, float), PGraphics.strokeJoin(int), PGraphics.strokeCap(int)
      • strokeJoin

        public void strokeJoin​(int join)
        ( begin auto-generated from strokeJoin.xml ) Sets the style of the joints which connect line segments. These joints are either mitered, beveled, or rounded and specified with the corresponding parameters MITER, BEVEL, and ROUND. The default joint is MITER.

        This function is not available with the P3D renderer, (see Issue 123). More information about the renderers can be found in the size() reference. ( end auto-generated )
        Parameters:
        join - either MITER, BEVEL, ROUND
        See Also:
        PGraphics.stroke(int, float), PGraphics.strokeWeight(float), PGraphics.strokeCap(int)
      • strokeCap

        public void strokeCap​(int cap)
        ( begin auto-generated from strokeCap.xml ) Sets the style for rendering line endings. These ends are either squared, extended, or rounded and specified with the corresponding parameters SQUARE, PROJECT, and ROUND. The default cap is ROUND.

        This function is not available with the P3D renderer (see Issue 123). More information about the renderers can be found in the size() reference. ( end auto-generated )
        Parameters:
        cap - either SQUARE, PROJECT, or ROUND
        See Also:
        PGraphics.stroke(int, float), PGraphics.strokeWeight(float), PGraphics.strokeJoin(int), size(int, int, String, String)
      • stroke

        public void stroke​(int rgb,
                           float alpha)
        Parameters:
        alpha - opacity of the stroke
      • stroke

        public void stroke​(float gray)
        Parameters:
        gray - specifies a value between white and black
      • stroke

        public void stroke​(float gray,
                           float alpha)
      • stroke

        public void stroke​(float v1,
                           float v2,
                           float v3)
        Parameters:
        v1 - red or hue value (depending on current color mode)
        v2 - green or saturation value (depending on current color mode)
        v3 - blue or brightness value (depending on current color mode)
      • stroke

        public void stroke​(float v1,
                           float v2,
                           float v3,
                           float alpha)
      • tint

        public void tint​(int rgb)
        ( begin auto-generated from tint.xml ) Sets the fill value for displaying images. Images can be tinted to specified colors or made transparent by setting the alpha.

        To make an image transparent, but not change it's color, use white as the tint color and specify an alpha value. For instance, tint(255, 128) will make an image 50% transparent (unless colorMode() has been used).

        When using hexadecimal notation to specify a color, use "#" or "0x" before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six digits to specify a color (the way colors are specified in HTML and CSS). When using the hexadecimal notation starting with "0x", the hexadecimal value must be specified with eight characters; the first two characters define the alpha component and the remainder the red, green, and blue components.

        The value for the parameter "gray" must be less than or equal to the current maximum value as specified by colorMode(). The default maximum value is 255.

        The tint() function is also used to control the coloring of textures in 3D. ( end auto-generated )
        Parameters:
        rgb - color value in hexadecimal notation
        See Also:
        PGraphics.noTint(), PGraphics.image(PImage, float, float, float, float)
      • tint

        public void tint​(int rgb,
                         float alpha)
        Parameters:
        alpha - opacity of the image
      • tint

        public void tint​(float gray)
        Parameters:
        gray - specifies a value between white and black
      • tint

        public void tint​(float gray,
                         float alpha)
      • tint

        public void tint​(float v1,
                         float v2,
                         float v3)
        Parameters:
        v1 - red or hue value (depending on current color mode)
        v2 - green or saturation value (depending on current color mode)
        v3 - blue or brightness value (depending on current color mode)
      • tint

        public void tint​(float v1,
                         float v2,
                         float v3,
                         float alpha)
      • fill

        public void fill​(int rgb)
        ( begin auto-generated from fill.xml ) Sets the color used to fill shapes. For example, if you run fill(204, 102, 0), all subsequent shapes will be filled with orange. This color is either specified in terms of the RGB or HSB color depending on the current colorMode() (the default color space is RGB, with each value in the range from 0 to 255).

        When using hexadecimal notation to specify a color, use "#" or "0x" before the values (e.g. #CCFFAA, 0xFFCCFFAA). The # syntax uses six digits to specify a color (the way colors are specified in HTML and CSS). When using the hexadecimal notation starting with "0x", the hexadecimal value must be specified with eight characters; the first two characters define the alpha component and the remainder the red, green, and blue components.

        The value for the parameter "gray" must be less than or equal to the current maximum value as specified by colorMode(). The default maximum value is 255.

        To change the color of an image (or a texture), use tint(). ( end auto-generated )
        Parameters:
        rgb - color variable or hex value
        See Also:
        PGraphics.noFill(), PGraphics.stroke(int, float), PGraphics.noStroke(), PGraphics.tint(int, float), PGraphics.background(float, float, float, float), PGraphics.colorMode(int, float, float, float, float)
      • fill

        public void fill​(int rgb,
                         float alpha)
        Parameters:
        alpha - opacity of the fill
      • fill

        public void fill​(float gray)
        Parameters:
        gray - number specifying value between white and black
      • fill

        public void fill​(float gray,
                         float alpha)
      • fill

        public void fill​(float v1,
                         float v2,
                         float v3)
        Parameters:
        v1 - red or hue value (depending on current color mode)
        v2 - green or saturation value (depending on current color mode)
        v3 - blue or brightness value (depending on current color mode)
      • fill

        public void fill​(float v1,
                         float v2,
                         float v3,
                         float alpha)
      • ambient

        public void ambient​(int rgb)
        ( begin auto-generated from ambient.xml ) Sets the ambient reflectance for shapes drawn to the screen. This is combined with the ambient light component of environment. The color components set through the parameters define the reflectance. For example in the default color mode, setting v1=255, v2=126, v3=0, would cause all the red light to reflect and half of the green light to reflect. Used in combination with emissive(), specular(), and shininess() in setting the material properties of shapes. ( end auto-generated )
        Parameters:
        rgb - any value of the color datatype
        See Also:
        PGraphics.emissive(float, float, float), PGraphics.specular(float, float, float), PGraphics.shininess(float)
      • ambient

        public void ambient​(float gray)
        Parameters:
        gray - number specifying value between white and black
      • ambient

        public void ambient​(float v1,
                            float v2,
                            float v3)
        Parameters:
        v1 - red or hue value (depending on current color mode)
        v2 - green or saturation value (depending on current color mode)
        v3 - blue or brightness value (depending on current color mode)
      • specular

        public void specular​(float gray)
        gray number specifying value between white and black
      • specular

        public void specular​(float v1,
                             float v2,
                             float v3)
        Parameters:
        v1 - red or hue value (depending on current color mode)
        v2 - green or saturation value (depending on current color mode)
        v3 - blue or brightness value (depending on current color mode)
      • emissive

        public void emissive​(float gray)
        gray number specifying value between white and black
      • emissive

        public void emissive​(float v1,
                             float v2,
                             float v3)
        Parameters:
        v1 - red or hue value (depending on current color mode)
        v2 - green or saturation value (depending on current color mode)
        v3 - blue or brightness value (depending on current color mode)
      • noLights

        public void noLights()
        ( begin auto-generated from noLights.xml ) Disable all lighting. Lighting is turned off by default and enabled with the lights() function. This function can be used to disable lighting so that 2D geometry (which does not require lighting) can be drawn after a set of lighted 3D geometry. ( end auto-generated )
        See Also:
        PGraphics.lights()
      • ambientLight

        public void ambientLight​(float v1,
                                 float v2,
                                 float v3,
                                 float x,
                                 float y,
                                 float z)
        Parameters:
        x - x-coordinate of the light
        y - y-coordinate of the light
        z - z-coordinate of the light
      • directionalLight

        public void directionalLight​(float v1,
                                     float v2,
                                     float v3,
                                     float nx,
                                     float ny,
                                     float nz)
        ( begin auto-generated from directionalLight.xml ) Adds a directional light. Directional light comes from one direction and is stronger when hitting a surface squarely and weaker if it hits at a a gentle angle. After hitting a surface, a directional lights scatters in all directions. Lights need to be included in the draw() to remain persistent in a looping program. Placing them in the setup() of a looping program will cause them to only have an effect the first time through the loop. The affect of the v1, v2, and v3 parameters is determined by the current color mode. The nx, ny, and nz parameters specify the direction the light is facing. For example, setting ny to -1 will cause the geometry to be lit from below (the light is facing directly upward). ( end auto-generated )
        Parameters:
        v1 - red or hue value (depending on current color mode)
        v2 - green or saturation value (depending on current color mode)
        v3 - blue or brightness value (depending on current color mode)
        nx - direction along the x-axis
        ny - direction along the y-axis
        nz - direction along the z-axis
        See Also:
        PGraphics.lights(), PGraphics.ambientLight(float, float, float, float, float, float), PGraphics.pointLight(float, float, float, float, float, float), PGraphics.spotLight(float, float, float, float, float, float, float, float, float, float, float)
      • spotLight

        public void spotLight​(float v1,
                              float v2,
                              float v3,
                              float x,
                              float y,
                              float z,
                              float nx,
                              float ny,
                              float nz,
                              float angle,
                              float concentration)
        ( begin auto-generated from spotLight.xml ) Adds a spot light. Lights need to be included in the draw() to remain persistent in a looping program. Placing them in the setup() of a looping program will cause them to only have an effect the first time through the loop. The affect of the v1, v2, and v3 parameters is determined by the current color mode. The x, y, and z parameters specify the position of the light and nx, ny, nz specify the direction or light. The angle parameter affects angle of the spotlight cone. ( end auto-generated )
        Parameters:
        v1 - red or hue value (depending on current color mode)
        v2 - green or saturation value (depending on current color mode)
        v3 - blue or brightness value (depending on current color mode)
        x - x-coordinate of the light
        y - y-coordinate of the light
        z - z-coordinate of the light
        nx - direction along the x axis
        ny - direction along the y axis
        nz - direction along the z axis
        angle - angle of the spotlight cone
        concentration - exponent determining the center bias of the cone
        See Also:
        PGraphics.lights(), PGraphics.directionalLight(float, float, float, float, float, float), PGraphics.pointLight(float, float, float, float, float, float), PGraphics.ambientLight(float, float, float, float, float, float)
      • background

        public void background​(int rgb)
        ( begin auto-generated from background.xml ) The background() function sets the color used for the background of the Processing window. The default background is light gray. In the draw() function, the background color is used to clear the display window at the beginning of each frame.

        An image can also be used as the background for a sketch, however its width and height must be the same size as the sketch window. To resize an image 'b' to the size of the sketch window, use b.resize(width, height).

        Images used as background will ignore the current tint() setting.

        It is not possible to use transparency (alpha) in background colors with the main drawing surface, however they will work properly with createGraphics(). ( end auto-generated )

        Advanced

        Clear the background with a color that includes an alpha value. This can only be used with objects created by createGraphics(), because the main drawing surface cannot be set transparent.

        It might be tempting to use this function to partially clear the screen on each frame, however that's not how this function works. When calling background(), the pixels will be replaced with pixels that have that level of transparency. To do a semi-transparent overlay, use fill() with alpha and draw a rectangle.

        Parameters:
        rgb - any value of the color datatype
        See Also:
        PGraphics.stroke(float), PGraphics.fill(float), PGraphics.tint(float), PGraphics.colorMode(int)
      • background

        public void background​(int rgb,
                               float alpha)
        Parameters:
        alpha - opacity of the background
      • background

        public void background​(float gray)
        Parameters:
        gray - specifies a value between white and black
      • background

        public void background​(float gray,
                               float alpha)
      • background

        public void background​(float v1,
                               float v2,
                               float v3)
        Parameters:
        v1 - red or hue value (depending on the current color mode)
        v2 - green or saturation value (depending on the current color mode)
        v3 - blue or brightness value (depending on the current color mode)
      • background

        public void background​(float v1,
                               float v2,
                               float v3,
                               float alpha)
      • clear

        public void clear()
      • background

        public void background​(PImage image)
        Takes an RGB or ARGB image and sets it as the background. The width and height of the image must be the same size as the sketch. Use image.resize(width, height) to make short work of such a task.

        Note that even if the image is set as RGB, the high 8 bits of each pixel should be set opaque (0xFF000000) because the image data will be copied directly to the screen, and non-opaque background images may have strange behavior. Use image.filter(OPAQUE) to handle this easily.

        When using 3D, this will also clear the zbuffer (if it exists).
        Parameters:
        image - PImage to set as background (must be same size as the sketch window)
      • colorMode

        public void colorMode​(int mode)
        ( begin auto-generated from colorMode.xml ) Changes the way Processing interprets color data. By default, the parameters for fill(), stroke(), background(), and color() are defined by values between 0 and 255 using the RGB color model. The colorMode() function is used to change the numerical range used for specifying colors and to switch color systems. For example, calling colorMode(RGB, 1.0) will specify that values are specified between 0 and 1. The limits for defining colors are altered by setting the parameters range1, range2, range3, and range 4. ( end auto-generated )
        Parameters:
        mode - Either RGB or HSB, corresponding to Red/Green/Blue and Hue/Saturation/Brightness
        See Also:
        PGraphics.background(float), PGraphics.fill(float), PGraphics.stroke(float)
      • colorMode

        public void colorMode​(int mode,
                              float max)
        Parameters:
        max - range for all color elements
      • colorMode

        public void colorMode​(int mode,
                              float max1,
                              float max2,
                              float max3)
        Parameters:
        max1 - range for the red or hue depending on the current color mode
        max2 - range for the green or saturation depending on the current color mode
        max3 - range for the blue or brightness depending on the current color mode
      • colorMode

        public void colorMode​(int mode,
                              float max1,
                              float max2,
                              float max3,
                              float maxA)
        Parameters:
        maxA - range for the alpha
      • red

        public final float red​(int rgb)
        ( begin auto-generated from red.xml ) Extracts the red value from a color, scaled to match current colorMode(). This value is always returned as a float so be careful not to assign it to an int value.

        The red() function is easy to use and undestand, but is slower than another technique. To achieve the same results when working in colorMode(RGB, 255), but with greater speed, use the >> (right shift) operator with a bit mask. For example, the following two lines of code are equivalent:
        float r1 = red(myColor);
        float r2 = myColor >> 16 & 0xFF;
        ( end auto-generated )
        Parameters:
        rgb - any value of the color datatype
        See Also:
        PGraphics.green(int), PGraphics.blue(int), PGraphics.alpha(int), PGraphics.hue(int), PGraphics.saturation(int), PGraphics.brightness(int)
      • green

        public final float green​(int rgb)
        ( begin auto-generated from green.xml ) Extracts the green value from a color, scaled to match current colorMode(). This value is always returned as a float so be careful not to assign it to an int value.

        The green() function is easy to use and undestand, but is slower than another technique. To achieve the same results when working in colorMode(RGB, 255), but with greater speed, use the >> (right shift) operator with a bit mask. For example, the following two lines of code are equivalent:
        float r1 = green(myColor);
        float r2 = myColor >> 8 & 0xFF;
        ( end auto-generated )
        Parameters:
        rgb - any value of the color datatype
        See Also:
        PGraphics.red(int), PGraphics.blue(int), PGraphics.alpha(int), PGraphics.hue(int), PGraphics.saturation(int), PGraphics.brightness(int)
      • blue

        public final float blue​(int rgb)
        ( begin auto-generated from blue.xml ) Extracts the blue value from a color, scaled to match current colorMode(). This value is always returned as a float so be careful not to assign it to an int value.

        The blue() function is easy to use and undestand, but is slower than another technique. To achieve the same results when working in colorMode(RGB, 255), but with greater speed, use a bit mask to remove the other color components. For example, the following two lines of code are equivalent:
        float r1 = blue(myColor);
        float r2 = myColor & 0xFF;
        ( end auto-generated )
        Parameters:
        rgb - any value of the color datatype
        See Also:
        PGraphics.red(int), PGraphics.green(int), PGraphics.alpha(int), PGraphics.hue(int), PGraphics.saturation(int), PGraphics.brightness(int)
      • lerpColor

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

        public static void showDepthWarning​(String method)
        Display a warning that the specified method is only available with 3D.
        Parameters:
        method - The method name (no parentheses)
      • showDepthWarningXYZ

        public static void showDepthWarningXYZ​(String method)
        Display a warning that the specified method that takes x, y, z parameters can only be used with x and y parameters in this renderer.
        Parameters:
        method - The method name (no parentheses)
      • showMethodWarning

        public static void showMethodWarning​(String method)
        Display a warning that the specified method is simply unavailable.
      • showVariationWarning

        public static void showVariationWarning​(String str)
        Error that a particular variation of a method is unavailable (even though other variations are). For instance, if vertex(x, y, u, v) is not available, but vertex(x, y) is just fine.
      • showMissingWarning

        public static void showMissingWarning​(String method)
        Display a warning that the specified method is not implemented, meaning that it could be either a completely missing function, although other variations of it may still work properly.
      • get

        public int get​(int x,
                       int y)
        ( begin auto-generated from PImage_get.xml ) Reads the color of any pixel or grabs a section of an image. If no parameters are specified, the entire image is returned. Use the x and y parameters to get the value of one pixel. Get a section of the display window by specifying an additional width and height parameter. When getting an image, the x and y parameters define the coordinates for the upper-left corner of the image, regardless of the current imageMode().

        If the pixel requested is outside of the image window, black is returned. The numbers returned are scaled according to the current color ranges, but only RGB values are returned by this function. For example, even though you may have drawn a shape with colorMode(HSB), the numbers returned will be in RGB format.

        Getting the color of a single pixel with get(x, y) is easy, but not as fast as grabbing the data directly from pixels[]. The equivalent statement to get(x, y) using pixels[] is pixels[y*width+x]. See the reference for pixels[] for more information. ( end auto-generated )

        Advanced

        Returns an ARGB "color" type (a packed 32 bit int with the color. If the coordinate is outside the image, zero is returned (black, but completely transparent).

        If the image is in RGB format (i.e. on a PVideo object), the value will get its high bits set, just to avoid cases where they haven't been set already.

        If the image is in ALPHA format, this returns a white with its alpha value set.

        This function is included primarily for beginners. It is quite slow because it has to check to see if the x, y that was provided is inside the bounds, and then has to check to see what image type it is. If you want things to be more efficient, access the pixels[] array directly.

        Parameters:
        x - x-coordinate of the pixel
        y - y-coordinate of the pixel
        See Also:
        set(int, int, int), pixels, copy(PImage, int, int, int, int, int, int, int, int)
      • get

        public PImage get​(int x,
                          int y,
                          int w,
                          int h)
        Parameters:
        w - width of pixel rectangle to get
        h - height of pixel rectangle to get
      • get

        public PImage get()
        Returns a copy of this PImage. Equivalent to get(0, 0, width, height). Deprecated, just use copy() instead.
      • set

        public void set​(int x,
                        int y,
                        int c)
        ( begin auto-generated from PImage_set.xml ) Changes the color of any pixel or writes an image directly into the display window.

        The x and y parameters specify the pixel to change and the color parameter specifies the color value. The color parameter is affected by the current color mode (the default is RGB values from 0 to 255). When setting an image, the x and y parameters define the coordinates for the upper-left corner of the image, regardless of the current imageMode().

        Setting the color of a single pixel with set(x, y) is easy, but not as fast as putting the data directly into pixels[]. The equivalent statement to set(x, y, #000000) using pixels[] is pixels[y*width+x] = #000000. See the reference for pixels[] for more information. ( end auto-generated )
        Parameters:
        x - x-coordinate of the pixel
        y - y-coordinate of the pixel
        c - any value of the color datatype
        See Also:
        PImage.get(int, int, int, int), PImage.pixels, PImage.copy(PImage, int, int, int, int, int, int, int, int)
      • set

        public void set​(int x,
                        int y,
                        PImage img)

        Advanced

        Efficient method of drawing an image's pixels directly to this surface. No variations are employed, meaning that any scale, tint, or imageMode settings will be ignored.
        Parameters:
        img - image to copy into the original image
      • mask

        public void mask​(PImage img)
        ( begin auto-generated from PImage_mask.xml ) Masks part of an image from displaying by loading another image and using it as an alpha channel. This mask image should only contain grayscale data, but only the blue color channel is used. The mask image needs to be the same size as the image to which it is applied.

        In addition to using a mask image, an integer array containing the alpha channel data can be specified directly. This method is useful for creating dynamically generated alpha masks. This array must be of the same length as the target image's pixels array and should contain only grayscale data of values between 0-255. ( end auto-generated )

        Advanced

        Set alpha channel for an image. Black colors in the source image will make the destination image completely transparent, and white will make things fully opaque. Gray values will be in-between steps.

        Strictly speaking the "blue" value from the source image is used as the alpha color. For a fully grayscale image, this is correct, but for a color image it's not 100% accurate. For a more accurate conversion, first use filter(GRAY) which will make the image into a "correct" grayscale by performing a proper luminance-based conversion.

        Parameters:
        img - image to use as the mask
      • filter

        public void filter​(int kind)
      • filter

        public void filter​(int kind,
                           float param)
        ( begin auto-generated from PImage_filter.xml ) Filters an image as defined by one of the following modes:

        THRESHOLD - converts the image to black and white pixels depending if they are above or below the threshold defined by the level parameter. The level must be between 0.0 (black) and 1.0(white). If no level is specified, 0.5 is used.

        GRAY - converts any colors in the image to grayscale equivalents

        INVERT - sets each pixel to its inverse value

        POSTERIZE - limits each channel of the image to the number of colors specified as the level parameter

        BLUR - executes a Guassian blur with the level parameter specifying the extent of the blurring. If no level parameter is used, the blur is equivalent to Guassian blur of radius 1

        OPAQUE - sets the alpha channel to entirely opaque

        ERODE - reduces the light areas with the amount defined by the level parameter

        DILATE - increases the light areas with the amount defined by the level parameter ( end auto-generated )

        Advanced

        Method to apply a variety of basic filters to this image.

        • filter(BLUR) provides a basic blur.
        • filter(GRAY) converts the image to grayscale based on luminance.
        • filter(INVERT) will invert the color components in the image.
        • filter(OPAQUE) set all the high bits in the image to opaque
        • filter(THRESHOLD) converts the image to black and white.
        • filter(DILATE) grow white/light areas
        • filter(ERODE) shrink white/light areas
        Luminance conversion code contributed by toxi

        Gaussian blur code contributed by Mario Klingemann

        Parameters:
        kind - Either THRESHOLD, GRAY, OPAQUE, INVERT, POSTERIZE, BLUR, ERODE, or DILATE
        param - unique for each, see above
      • copy

        public void copy​(int sx,
                         int sy,
                         int sw,
                         int sh,
                         int dx,
                         int dy,
                         int dw,
                         int dh)
        ( begin auto-generated from PImage_copy.xml ) Copies a region of pixels from one image into another. If the source and destination regions aren't the same size, it will automatically resize source pixels to fit the specified target region. No alpha information is used in the process, however if the source image has an alpha channel set, it will be copied as well.

        As of release 0149, this function ignores imageMode(). ( end auto-generated )
        Parameters:
        sx - X coordinate of the source's upper left corner
        sy - Y coordinate of the source's upper left corner
        sw - source image width
        sh - source image height
        dx - X coordinate of the destination's upper left corner
        dy - Y coordinate of the destination's upper left corner
        dw - destination image width
        dh - destination image height
        See Also:
        PGraphics.alpha(int), PImage.blend(PImage, int, int, int, int, int, int, int, int, int)
      • copy

        public void copy​(PImage src,
                         int sx,
                         int sy,
                         int sw,
                         int sh,
                         int dx,
                         int dy,
                         int dw,
                         int dh)
        Parameters:
        src - an image variable referring to the source image.
      • 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)
        ( begin auto-generated from PImage_blend.xml ) Blends a region of pixels into the image specified by the img parameter. These copies utilize full alpha channel support and a choice of the following modes to blend the colors of source pixels (A) with the ones of pixels in the destination image (B):

        BLEND - linear interpolation of colours: C = A*factor + B

        ADD - additive blending with white clip: C = min(A*factor + B, 255)

        SUBTRACT - subtractive blending with black clip: C = max(B - A*factor, 0)

        DARKEST - only the darkest colour succeeds: C = min(A*factor, B)

        LIGHTEST - only the lightest colour succeeds: C = max(A*factor, B)

        DIFFERENCE - subtract colors from underlying image.

        EXCLUSION - similar to DIFFERENCE, but less extreme.

        MULTIPLY - Multiply the colors, result will always be darker.

        SCREEN - Opposite multiply, uses inverse values of the colors.

        OVERLAY - A mix of MULTIPLY and SCREEN. Multiplies dark values, and screens light values.

        HARD_LIGHT - SCREEN when greater than 50% gray, MULTIPLY when lower.

        SOFT_LIGHT - Mix of DARKEST and LIGHTEST. Works like OVERLAY, but not as harsh.

        DODGE - Lightens light tones and increases contrast, ignores darks. Called "Color Dodge" in Illustrator and Photoshop.

        BURN - Darker areas are applied, increasing contrast, ignores lights. Called "Color Burn" in Illustrator and Photoshop.

        All modes use the alpha information (highest byte) of source image pixels as the blending factor. If the source and destination regions are different sizes, the image will be automatically resized to match the destination size. If the srcImg parameter is not used, the display window is used as the source image.

        As of release 0149, this function ignores imageMode(). ( end auto-generated )
        Parameters:
        src - an image variable referring to the source image
        sx - X coordinate of the source's upper left corner
        sy - Y coordinate of the source's upper left corner
        sw - source image width
        sh - source image height
        dx - X coordinate of the destinations's upper left corner
        dy - Y coordinate of the destinations's upper left corner
        dw - destination image width
        dh - destination image height
        mode - Either BLEND, ADD, SUBTRACT, LIGHTEST, DARKEST, DIFFERENCE, EXCLUSION, MULTIPLY, SCREEN, OVERLAY, HARD_LIGHT, SOFT_LIGHT, DODGE, BURN
        See Also:
        alpha(int), PImage.copy(PImage, int, int, int, int, int, int, int, int), PImage.blendColor(int,int,int)
      • mainThread

        public static PApplet.MainThreadContext mainThread()
        Access the main thread context.
        Returns:
        main thread context