Hello,
This topic inspired me!
Something I worked on:
Example of random tiling < Click here to see code!
// Pixel Manipulation
// v1.0.0
// GLV 2021-05-30
let img;
let cap;
function setup()
{
createCanvas(640, 480); // Set to video size
img = createGraphics(width, height);
pixelDensity(1);
img.pixelDensity(1);
cap = createCapture(VIDEO);
cap.hide();
//d = pixelDensity(); // Future! See references.
}
function draw()
{
cap.loadPixels();
img.loadPixels();
tilesX = 10;
tilesY = 10;
//samples = map(mouseX, 0, width, 0, 2000);
samples = 200;
for (let i = 0; i<samples; i++)
{
x = (random(width))| 1; // Converts to int
y = int(random(height)); // Converts to int
let loc = x + y*cap.width;
// Copy a tile from capture to pixels
for (let xt = x; xt < x+tilesX; xt++)
{
for (let yt = y; yt < y+tilesY; yt++)
{
let loct = (xt + yt*cap.width)*4;
img.pixels[loct + 0] = cap.pixels[loct + 0]; //r
img.pixels[loct + 1] = cap.pixels[loct + 1]; //g
img.pixels[loct + 2] = cap.pixels[loct + 2]; //b
img.pixels[loct + 3] = cap.pixels[loct + 3]; //a
}
}
}
img.updatePixels();
image(img, 0, 0);
// Display data
fill(255);
stroke(1);
textSize(18);
text(frameRate()|1, 10, 20);
text(samples, 10, 40);
}
A very cool effect!
:)