xxxxxxxxxx
42
// Time interval for picking new position
let interval = 60;
// Position
let x = 0;
let y = 0;
let z = 0;
let video;
let a = 0;
function setup() {
createCanvas(windowWidth, windowWidth*480/640);
video = createCapture(VIDEO);
video.hide();
noStroke();
//imageMode(CENTER);
}
function draw() {
//background('white');
push();
translate(width, 0);
scale(-1, 1);
image(video, 0, 0, width, (width*480)/640);
pop();
// Every second, pick a new random position
if (frameCount % interval == 0) {
x = random(width);
y = random(height);
z = random(100);
interval = floor(random(300, 1500));
background(255);
}
a++;
// Fill a red spot
stroke(255, 0, 0, a);
strokeWeight(50);
// Draw the spot
point(x, y);
}