From 2fd9770440a45d9c7412e8cd65ca256093ae3d55 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Fri, 18 Nov 2016 07:33:02 -0800 Subject: [PATCH] Moved fiters to their own files. --- README.md | 5 ++- index.html | 5 ++- scripts/modules/filter.chromatic.js | 38 ++++++++++++++++++ scripts/modules/filter.js | 59 +--------------------------- scripts/modules/filter.saturation.js | 15 +++++++ 5 files changed, 61 insertions(+), 61 deletions(-) create mode 100644 scripts/modules/filter.chromatic.js create mode 100644 scripts/modules/filter.saturation.js diff --git a/README.md b/README.md index 26c9bc2..7ce1d9f 100644 --- a/README.md +++ b/README.md @@ -65,11 +65,12 @@ $ ! ; Clear temporary storage ##Filters* ``` : saturation 0.5 ; Set image saturation to 0.5 +: chromatic 10 ; Shifts, from center, pixels red value by 10, green by 5, blue by 0 +: chromatic 8 0 16 ; Shifts, from center, pixels red value by 8, green by 0, blue by 16 + : balance red 0.9 0.4 0.7 ; Set color balance red to 0.9 0.4 0.7 : balance white 0.7 0.7 0.7 ; Set color balance white to 0.7 0.7 0.7 : sharpen 0.5 ; Sharpen image to 50% -: chromatic 10 ; Shifts, from center, pixels red value by 10, green by 5, blue by 0 -: chromatic 8 0 16 ; Shifts, from center, pixels red value by 8, green by 0, blue by 16 ``` ##Translate* diff --git a/index.html b/index.html index d0c950c..88f88fa 100644 --- a/index.html +++ b/index.html @@ -12,7 +12,6 @@ - @@ -21,6 +20,10 @@ + + + + diff --git a/scripts/modules/filter.chromatic.js b/scripts/modules/filter.chromatic.js new file mode 100644 index 0000000..e162c3e --- /dev/null +++ b/scripts/modules/filter.chromatic.js @@ -0,0 +1,38 @@ +Filter.prototype.filter_chromatic = function(pixels = this.pixels(),p = null) +{ + var s; + if(p.length === 0) + s = {r:2,g:2,b:2}; + else if(p.length < 3) + s = {r:parseFloat(p[0]), g:parseFloat(p[0])*.5, b:0}; + else + s = {r:parseFloat(p[0]), g:parseFloat(p[1]), b:parseFloat(p[2])}; + var hw = pixels.width*.5; + var hh = pixels.height*.5; + var maxLength = Math.sqrt(hw*hw+hh*hh); + var output = new ImageData(pixels.width, pixels.height); + for (var i=0; i