Add completed slit scanner

This commit is contained in:
Lev
2021-07-28 15:36:02 -05:00
parent 32ff798a0e
commit a3711c3c7a
5 changed files with 82 additions and 0 deletions

View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>graphicsProgramming - Coursera</title>
<script src="libraries/p5.min.js" type="text/javascript"></script>
<script src="libraries/p5.sound.min.js" type="text/javascript"></script>
<script src="sketch.js" type="text/javascript"></script>
<style> body {padding: 0; margin: 0;} canvas {vertical-align: top;} </style>
</head>
<body>
</body>
</html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,36 @@
let video;
let strip;
let strips=[];
let scan;
function setup() {
createCanvas(640 * 2, 480);
pixelDensity(1);
video = createCapture(VIDEO);
video.hide();
scan = createGraphics(640, 480);
}
function draw() {
background(150);
image(video, 0, 0);
// STEP 1 - write your cocde below
strip = video.get(video.width/2, 0, 1, video.height);
// save to scan object
scan.image(strip, frameCount%640 - 1, 0);
// or store it in an array
//strips[frameCount%640 - 1] = strip;
push();
stroke(255, 0, 0);
line(video.width / 2, 0, video.width / 2, video.height);
pop();
// STEP 2 - write your code below
// one of the two methods below will work
image(scan, 640, 0);
//for(let i=0; i<strips.length; i++)
// image(strips[i], 640 + i, 0);
}