imageMode

Static imageMode 

Source
pub static imageMode: ImageModeInternalType
Expand description

Set image mode. Modifies the location from which images are drawn by changing the way in which parameters given to image() are interpreted. 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.

Examples

let img;
function preload() {
  img = loadImage('assets/bricks.jpg');
}
function setup() {
  imageMode(CORNER);
  image(img, 10, 10, 50, 50);
}
let img;
function preload() {
  img = loadImage('assets/bricks.jpg');
}
function setup() {
  imageMode(CORNERS);
  image(img, 10, 10, 90, 40);
}
let img;
function preload() {
  img = loadImage('assets/bricks.jpg');
}
function setup() {
  imageMode(CENTER);
  image(img, 50, 50, 80, 80);
}

Parameters

mode either CORNER, CORNERS, or CENTER