xxxxxxxxxx
32
let myImage;
function setup() {
createCanvas(100, 100);
pixelDensity(1);
//p5image
myImage = createImage(width, height);
background("red");
}
function draw() {
myImage.loadPixels();
for (let i = 0; i < myImage.pixels.length; i += 4) {
//red
myImage.pixels[i] = 255;
//green
myImage.pixels[i + 1]++;
//blue
myImage.pixels[i + 2]++;
//alpha
myImage.pixels[i + 3] = 255;
}
myImage.updatePixels();
image(myImage, 0, 0);
}