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. 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 |
|
||||||||
Usage | Web & Application | ||||||||
Related | PGraphics |