Loading

PrectMode

processing

Modifies the location from which rectangles are drawn by changing the way in which parameters given to Prect are intepreted.

The default mode is CORNER, which interprets the first two parameters of Prect as the upper-left corner of the shape, while the third and fourth parameters are its width and height.

CORNERS interprets the first two parameters of Prect as the location of one corner, and the third and fourth parameters as the location of the opposite corner.

CENTER interprets the first two parameters of Prect as the shape's center point, while the third and fourth parameters are its width and height.

RADIUS also uses the first two parameters of Prect as the shape's center point, but uses the third and fourth parameters to specify half of the shape's width and height.

The parameter must be written in ALL CAPS because Processing is a case-sensitive language.

Link to original Processing doc

PrectMode is available since version 1.0.0.

See also

Signatures

Examples

// @preview image 200 100 '2D' PGraphics 255 Pbackground //white 16 PtextSize 0 'x' STORE 0x5fff0000 Pfill //red 'CORNER' PrectMode $x 50 + 50 20 20 Prect // Draw white rect using CORNER mode 'CORNER' $x 95 Ptext 0x9f0000ff Pfill //blue 'CORNERS' PrectMode $x 50 + 50 20 20 Prect // Draw white rect using CORNERS mode 'CORNERS' $x 18 Ptext 100 'x' STORE 0x5fff0000 Pfill //red 'RADIUS' PrectMode $x 50 + 50 20 20 Prect // Draw white rect using RADIUS mode 'RADIUS' $x 95 Ptext 0x9f0000ff Pfill //blue 'CENTER' PrectMode $x 50 + 50 20 20 Prect // Draw white rect using CENTER mode 'CENTER' $x 18 Ptext Pencode // 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