- Processing
- p5.js
- Processing.py
- Processing for Android
- Processing for Pi

- Processing Foundation

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 | ### rectMode()
Examples |
    rectMode(CORNER);  // Default rectMode is CORNER
    fill(255);  // Set fill to white
    rect(25, 25, 50, 50);  // Draw white rect using CORNER mode

    rectMode(CORNERS);  // Set rectMode to CORNERS
    fill(100);  // Set fill to gray
    rect(25, 25, 50, 50);  // Draw gray rect using CORNERS mode
    rectMode(RADIUS);  // Set rectMode to RADIUS
    fill(255);  // Set fill to white
    rect(50, 50, 30, 30);  // Draw white rect using RADIUS mode

    rectMode(CENTER);  // Set rectMode to CENTER
    fill(100);  // Set fill to gray
    rect(50, 50, 30, 30);  // Draw gray rect using CENTER mode
Description | Modifies the location from which rectangles are drawn by changing the way in which parameters given to rect() are intepreted. The default mode is rectMode(CORNER), which interprets the first two parameters of rect() as the upper-left corner of the shape, while the third and fourth parameters are its width and height. rectMode(CORNERS) interprets the first two parameters of rect() as the location of one corner, and the third and fourth parameters as the location of the opposite corner. rectMode(CENTER) interprets the first two parameters of rect() as the shape's center point, while the third and fourth parameters are its width and height. rectMode(RADIUS) also uses the first two parameters of rect() as the shape's center point, but uses the third and fourth parameters to specify half of the shapes's width and height. The parameter must be written in ALL CAPS because Processing is a case-sensitive language.
Syntax |
    rectMode(mode)
Parameters |
mode | int: either CORNER, CORNERS, CENTER, or RADIUS
Returns | void
Related | rect()

Updated on January 9, 2020 00:33:10pm EST