Skip to content

Commit

Permalink
added a tenary in motionweight to correctly handle the right most pix…
Browse files Browse the repository at this point in the history
…els in the pixelarray
  • Loading branch information
alonisser committed Oct 7, 2012
1 parent 8f438c9 commit f0c5da4
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion webcam-swiper-0.1.js
Expand Up @@ -150,7 +150,7 @@ function initializeWebcamSwiper() {
var i = 0; var i = 0;
while (i < dataLength) { while (i < dataLength) {
if (Math.abs(previousData[i] - currentData[i]) > PIXEL_CHANGE_THRESHOLD) { if (Math.abs(previousData[i] - currentData[i]) > PIXEL_CHANGE_THRESHOLD) {
motionWeight += ((i / 4) % canvasWidth) - (canvasWidth / 2); motionWeight += (((i / 4) % canvasWidth) == 0 ? ((i-1) / 4 % canvasWidth) : ((i / 4) % canvasWidth)- (canvasWidth / 2));


} }
i += 4; i += 4;
Expand All @@ -177,6 +177,7 @@ function initializeWebcamSwiper() {


// Fully opaque // Fully opaque
newData[i+3] = 255; newData[i+3] = 255;
// returning an average intensity of all pixels. Used for calibrating sensitivity based on room light level.
lightLevel += newData[i]; //combining the light level in the samefunction lightLevel += newData[i]; //combining the light level in the samefunction
i += 4; i += 4;


Expand Down

0 comments on commit f0c5da4

Please sign in to comment.