xxxxxxxxxx
42
let video;
let slider;
let font;
function setup() {
createCanvas(400, 400);
video = createCapture(VIDEO);
video.size(400, 400);
video.hide()
radio = createRadio();
radio.option("yes");
radio.option("no");
radio.position(CENTER);
noStroke();
slider = createSlider(3,100,100)
slider.position(10, 10)
}
function draw() {
background(255);
video.loadPixels()
let stepSize = slider.value();
textFont('Courier New');
text("welcome. this is a camera application.\nit will capture the light in view and interpret data and \ndisplay the color values as pixels.\nit will not store any data.\n\nthis camrea uses a filter that enlarges the pixels \nand only displays the green values captured.\nyou can use the slider to adjust the size of pixels.\n\nto turn the camera on select yes.\nto turn it off select no.",0,100);
if(radio.value() == "yes"){
for (let x = 0; x < video.width; x += stepSize) {
for (let y = 0; y < video.height; y += stepSize) {
let index = ((y*video.width) + x) * 4;
let r = video.pixels[index];
let g = video.pixels[index + 1];
let b = video.pixels[index + 2];
fill(r/2, g, b/2);
rect(x, y, stepSize, stepSize);
}
}
}
}