Static p5_sys::global::textureMode [−][src]
pub static textureMode: TextureModeInternalType
Expand description
Sets the coordinate space for texture mapping. The default mode is IMAGE which refers to the actual coordinates of the image. NORMAL refers to a normalized space of values ranging from 0 to 1. This function only works in WEBGL mode.
With IMAGE, if an image is 100 x 200 pixels, mapping the image onto the entire size of a quad would require the points (0,0) (100, 0) (100,200) (0,200). The same mapping in NORMAL is (0,0) (1,0) (1,1) (0,1).
Examples
let img; function preload() { img = loadImage('assets/laDefense.jpg'); } function setup() { createCanvas(100, 100, WEBGL); } function draw() { texture(img); textureMode(NORMAL); beginShape(); vertex(-50, -50, 0, 0); vertex(50, -50, 1, 0); vertex(50, 50, 1, 1); vertex(-50, 50, 0, 1); endShape(); }
Parameters
mode
either IMAGE or NORMAL