Reference for Processing version 1.5. If you have a previous version, use the reference included with your software. If you see any errors or have suggestions, please let us know. If you prefer a more technical reference, visit the Processing Javadoc.

Name

### shape()

Examples

    PShape s;
    s = loadShape("bot.svg");
    smooth();
    shape(s, 10, 10, 80, 80);

    // Loading a shape when using setup() and draw()

    PShape s;

    void setup() {
      s = loadShape("bot.svg");
      smooth();
      noLoop();
    }

    void draw() {
      shape(s, 10, 10, 80, 80);
    }

Description

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 P2D, P3D, and OPENGL. Those renderers do not yet support shapes that have holes or complicated breaks.

Syntax

    shape(sh)
    shape(sh, x, y)
    shape(sh, x, y, width, height)

Parameters

sh | PShape: the shape to display
x | int or float: x-coordinate of the shape
y | int or float: y-coordinate of the shape
width | int or float: width to display the shape
height | int or float: height to display the shape

Usage | Web & Application
Related | PShape loadShape() shapeMode()

Updated on August 30, 2010 04:29:39pm EDT