xxxxxxxxxx
60
// Experimental Camera, Wesley Chau, 2020
let capture;
let msgArr = ["Vibing","Do I have your attention?","Feeling thirsty","Feeling grounded","Found my light","Due for a soil change soon","Feeling lonely","Is it me or does the air feel dry","I miss when you sing to me"];
let txt;
let points = [];
function setup() {
createCanvas(640, 480);
capture = createCapture(VIDEO);
capture.size(640, 480);
capture.hide();
pixelDensity(1);
noStroke();
txt = "";
}
function draw() {
image(capture, 0, 0, width, height); //draws video on canvas as image
capture.loadPixels();
drawPoints(); //draws point and text statement
// updatePixels();
}
function mousePressed() {
addPoint(mouseX, mouseY);
}
function addPoint(xPos,yPos){ // draws new point at any given x,y on the canvas with new random message
let newPoint = {
x: xPos,
y: yPos,
txt: msgArr[int(random(msgArr.length))]
}
points.push(newPoint);
}
function drawPoints(){
textSize(16);
textAlign(LEFT);
for(let i = 0; i < points.length; i ++){
stroke(0, 250, 0);
strokeWeight(2);
noFill();
circle(points[i].x, points[i].y, 6);
}
for(let i = 0; i < points.length; i ++){
fill(0, 250, 0);
noStroke();
text(points[i].txt, points[i].x+8, points[i].y-8)
}
}