Skip to content

Commit

Permalink
Fixing the pixel wrapping algorithm.
Browse files Browse the repository at this point in the history
  • Loading branch information
reu committed Mar 24, 2013
1 parent 29c4ede commit 7b916c6
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/screen.js
Expand Up @@ -28,17 +28,11 @@
*/
this.setPixel = function(x, y) {
// Wrap around pixels that overflow the screen
if (x > this.columns) {
x -= this.columns;
} else if (x < 0) {
x += this.columns;
}
if (x > this.columns - 1) while (x > this.columns - 1) x -= this.columns;
if (x < 0) while (x < 0) x += this.columns;

if (y > this.rows) {
y -= this.rows;
} else if (y < 0) {
y += this.rows;
}
if (y > this.rows - 1) while (y > this.rows - 1) y -= this.rows;
if (y < 0) while (y < 0) y += this.rows;

var location = x + (y * this.columns);
this.bitMap[location] = this.bitMap[location] ^ 1;
Expand Down

0 comments on commit 7b916c6

Please sign in to comment.