[−][src]Static p5_sys::global::loadPixels
pub static loadPixels: LoadPixelsInternalType
Loads the pixel data for the display window into the pixels[] array. This function must always be called before reading from or writing to pixels[]. Note that only changes made with set() or direct manipulation of pixels[] will occur.
Examples
let img;
function preload() {
img = loadImage('assets/rockies.jpg');
}
function setup() {
image(img, 0, 0, width, height);
let d = pixelDensity();
let halfImage = 4 * (width * d) * (height * d / 2);
loadPixels();
for (let i = 0; i < halfImage; i++) {
pixels[i + halfImage] = pixels[i];
}
updatePixels();
}