Skip to content

Instantly share code, notes, and snippets.

@jshaw
Created December 12, 2021 22:56
Embed
What would you like to do?
snippet for interpreting, manipulating and displaying video
if(label == "Start"){
flippedVideo.loadPixels();
noStroke();
for (let y = 0; y < flippedVideo.height; y += 8) {
for (let x = 0; x < flippedVideo.width; x += 8) {
let offset = ((y*flippedVideo.width)+x)*4;
fill(flippedVideo.pixels[offset],
flippedVideo.pixels[offset+1],
flippedVideo.pixels[offset+2]);
rect(x, y, 8, 8);
}
}
} else if( label == "Faster"){
flippedVideo.loadPixels();
fill("black")
for (let cy = 0; cy < flippedVideo.height; cy += 10) {
for (let cx = 0; cx < flippedVideo.width; cx += 5) {
let offset = ((cy*flippedVideo.width)+cx)*4;
let xpos = (cx / flippedVideo.width) * flippedVideo.width;
let ypos = (cy / flippedVideo.height) * flippedVideo.height;
rect(xpos, ypos, 10,
10 * (flippedVideo.pixels[offset+1]/255));
}
}
} else {
image(flippedVideo, 0, 0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment