Search processing.org:

Reference for Processing version 1.0+. If you have a previous version, use the reference included with your software. If you see any errors or have any comments, let us know.

Name | ### createGraphics()
Examples |
    PGraphics pg;

    void setup() {
      size(100, 100);
      pg = createGraphics(80, 80, P3D);
    }

    void draw() {
      pg.beginDraw();
      pg.background(102);
      pg.stroke(255);
      pg.line(40, 40, mouseX, mouseY);
      pg.endDraw();
      image(pg, 10, 10);
    }
Description | Creates and returns a new PGraphics object of the types P2D, P3D, and JAVA2D. Use this class if you need to draw into an off-screen graphics buffer. It's not possible to use createGraphics() with OPENGL, because it doesn't allow offscreen use. The DXF and PDF renderers require the filename parameter. It's important to call any drawing commands between beginDraw() and endDraw() statements. This is also true for any commands that affect drawing, such as smooth() or colorMode(). Unlike the main drawing surface which is completely opaque, surfaces created with createGraphics() can have transparency. This makes it possible to draw into a graphics and maintain the alpha channel. 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 (as of release 0127), this means that text characters will be opaque blocks. This will be fixed in a future release (Bug 641).
Syntax |
    createGraphics(width, height, renderer)
    createGraphics(width, height, renderer, filename)
Parameters |
width | int: width in pixels
height | int: height in pixels
renderer | Either P2D (not yet implemented), P3D, JAVA2D, PDF, DXF
filename | String: the name of the file
Returns | PImage or null
Usage | Web & Application
Related | PGraphics

Updated on November 28, 2008 04:32:47pm PST