Permalink
Browse files

added a tenary in motionweight to correctly handle the right most pix…

…els in the pixelarray
  • Loading branch information...
1 parent 8f438c9 commit f0c5da4d9bd19a10b4b88aa8d361fb25167fd5fa @alonisser alonisser committed Oct 7, 2012
Showing with 2 additions and 1 deletion.
  1. +2 −1 webcam-swiper-0.1.js
View
@@ -150,7 +150,7 @@ function initializeWebcamSwiper() {
var i = 0;
while (i < dataLength) {
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));
@alonisser

alonisser Oct 8, 2012

Contributor

am I understanding this right? is the right most pixel gets a zero value from (i/4)%canvaswidth?

}
i += 4;
@@ -177,6 +177,7 @@ function initializeWebcamSwiper() {
// Fully opaque
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
i += 4;

0 comments on commit f0c5da4

Please sign in to comment.