xxxxxxxxxx
20
let img;
function preload() {
img = loadImage('loadImage_0.png');
}
function setup() {
createCanvas(400,400, WEBGL);
background(128);
// method 1: draw an image + nofill rect
// they must be the same size
image(img, 0, 0);
noFill();
rect(0,0,100,100);
// method 2: use WEBGL, texture + rect
// the rect may be any size, image will warp
translate(-100,-100)
texture(img);
rect(0,0,40,150);
}