From c7caf60173314248a7782000f9301a65aa689eed Mon Sep 17 00:00:00 2001 From: cale bradbury Date: Fri, 18 Nov 2016 00:48:07 -0400 Subject: [PATCH 1/2] Update README.md --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index b1e562a..26c9bc2 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,8 @@ $ ! ; Clear temporary storage : 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* @@ -127,4 +129,4 @@ h ; percentage of canvas height > 2,2;> 4,4;> 6,6;> 8,8 # Symmetric Light > 1,1 600x;> 2,2 600x;> 3,3 600x;> 4,4 600x -``` \ No newline at end of file +``` From 7bc62d185024c485e386de941b3b686be6313ed4 Mon Sep 17 00:00:00 2001 From: cale bradbury Date: Fri, 18 Nov 2016 00:51:44 -0400 Subject: [PATCH 2/2] Added chromatic aberration filter --- scripts/modules/filter.js | 73 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/scripts/modules/filter.js b/scripts/modules/filter.js index a462655..c52ef3e 100644 --- a/scripts/modules/filter.js +++ b/scripts/modules/filter.js @@ -16,6 +16,9 @@ function Filter(element) case "saturation": this.filter_saturation(this.pixels(),p); break; + case "chromatic": + this.filter_chromatic(this.pixels(),p); + break; } } @@ -41,10 +44,78 @@ function Filter(element) ronin.canvas.context().putImageData(pixels, 0, 0, 0, 0, pixels.width, pixels.height); } + this.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