From a597a2c988bd1844053373010af50d251eddef3f Mon Sep 17 00:00:00 2001 From: Martijn de Boer Date: Fri, 5 Jan 2018 00:03:37 +0100 Subject: [PATCH] Update code quality --- drivers/driver.js | 5 +---- www/js/app.js | 50 ++++++++++------------------------------------- 2 files changed, 11 insertions(+), 44 deletions(-) diff --git a/drivers/driver.js b/drivers/driver.js index 55cb4be..e7aa95a 100644 --- a/drivers/driver.js +++ b/drivers/driver.js @@ -55,10 +55,7 @@ class Driver { clear( r = 0, g = 0, b = 0, a = 1 ) { for ( let x = 0; x < this.width; x++ ) { for ( let y = 0; y < this.height; y++) { - this.matrix[x][y].r = r; - this.matrix[x][y].g = g; - this.matrix[x][y].b = b; - this.matrix[x][y].a = a; + this.setPikel( x, y, r, g, b, a ); } } } diff --git a/www/js/app.js b/www/js/app.js index 79ca37c..b344e75 100644 --- a/www/js/app.js +++ b/www/js/app.js @@ -42,40 +42,13 @@ class App createPalette() { let paletteItBe = [ - "0 0 0", - "20 12 28", - "68 36 52", - "48 52 109", - "78 74 78", - "133 76 48", - "52 101 36", - "208 70 72", - "117 113 97", - "89 125 206", - "210 125 44", - "133 149 161", - "109 170 44", - "210 170 153", - "109 194 202", - "218 212 94", - "222 238 214", - "0 71 189", - "2 136 217", - "7 185 252", - "0 149 67", - "0 171 56", - "154 240 0", - "255 179 0", - "255 206 0", - "255 239 59", - "255 206 0", - "255 230 59", - "234 0 52", - "253 71 3", - "255 139 42", - "130 0 172", - "182 16 191", - "204 114 245" + "0 0 0", "20 12 28", "68 36 52", "48 52 109", "78 74 78", "133 76 48", + "52 101 36", "208 70 72", "117 113 97", "89 125 206", "210 125 44", + "133 149 161", "109 170 44", "210 170 153", "109 194 202", "218 212 94", + "222 238 214", "0 71 189", "2 136 217", "7 185 252", "0 149 67", + "0 171 56", "154 240 0", "255 179 0", "255 206 0", "255 239 59", + "255 206 0", "255 230 59", "234 0 52", "253 71 3", "255 139 42", + "130 0 172", "182 16 191", "204 114 245" ]; let holder = document.querySelector( '#paletteHolder' ); @@ -151,13 +124,10 @@ class App let g = imageData.data[ index + 1 ]; let b = imageData.data[ index + 2 ]; - if ( r > 0 || g > 0 || b > 0 ) { + if ( r + g + b > 0 ) { obj.push( { - x: x, - y: y, - r: r, - g: g, - b: b + x: x, y: y, + r: r, g: g, b: b } ) } }