Created
December 12, 2021 22:56
-
-
Save jshaw/a7b5e7c03507ca8cadf29682a4b2982e to your computer and use it in GitHub Desktop.
snippet for interpreting, manipulating and displaying video
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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