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

imageMode()

Examples
example pic
PImage img;

void setup() {
  img = loadImage("laDefense.jpg");
}

void draw() {
  imageMode(CORNER);
  image(img, 10, 10, 50, 50);  // Draw image using CORNER mode
}
example pic
PImage img;

void setup() {
  img = loadImage("laDefense.jpg");
}

void draw() {
  imageMode(CORNERS);
  image(img, 10, 10, 90, 40);  // Draw image using CORNERS mode
}
example pic
PImage img;

void setup() {
  img = loadImage("laDefense.jpg");
}

void draw() {
  imageMode(CENTER);
  image(img, 50, 50, 80, 80);  // Draw image using CENTER mode
}
Description Modifies the location from which images are drawn by changing the way in which parameters given to image() are intepreted.

The default mode is imageMode(CORNER), which interprets the second and third parameters of image() as the upper-left corner of the image. If two additional parameters are specified, they are used to set the image's width and height.

imageMode(CORNERS) interprets the second and third parameters of image() as the location of one corner, and the fourth and fifth parameters as the opposite corner.

imageMode(CENTER) interprets the second and third parameters of image() as the image's center point. If two additional parameters are specified, they are used to set the image's width and height.

The parameter must be written in ALL CAPS because Processing is a case-sensitive language.
Syntax
imageMode(mode)
Parameters
mode int: either CORNER, CORNERS, or CENTER
Returnsvoid
RelatedloadImage()
PImage
image()
background()
Updated on January 1, 2021 03:38:08am EST