a port of the Processing Visualization Language
Name

createGraphics()

Examples
example pic
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. P2D is not yet implemented, but will be available in a future release. 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
Usage Web & Application
Related PGraphics

This reference is licensed under the CC BY-NC-SA 2.0 license:

Creative Commons License
Fork me on GitHub