2 * Pixastic Lib - Desaturation filter - v0.1.1
3 * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
4 * License: [http://www.pixastic.com/lib/license.txt] (MPL 1.1)
9 Pixastic.Actions.desaturate = {
10 process : function(params) {
11 var useAverage = !!(params.options.average && params.options.average != "false");
12 var data = params.data;
13 var rect = params.options.rect;
18 var pix = p*4, pix1, pix2;
22 data[pix-=4] = data[pix1=pix+1] = data[pix2=pix+2] = (data[pix]+data[pix1]+data[pix2])/3
25 data[pix-=4] = data[pix1=pix+1] = data[pix2=pix+2] = (data[pix]*0.3 + data[pix1]*0.59 + data[pix2]*0.11);
33 rect: { width: width, height: height},
38 //XXX improve dataset rather than loop
39 for (var pixcounter = 0; pixcounter < 200; pixcounter++)
40 Pixastic.Actions.desaturate.process(params);