Skip to content

Instantly share code, notes, and snippets.

@jshaw
Created December 12, 2021 22:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jshaw/a7b5e7c03507ca8cadf29682a4b2982e to your computer and use it in GitHub Desktop.
Save jshaw/a7b5e7c03507ca8cadf29682a4b2982e to your computer and use it in GitHub Desktop.
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