mirror of
https://github.com/Cametendo/EMVs-Creative-coding.git
synced 2026-06-20 17:45:02 +02:00
Push after two months, oops
This commit is contained in:
38
Week-2/Pictures/image-filter.js
Normal file
38
Week-2/Pictures/image-filter.js
Normal file
@@ -0,0 +1,38 @@
|
||||
let img;
|
||||
|
||||
function preload() {
|
||||
img = loadImage("/Images/monitoring-miku.png");
|
||||
}
|
||||
|
||||
function setup() {
|
||||
createCanvas(600, 600);
|
||||
pixelDensity(1);
|
||||
}
|
||||
|
||||
function draw() {
|
||||
background(0);
|
||||
image(img, 100, 100, 400, 400);
|
||||
/* img.loadPixels();
|
||||
for (let i = 0; i < img.pixels.length; i += 4) {
|
||||
let red = img.pixels[i + 0];
|
||||
let green = img.pixels[i + 1];
|
||||
let blue = img.pixels[i + 2];
|
||||
let alpha = img.pixels[i + 3];
|
||||
img.pixels[i + 0] = red;
|
||||
img.pixels[i + 1] = green;
|
||||
img.pixels[i + 2] = blue;
|
||||
img.pixels[i + 3] = alpha;
|
||||
}
|
||||
img.updatePixels(); */
|
||||
img.loadPixels();
|
||||
for (let y = 0; y < height; y++) {
|
||||
for (let x = 0; x < width; x++) {
|
||||
const index = (x + y * width) * 4;
|
||||
img.pixels[index + 0] = mouseX;
|
||||
img.pixels[index + 1] = mouseY;
|
||||
img.pixels[index + 2] = y;
|
||||
img.pixels[index + 3] = 100;
|
||||
}
|
||||
}
|
||||
img.updatePixels();
|
||||
}
|
||||
Reference in New Issue
Block a user