xxxxxxxxxx
137
let img;
function preload() {
img = loadImage("3.jpg"); //random(["1.png", "2.jpg"]));
}
function setup() {
createCanvas(img.width, img.height);
image(img, 0, 0);
if (random() > 0.7) {
// slicer vert
for (let _ = 0; _ < 20; _++) {
let h = int(random(1, img.height * 0.1));
let y = random(0, img.height - h);
let y2 = random(0, img.height - h);
let cpy = createImage(img.width, h);
cpy.copy(img, 0, y, img.width, h, 0, 0, img.width, h);
image(cpy, 0, y2);
}
}
if (random() > 0.7) {
// slicer horiz
for (let _ = 0; _ < 20; _++) {
let w = int(random(1, img.width * 0.1));
let x = random(0, img.width - w);
let x2 = random(0, img.width - w);
let cpy = createImage(w, img.height);
cpy.copy(img, x, 0, w, img.height, 0, 0, w, img.height);
image(cpy, x2, 0);
}
}
if (random() > 0.7) {
// pixellate and drip
threshold = random(10, 80); //40;
darkest = [];
let csize = 10;
let csize2 = int(csize / 2);
noStroke();
rectMode(CENTER);
img.loadPixels();
for (let y = csize2; y < img.height; y += csize) {
for (let x = csize2; x < img.width; x += csize) {
let c = color(img.get(x, y));
c.setAlpha(int(random(80, 220)));
fill(c);
rect(x, y, csize, csize);
// if (green(c) < green(darkest.c) && red(c) < red(darkest.c) && blue(c) < blue(darkest.c)) {
if (
(green(c) < threshold && red(c) < threshold && blue(c) < threshold) ||
random() > 0.99
) {
darkest.push({ x: x, y: y, c: c });
}
}
}
}
if (random() > 0.7) {
for (let d of darkest) {
fill(d.c);
while (d.y < img.height) {
d.c.setAlpha(random(20, 120));
fill(d.c);
rect(d.x, d.y, csize, csize);
d.y += csize;
}
}
}
let off = random(-50, 50);
let gfx = createGraphics(img.width, img.height);
// invert with noise
if (random() > 0.7) {
noiseDetail(random(4, 14), random(0.25, 0.75));
for (let y = 0; y < img.height; y++) {
for (let x = 0; x < img.width; x++) {
let c = color(img.get(x, y));
let c2 = color(255 - red(c), 255 - green(c), 255 - blue(c));
let n = noise(x * 0.01, y * 0.01);
let hv = floor(hue(c));
let sv = saturation(c);
let lv = lightness(c);
hv += off; //random(-20,20);
hv = constrain(hv, 0, 255);
// sv += off;//random(-20,20);
// sv = constrain(sv,0,255);
// lv += off;//random(-20,20);
// lv = constrain(lv,0,255);
if (n < 0.33) gfx.stroke(c2);
//else if (n < 0.66)
// shift
//gfx.stroke(`hsl(${hv}, ${sv}%, ${lv}%)`);
else gfx.stroke(c);
gfx.point(x, y);
}
}
}
// color shift
if (random() > 0.7) {
for (let y = 0; y < img.height; y++) {
for (let x = 0; x < img.width; x++) {
let c = img.get(x, y);
let hv = floor(hue(c));
let sv = saturation(c);
let lv = lightness(c);
hv += off; //random(-20,20);
hv = constrain(hv, 0, 255);
// sv += off;//random(-20,20);
// sv = constrain(sv,0,255);
// lv += off;//random(-20,20);
// lv = constrain(lv,0,255);
gfx.stroke(`hsl(${hv}, ${sv}%, ${lv}%)`);
gfx.point(x, y);
}
}
}
image(gfx, 0, 0);
noLoop();
}
function draw() {
// background(220);
}