Commit RELEASE-NOTES line for the wgCategories js variable I added some time ago.
[lhc/web/wiklou.git] / js2 / mwEmbed / libClipEdit / pixastic-lib / actions / lighten.js
1 /*
2 * Pixastic Lib - Lighten filter - v0.1.0
3 * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
4 * MIT License [http://www.opensource.org/licenses/mit-license.php]
5 */
6
7 Pixastic.Actions.lighten = {
8
9 process : function(params) {
10 var amount = parseFloat(params.options.amount) || 0;
11
12 if (Pixastic.Client.hasCanvasImageData()) {
13 var data = Pixastic.prepareData(params);
14 var rect = params.options.rect;
15 var w = rect.width;
16 var h = rect.height;
17 var w4 = w*4;
18 var y = h;
19 do {
20 var offsetY = (y-1)*w4;
21 var x = w;
22 do {
23 var offset = offsetY + (x-1)*4;
24
25 var r = data[offset];
26 var g = data[offset+1];
27 var b = data[offset+2];
28
29 r += r*amount;
30 g += g*amount;
31 b += b*amount;
32
33 if (r < 0 ) r = 0;
34 if (g < 0 ) g = 0;
35 if (b < 0 ) b = 0;
36 if (r > 255 ) r = 255;
37 if (g > 255 ) g = 255;
38 if (b > 255 ) b = 255;
39
40 data[offset] = r;
41 data[offset+1] = g;
42 data[offset+2] = b;
43
44 } while (--x);
45 } while (--y);
46 return true;
47
48 } else if (Pixastic.Client.isIE()) {
49 var img = params.image;
50 if (amount < 0) {
51 img.style.filter += " light()";
52 img.filters[img.filters.length-1].addAmbient(
53 255,255,255,
54 100 * -amount
55 );
56 } else if (amount > 0) {
57 img.style.filter += " light()";
58 img.filters[img.filters.length-1].addAmbient(
59 255,255,255,
60 100
61 );
62 img.filters[img.filters.length-1].addAmbient(
63 255,255,255,
64 100 * amount
65 );
66 }
67 return true;
68 }
69 },
70 checkSupport : function() {
71 return (Pixastic.Client.hasCanvasImageData() || Pixastic.Client.isIE());
72 }
73 }