GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Processing
  • Download
  • Reference
  • Environment
  • Libraries
  • Tools
  • Wiki
  • Tutorials
  • Examples
  • Books
  • Forum
  • Overview
  • People
  • Privacy

This view

  • Original page
  • New address

GeezerVison is showing processing.org — PShape / Reference

Reference+
Documentation→Reference→Shape

Class Name

PShape

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().

Examples

  •   
    PShape s;
    
    void setup() {
      size(400, 400);
      // 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, 40, 40, 320, 320);
    }
  • 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);
    }
    

Constructors

  • PShape(g, kind, params)

Fields

  • widthShape document width
  • heightShape document height

Methods

  • isVisible()Returns a boolean value true if the image is set to be visible, false if not
  • setVisible()Sets the shape to be visible or invisible
  • disableStyle()Disables the shape's style data and uses Processing styles
  • enableStyle()Enables the shape's style data and ignores the Processing styles
  • beginContour()Starts a new contour
  • endContour()Ends a contour
  • beginShape()Starts the creation of a new PShape
  • endShape()Finishes the creation of a new PShape
  • getChildCount()Returns the number of children
  • getChild()Returns a child element of a shape as a PShape object
  • addChild()Adds a new child
  • getVertexCount()Returns the total number of vertices as an int
  • getVertex()Returns the vertex at the index position
  • setVertex()Sets the vertex at the index position
  • setFill()Set the fill value
  • setStroke()Set the stroke value
  • translate()Displaces the shape
  • rotateX()Rotates the shape around the x‑axis
  • rotateY()Rotates the shape around the y‑axis
  • rotateZ()Rotates the shape around the z‑axis
  • rotate()Rotates the shape
  • scale()Increases and decreases the size of a shape
  • resetMatrix()Replaces the current matrix of a shape with the identity matrix

Related

  • loadShape()
  • createShape()
  • shapeMode()
Creative Commons License

This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.