Created
April 22, 2017 12:56
-
-
Save catarak/a721b7a3b67dbb726315bc0529843f06 to your computer and use it in GitHub Desktop.
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
var capture; | |
var stepSize = 5; | |
function setup() { | |
createCanvas(400, 300); | |
capture = createCapture(VIDEO); | |
capture.size(400, 300); | |
capture.hide(); | |
rectMode(CENTER); | |
noStroke(); | |
} | |
function draw() { | |
background(50); | |
fill(255); | |
capture.loadPixels(); | |
for (var cy = 0; cy < capture.height; cy += stepSize) { | |
for (var cx = 0; cx < capture.width; cx += stepSize) { | |
var offset = ((cy*capture.width)+cx)*4; | |
var xpos = (cx / capture.width) * width; | |
var ypos = (cy / capture.height) * height; | |
var pixelBrightness = capture.pixels[offset+1]/255; //TECHNICALLY the green brightness | |
rect(width - xpos, ypos, stepSize, stepSize*pixelBrightness); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment