This reference is for Processing 3.0+. If you have a previous version, use the reference included with your software in the Help menu. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Core Javadoc and Libraries Javadoc.
Name | PShape |
||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Examples | PShape s; void setup() { size(100, 100); // The file "bot.svg" must be in the data folder // of the current sketch to load successfully s = loadShape("bot.svg"); } void draw() { shape(s, 10, 10, 80, 80); } PShape square; // The PShape object void setup() { size(100, 100); // Creating the PShape as a square. The corner // is 0,0 so that the center is at 40,40 square = createShape(RECT, 0, 0, 80, 80); } void draw() { shape(square, 10, 10); } | ||||||||||||||||||||||||||||||||||||||||||||||
Description |
Datatype for storing shapes. Before a shape is used, it must be loaded with the loadShape() or created with the createShape(). The shape() function is used to draw the shape to the display window. Processing can currently load and display SVG (Scalable Vector Graphics) and OBJ shapes. OBJ files can only be opened using the P3D renderer. The loadShape() function supports SVG files created with Inkscape and Adobe Illustrator. It is not a full SVG implementation, but offers some straightforward support for handling vector data.
The PShape object contains a group of methods that can operate on the shape data. Some of the methods are listed below, but the full list used for creating and modifying shapes is available here in the Processing Javadoc. To create a new shape, use the createShape() function. Do not use the syntax new PShape(). |
||||||||||||||||||||||||||||||||||||||||||||||
Fields |
| ||||||||||||||||||||||||||||||||||||||||||||||
Methods |
| ||||||||||||||||||||||||||||||||||||||||||||||
Constructor | PShape(g, kind, params) | ||||||||||||||||||||||||||||||||||||||||||||||
Related | loadShape() createShape() shapeMode() |
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.