xxxxxxxxxx
82
var video;
var canvas;
var x = 0;
var slitWidth = 1;
var brojac = 0;
frameRate = 120;
//var from = color(218, 165, 32);
//var to = color(72, 61, 139);
// Try changing to HSB.
//var interA = lerpColor(from, to, 0.33);
//var interB = lerpColor(from, to, 0.66);
function setup() {
noStroke();
//colorMode(HSB, 255, 130, 30, 50);
//colorMode(HSL,200, 30, 90, 0.5);
/*colorMode(HSL);
var c = color(180, 150, 160);
fill(c);
//rect(15, 20, 35, 60);
var value = saturation(c); // Sets 'value' to 126
fill(value);
//rect(50, 20, 35, 60);*/
canvas = createCanvas(screen.width, screen.height);
pixelDensity(1);
video = createCapture (VIDEO, ready);
video.size (width, height);
video.hide();
graph = createGraphics(screen.width, screen.height);
}
function ready() {
readyCheck = true;
console.log('work');
}
function draw() {
//colorMode(HSB,50);
video.loadPixels();
var w = video.width;
var h = video.height;
graph.background(255);
graph.image(video, w/2, 0, slitWidth, h);
//graph.loadPixels();
/*for (var i = 0; i < graph.pixels.length; i += 4) {
//graph.pixels[i] = 0;
}*/
//graph.updatePixels();
copy (graph, w/2, 0, slitWidth, h, x, 0, slitWidth, h);
x = x + slitWidth;
if (x > width) {
//console.log(graph);
save(canvas, 'myCanvas' + brojac + '.jpg');
brojac++;
x = 0;
}
}