diff options
author | Jose Antonio Marquez | 2012-02-15 20:37:48 -0800 |
---|---|---|
committer | Jose Antonio Marquez | 2012-02-15 20:37:48 -0800 |
commit | 89b5e793ea88ef235b54b6e1d1c379698d3e612b (patch) | |
tree | 4d29118f35df77ca6b423119a4ff61694a442cbf /node_modules/ninja-components/effect/desaturate-effect.js | |
parent | 9d2c2a80483415d7560b00cda5519153db23e241 (diff) | |
parent | d366c0bd1af6471511217ed574083e15059519b5 (diff) | |
download | ninja-89b5e793ea88ef235b54b6e1d1c379698d3e612b.tar.gz |
Merge branch 'refs/heads/NinjaInternal' into Color
Diffstat (limited to 'node_modules/ninja-components/effect/desaturate-effect.js')
-rwxr-xr-x | node_modules/ninja-components/effect/desaturate-effect.js | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/node_modules/ninja-components/effect/desaturate-effect.js b/node_modules/ninja-components/effect/desaturate-effect.js new file mode 100755 index 00000000..defa1973 --- /dev/null +++ b/node_modules/ninja-components/effect/desaturate-effect.js | |||
@@ -0,0 +1,25 @@ | |||
1 | /* <copyright> | ||
2 | This file contains proprietary software owned by Motorola Mobility, Inc.<br/> | ||
3 | No rights, expressed or implied, whatsoever to this software are provided by Motorola Mobility, Inc. hereunder.<br/> | ||
4 | (c) Copyright 2011 Motorola Mobility, Inc. All Rights Reserved. | ||
5 | </copyright> */ | ||
6 | var Montage = require("montage").Montage; | ||
7 | var Effect = require("effect/effect").Effect; | ||
8 | |||
9 | exports.DesaturateEffect = Montage.create(Effect, { | ||
10 | |||
11 | applyEffect: { | ||
12 | value: function(pixels, pixelCount) { | ||
13 | var i = 0, | ||
14 | average; | ||
15 | |||
16 | for (i = 0; i < pixelCount; i += 4) { | ||
17 | average = (pixels[i] + pixels[i+1] + pixels[i+2])/ 3; | ||
18 | pixels[i] = average; | ||
19 | pixels[i+1] = average; | ||
20 | pixels[i+2] = average; | ||
21 | } | ||
22 | } | ||
23 | } | ||
24 | |||
25 | }); | ||