Property changes on: trunk/extensions/SemanticForms/includes/SF_FormField.inc |
___________________________________________________________________ |
Added: svn:eol-style |
1 | 1 | + native |
Property changes on: trunk/extensions/ExternalData/ExternalData.sql |
___________________________________________________________________ |
Added: svn:eol-style |
2 | 2 | + native |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libEmbedObj/mv_baseEmbed.js |
___________________________________________________________________ |
Added: svn:eol-style |
3 | 3 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/pixastic.core.js |
— | — | @@ -1,332 +1,332 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Core Functions - v0.1.1
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, cupboy@gmail.com, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -var Pixastic = (function() {
|
9 | | -
|
10 | | -
|
11 | | -
|
12 | | - function addEvent(el, event, handler) {
|
13 | | - if (el.addEventListener)
|
14 | | - el.addEventListener(event, handler, false);
|
15 | | - else if (el.attachEvent)
|
16 | | - el.attachEvent("on" + event, handler);
|
17 | | - }
|
18 | | -
|
19 | | - function onready(handler) {
|
20 | | - var handlerDone = false;
|
21 | | - var execHandler = function() {
|
22 | | - if (!handlerDone) {
|
23 | | - handlerDone = true;
|
24 | | - handler();
|
25 | | - }
|
26 | | - }
|
27 | | - document.write("<"+"script defer src=\"//:\" id=\"__onload_ie_sumbox__\"></"+"script>");
|
28 | | - var script = document.getElementById("__onload_ie_sumbox__");
|
29 | | - script.onreadystatechange = function() {
|
30 | | - if (script.readyState == "complete") {
|
31 | | - script.parentNode.removeChild(script);
|
32 | | - execHandler();
|
33 | | - }
|
34 | | - }
|
35 | | - if (document.addEventListener)
|
36 | | - document.addEventListener("DOMContentLoaded", execHandler, false);
|
37 | | - addEvent(window, "load", execHandler);
|
38 | | - }
|
39 | | -
|
40 | | -
|
41 | | - function init() {
|
42 | | - if (!Pixastic.parseOnLoad) return;
|
43 | | - var imgEls = getElementsByClass("pixastic", null, "img");
|
44 | | - var canvasEls = getElementsByClass("pixastic", null, "canvas");
|
45 | | - var elements = imgEls.concat(canvasEls);
|
46 | | - for (var i=0;i<elements.length;i++) {
|
47 | | - (function() {
|
48 | | -
|
49 | | - var el = elements[i];
|
50 | | - var actions = [];
|
51 | | - var classes = el.className.split(" ");
|
52 | | - for (var c=0;c<classes.length;c++) {
|
53 | | - var cls = classes[c];
|
54 | | - if (cls.substring(0,9) == "pixastic-") {
|
55 | | - var actionName = cls.substring(9);
|
56 | | - if (actionName != "")
|
57 | | - actions.push(actionName);
|
58 | | - }
|
59 | | - }
|
60 | | - if (actions.length) {
|
61 | | - if (el.tagName == "IMG") {
|
62 | | - var dataImg = new Image();
|
63 | | - dataImg.src = el.src;
|
64 | | - if (dataImg.complete) {
|
65 | | - for (var a=0;a<actions.length;a++) {
|
66 | | - var res = Pixastic.applyAction(el, el, actions[a], null);
|
67 | | - if (res)
|
68 | | - el = res;
|
69 | | - }
|
70 | | - } else {
|
71 | | - dataImg.onload = function() {
|
72 | | - for (var a=0;a<actions.length;a++) {
|
73 | | - var res = Pixastic.applyAction(el, el, actions[a], null)
|
74 | | - if (res)
|
75 | | - el = res;
|
76 | | - }
|
77 | | - }
|
78 | | - }
|
79 | | - } else {
|
80 | | - setTimeout(function() {
|
81 | | - for (var a=0;a<actions.length;a++) {
|
82 | | - var res = Pixastic.applyAction(
|
83 | | - el, el, actions[a], null
|
84 | | - );
|
85 | | - if (res)
|
86 | | - el = res;
|
87 | | - }
|
88 | | - },1);
|
89 | | - }
|
90 | | - }
|
91 | | -
|
92 | | - })();
|
93 | | - }
|
94 | | - }
|
95 | | -
|
96 | | - onready(init);
|
97 | | -
|
98 | | -
|
99 | | - // getElementsByClass by Dustin Diaz, http://www.dustindiaz.com/getelementsbyclass/
|
100 | | - function getElementsByClass(searchClass,node,tag) {
|
101 | | - var classElements = new Array();
|
102 | | - if ( node == null )
|
103 | | - node = document;
|
104 | | - if ( tag == null )
|
105 | | - tag = '*';
|
106 | | -
|
107 | | - var els = node.getElementsByTagName(tag);
|
108 | | - var elsLen = els.length;
|
109 | | - var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)");
|
110 | | - for (i = 0, j = 0; i < elsLen; i++) {
|
111 | | - if ( pattern.test(els[i].className) ) {
|
112 | | - classElements[j] = els[i];
|
113 | | - j++;
|
114 | | - }
|
115 | | - }
|
116 | | - return classElements;
|
117 | | - }
|
118 | | -
|
119 | | - var debugElement;
|
120 | | -
|
121 | | - function writeDebug(text, level) {
|
122 | | - if (!Pixastic.debug) return;
|
123 | | -
|
124 | | - try {
|
125 | | - switch (level) {
|
126 | | - case "warn" :
|
127 | | - console.warn("Pixastic:", text);
|
128 | | - break;
|
129 | | - case "error" :
|
130 | | - console.error("Pixastic:", text);
|
131 | | - break;
|
132 | | - default:
|
133 | | - console.log("Pixastic:", text);
|
134 | | - }
|
135 | | - } catch(e) {
|
136 | | - }
|
137 | | - if (!debugElement) {
|
138 | | -
|
139 | | - }
|
140 | | - }
|
141 | | -
|
142 | | -
|
143 | | - return {
|
144 | | -
|
145 | | - parseOnLoad : false,
|
146 | | -
|
147 | | - debug : false,
|
148 | | -
|
149 | | - applyAction : function(img, dataImg, actionName, options) {
|
150 | | -
|
151 | | - options = options || {};
|
152 | | -
|
153 | | - var imageIsCanvas = (img.tagName == "CANVAS");
|
154 | | - if (imageIsCanvas && Pixastic.Client.isIE()) {
|
155 | | - if (Pixastic.debug) writeDebug("Tried to process a canvas element but browser is IE.");
|
156 | | - return false;
|
157 | | - }
|
158 | | -
|
159 | | - var canvas, ctx;
|
160 | | - if (Pixastic.Client.hasCanvas()) {
|
161 | | - canvas = document.createElement("canvas");
|
162 | | - ctx = canvas.getContext("2d");
|
163 | | - }
|
164 | | -
|
165 | | - var w = parseInt(img.offsetWidth);
|
166 | | - var h = parseInt(img.offsetHeight);
|
167 | | -
|
168 | | - if (actionName.indexOf("(") > -1) {
|
169 | | - var tmp = actionName;
|
170 | | - actionName = tmp.substr(0, tmp.indexOf("("));
|
171 | | - var arg = tmp.match(/\((.*?)\)/);
|
172 | | - if (arg[1]) {
|
173 | | - arg = arg[1].split(";");
|
174 | | - for (var a=0;a<arg.length;a++) {
|
175 | | - thisArg = arg[a].split("=");
|
176 | | - if (thisArg.length == 2) {
|
177 | | - if (thisArg[0] == "rect") {
|
178 | | - var rectVal = thisArg[1].split(",");
|
179 | | - options[thisArg[0]] = {
|
180 | | - left : parseInt(rectVal[0],10)||0,
|
181 | | - top : parseInt(rectVal[1],10)||0,
|
182 | | - width : parseInt(rectVal[2],10)||0,
|
183 | | - height : parseInt(rectVal[3],10)||0
|
184 | | - }
|
185 | | - } else {
|
186 | | - options[thisArg[0]] = thisArg[1];
|
187 | | - }
|
188 | | - }
|
189 | | - }
|
190 | | - }
|
191 | | - }
|
192 | | -
|
193 | | - if (!options.rect) {
|
194 | | - options.rect = {
|
195 | | - left : 0, top : 0, width : w, height : h
|
196 | | - };
|
197 | | - }
|
198 | | - var validAction = false;
|
199 | | - if (Pixastic.Actions[actionName] && typeof Pixastic.Actions[actionName].process == "function") {
|
200 | | - validAction = true;
|
201 | | - }
|
202 | | - if (!validAction) {
|
203 | | - if (Pixastic.debug) writeDebug("Invalid action \"" + actionName + "\". Maybe file not included?");
|
204 | | - return false;
|
205 | | - }
|
206 | | - if (!Pixastic.Actions[actionName].checkSupport()) {
|
207 | | - if (Pixastic.debug) writeDebug("Action \"" + actionName + "\" not supported by this browser.");
|
208 | | - return false;
|
209 | | - }
|
210 | | -
|
211 | | - if (Pixastic.Client.hasCanvas()) {
|
212 | | - canvas.width = w;
|
213 | | - canvas.height = h;
|
214 | | - canvas.style.width = w+"px";
|
215 | | - canvas.style.height = h+"px";
|
216 | | - ctx.drawImage(dataImg,0,0,w,h);
|
217 | | - }
|
218 | | -
|
219 | | - var params = {
|
220 | | - image : img,
|
221 | | - canvas : canvas,
|
222 | | - width : w,
|
223 | | - height : h,
|
224 | | - useData : true,
|
225 | | - options : options
|
226 | | - }
|
227 | | -
|
228 | | - var res = Pixastic.Actions[actionName].process(params);
|
229 | | -
|
230 | | - if (!res) {
|
231 | | - return false;
|
232 | | - }
|
233 | | -
|
234 | | - if (Pixastic.Client.hasCanvas()) {
|
235 | | - if (params.useData) {
|
236 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
237 | | - canvas.getContext("2d").putImageData(params.canvasData, options.rect.left, options.rect.top);
|
238 | | - // Opera doesn't seem to update the canvas until we draw something on it, lets draw a 0x0 rectangle.
|
239 | | - canvas.getContext("2d").fillRect(0,0,0,0);
|
240 | | - }
|
241 | | - }
|
242 | | - // copy properties and stuff from the source image
|
243 | | - canvas.title = img.title;
|
244 | | - canvas.imgsrc = img.imgsrc;
|
245 | | - if (!imageIsCanvas) canvas.alt = img.alt;
|
246 | | - if (!imageIsCanvas) canvas.imgsrc = img.src;
|
247 | | - canvas.className = img.className;
|
248 | | - if (img.getAttribute("style"))
|
249 | | - canvas.setAttribute("style", img.getAttribute("style"));
|
250 | | - canvas.cssText = img.cssText;
|
251 | | - canvas.name = img.name;
|
252 | | - canvas.tabIndex = img.tabIndex;
|
253 | | - canvas.id = img.id;
|
254 | | -
|
255 | | - if (img.parentNode && img.parentNode.replaceChild) {
|
256 | | - img.parentNode.replaceChild(canvas, img);
|
257 | | - }
|
258 | | -
|
259 | | - return canvas;
|
260 | | - }
|
261 | | -
|
262 | | - return img;
|
263 | | - },
|
264 | | -
|
265 | | - prepareData : function(params, getCopy) {
|
266 | | - var ctx = params.canvas.getContext("2d");
|
267 | | - var rect = params.options.rect;
|
268 | | - var dataDesc = ctx.getImageData(rect.left, rect.top, rect.width, rect.height);
|
269 | | - var data = dataDesc.data;
|
270 | | - if (!getCopy) params.canvasData = dataDesc;
|
271 | | - return data;
|
272 | | - },
|
273 | | -
|
274 | | - // load the image file
|
275 | | - process : function(img, actionName, options, callback)
|
276 | | - {
|
277 | | - if (img.tagName == "IMG") {
|
278 | | - var dataImg = new Image();
|
279 | | - dataImg.src = img.src;
|
280 | | - if (dataImg.complete) {
|
281 | | - var res = Pixastic.applyAction(img, dataImg, actionName, options);
|
282 | | - if (callback) callback(res);
|
283 | | - return res;
|
284 | | - } else {
|
285 | | - dataImg.onload = function() {
|
286 | | - var res = Pixastic.applyAction(img, dataImg, actionName, options)
|
287 | | - if (callback) callback(res);
|
288 | | - }
|
289 | | - }
|
290 | | - }
|
291 | | - if (img.tagName == "CANVAS") {
|
292 | | - var res = Pixastic.applyAction(img, img, actionName, options);
|
293 | | - if (callback) callback(res);
|
294 | | - return res;
|
295 | | - }
|
296 | | - },
|
297 | | -
|
298 | | - Client : {
|
299 | | - hasCanvas : (function() {
|
300 | | - var c = document.createElement("canvas");
|
301 | | - var val = false;
|
302 | | - try {
|
303 | | - val = !!((typeof c.getContext == "function") && c.getContext("2d"));
|
304 | | - } catch(e) {}
|
305 | | - return function() {
|
306 | | - return val;
|
307 | | - }
|
308 | | - })(),
|
309 | | -
|
310 | | - hasCanvasImageData : (function() {
|
311 | | - var c = document.createElement("canvas");
|
312 | | - var val = false;
|
313 | | - var ctx;
|
314 | | - try {
|
315 | | - if (typeof c.getContext == "function" && (ctx = c.getContext("2d"))) {
|
316 | | - val = (typeof ctx.getImageData == "function");
|
317 | | - }
|
318 | | - } catch(e) {}
|
319 | | - return function() {
|
320 | | - return val;
|
321 | | - }
|
322 | | - })(),
|
323 | | -
|
324 | | - isIE : function() {
|
325 | | - return !!document.all && !!window.attachEvent && !window.opera;
|
326 | | - }
|
327 | | - },
|
328 | | -
|
329 | | - Actions : {}
|
330 | | - }
|
331 | | -
|
332 | | -
|
333 | | -})();
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Core Functions - v0.1.1 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, cupboy@gmail.com, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +var Pixastic = (function() { |
| 9 | + |
| 10 | + |
| 11 | + |
| 12 | + function addEvent(el, event, handler) { |
| 13 | + if (el.addEventListener) |
| 14 | + el.addEventListener(event, handler, false); |
| 15 | + else if (el.attachEvent) |
| 16 | + el.attachEvent("on" + event, handler); |
| 17 | + } |
| 18 | + |
| 19 | + function onready(handler) { |
| 20 | + var handlerDone = false; |
| 21 | + var execHandler = function() { |
| 22 | + if (!handlerDone) { |
| 23 | + handlerDone = true; |
| 24 | + handler(); |
| 25 | + } |
| 26 | + } |
| 27 | + document.write("<"+"script defer src=\"//:\" id=\"__onload_ie_sumbox__\"></"+"script>"); |
| 28 | + var script = document.getElementById("__onload_ie_sumbox__"); |
| 29 | + script.onreadystatechange = function() { |
| 30 | + if (script.readyState == "complete") { |
| 31 | + script.parentNode.removeChild(script); |
| 32 | + execHandler(); |
| 33 | + } |
| 34 | + } |
| 35 | + if (document.addEventListener) |
| 36 | + document.addEventListener("DOMContentLoaded", execHandler, false); |
| 37 | + addEvent(window, "load", execHandler); |
| 38 | + } |
| 39 | + |
| 40 | + |
| 41 | + function init() { |
| 42 | + if (!Pixastic.parseOnLoad) return; |
| 43 | + var imgEls = getElementsByClass("pixastic", null, "img"); |
| 44 | + var canvasEls = getElementsByClass("pixastic", null, "canvas"); |
| 45 | + var elements = imgEls.concat(canvasEls); |
| 46 | + for (var i=0;i<elements.length;i++) { |
| 47 | + (function() { |
| 48 | + |
| 49 | + var el = elements[i]; |
| 50 | + var actions = []; |
| 51 | + var classes = el.className.split(" "); |
| 52 | + for (var c=0;c<classes.length;c++) { |
| 53 | + var cls = classes[c]; |
| 54 | + if (cls.substring(0,9) == "pixastic-") { |
| 55 | + var actionName = cls.substring(9); |
| 56 | + if (actionName != "") |
| 57 | + actions.push(actionName); |
| 58 | + } |
| 59 | + } |
| 60 | + if (actions.length) { |
| 61 | + if (el.tagName == "IMG") { |
| 62 | + var dataImg = new Image(); |
| 63 | + dataImg.src = el.src; |
| 64 | + if (dataImg.complete) { |
| 65 | + for (var a=0;a<actions.length;a++) { |
| 66 | + var res = Pixastic.applyAction(el, el, actions[a], null); |
| 67 | + if (res) |
| 68 | + el = res; |
| 69 | + } |
| 70 | + } else { |
| 71 | + dataImg.onload = function() { |
| 72 | + for (var a=0;a<actions.length;a++) { |
| 73 | + var res = Pixastic.applyAction(el, el, actions[a], null) |
| 74 | + if (res) |
| 75 | + el = res; |
| 76 | + } |
| 77 | + } |
| 78 | + } |
| 79 | + } else { |
| 80 | + setTimeout(function() { |
| 81 | + for (var a=0;a<actions.length;a++) { |
| 82 | + var res = Pixastic.applyAction( |
| 83 | + el, el, actions[a], null |
| 84 | + ); |
| 85 | + if (res) |
| 86 | + el = res; |
| 87 | + } |
| 88 | + },1); |
| 89 | + } |
| 90 | + } |
| 91 | + |
| 92 | + })(); |
| 93 | + } |
| 94 | + } |
| 95 | + |
| 96 | + onready(init); |
| 97 | + |
| 98 | + |
| 99 | + // getElementsByClass by Dustin Diaz, http://www.dustindiaz.com/getelementsbyclass/ |
| 100 | + function getElementsByClass(searchClass,node,tag) { |
| 101 | + var classElements = new Array(); |
| 102 | + if ( node == null ) |
| 103 | + node = document; |
| 104 | + if ( tag == null ) |
| 105 | + tag = '*'; |
| 106 | + |
| 107 | + var els = node.getElementsByTagName(tag); |
| 108 | + var elsLen = els.length; |
| 109 | + var pattern = new RegExp("(^|\\s)"+searchClass+"(\\s|$)"); |
| 110 | + for (i = 0, j = 0; i < elsLen; i++) { |
| 111 | + if ( pattern.test(els[i].className) ) { |
| 112 | + classElements[j] = els[i]; |
| 113 | + j++; |
| 114 | + } |
| 115 | + } |
| 116 | + return classElements; |
| 117 | + } |
| 118 | + |
| 119 | + var debugElement; |
| 120 | + |
| 121 | + function writeDebug(text, level) { |
| 122 | + if (!Pixastic.debug) return; |
| 123 | + |
| 124 | + try { |
| 125 | + switch (level) { |
| 126 | + case "warn" : |
| 127 | + console.warn("Pixastic:", text); |
| 128 | + break; |
| 129 | + case "error" : |
| 130 | + console.error("Pixastic:", text); |
| 131 | + break; |
| 132 | + default: |
| 133 | + console.log("Pixastic:", text); |
| 134 | + } |
| 135 | + } catch(e) { |
| 136 | + } |
| 137 | + if (!debugElement) { |
| 138 | + |
| 139 | + } |
| 140 | + } |
| 141 | + |
| 142 | + |
| 143 | + return { |
| 144 | + |
| 145 | + parseOnLoad : false, |
| 146 | + |
| 147 | + debug : false, |
| 148 | + |
| 149 | + applyAction : function(img, dataImg, actionName, options) { |
| 150 | + |
| 151 | + options = options || {}; |
| 152 | + |
| 153 | + var imageIsCanvas = (img.tagName == "CANVAS"); |
| 154 | + if (imageIsCanvas && Pixastic.Client.isIE()) { |
| 155 | + if (Pixastic.debug) writeDebug("Tried to process a canvas element but browser is IE."); |
| 156 | + return false; |
| 157 | + } |
| 158 | + |
| 159 | + var canvas, ctx; |
| 160 | + if (Pixastic.Client.hasCanvas()) { |
| 161 | + canvas = document.createElement("canvas"); |
| 162 | + ctx = canvas.getContext("2d"); |
| 163 | + } |
| 164 | + |
| 165 | + var w = parseInt(img.offsetWidth); |
| 166 | + var h = parseInt(img.offsetHeight); |
| 167 | + |
| 168 | + if (actionName.indexOf("(") > -1) { |
| 169 | + var tmp = actionName; |
| 170 | + actionName = tmp.substr(0, tmp.indexOf("(")); |
| 171 | + var arg = tmp.match(/\((.*?)\)/); |
| 172 | + if (arg[1]) { |
| 173 | + arg = arg[1].split(";"); |
| 174 | + for (var a=0;a<arg.length;a++) { |
| 175 | + thisArg = arg[a].split("="); |
| 176 | + if (thisArg.length == 2) { |
| 177 | + if (thisArg[0] == "rect") { |
| 178 | + var rectVal = thisArg[1].split(","); |
| 179 | + options[thisArg[0]] = { |
| 180 | + left : parseInt(rectVal[0],10)||0, |
| 181 | + top : parseInt(rectVal[1],10)||0, |
| 182 | + width : parseInt(rectVal[2],10)||0, |
| 183 | + height : parseInt(rectVal[3],10)||0 |
| 184 | + } |
| 185 | + } else { |
| 186 | + options[thisArg[0]] = thisArg[1]; |
| 187 | + } |
| 188 | + } |
| 189 | + } |
| 190 | + } |
| 191 | + } |
| 192 | + |
| 193 | + if (!options.rect) { |
| 194 | + options.rect = { |
| 195 | + left : 0, top : 0, width : w, height : h |
| 196 | + }; |
| 197 | + } |
| 198 | + var validAction = false; |
| 199 | + if (Pixastic.Actions[actionName] && typeof Pixastic.Actions[actionName].process == "function") { |
| 200 | + validAction = true; |
| 201 | + } |
| 202 | + if (!validAction) { |
| 203 | + if (Pixastic.debug) writeDebug("Invalid action \"" + actionName + "\". Maybe file not included?"); |
| 204 | + return false; |
| 205 | + } |
| 206 | + if (!Pixastic.Actions[actionName].checkSupport()) { |
| 207 | + if (Pixastic.debug) writeDebug("Action \"" + actionName + "\" not supported by this browser."); |
| 208 | + return false; |
| 209 | + } |
| 210 | + |
| 211 | + if (Pixastic.Client.hasCanvas()) { |
| 212 | + canvas.width = w; |
| 213 | + canvas.height = h; |
| 214 | + canvas.style.width = w+"px"; |
| 215 | + canvas.style.height = h+"px"; |
| 216 | + ctx.drawImage(dataImg,0,0,w,h); |
| 217 | + } |
| 218 | + |
| 219 | + var params = { |
| 220 | + image : img, |
| 221 | + canvas : canvas, |
| 222 | + width : w, |
| 223 | + height : h, |
| 224 | + useData : true, |
| 225 | + options : options |
| 226 | + } |
| 227 | + |
| 228 | + var res = Pixastic.Actions[actionName].process(params); |
| 229 | + |
| 230 | + if (!res) { |
| 231 | + return false; |
| 232 | + } |
| 233 | + |
| 234 | + if (Pixastic.Client.hasCanvas()) { |
| 235 | + if (params.useData) { |
| 236 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 237 | + canvas.getContext("2d").putImageData(params.canvasData, options.rect.left, options.rect.top); |
| 238 | + // Opera doesn't seem to update the canvas until we draw something on it, lets draw a 0x0 rectangle. |
| 239 | + canvas.getContext("2d").fillRect(0,0,0,0); |
| 240 | + } |
| 241 | + } |
| 242 | + // copy properties and stuff from the source image |
| 243 | + canvas.title = img.title; |
| 244 | + canvas.imgsrc = img.imgsrc; |
| 245 | + if (!imageIsCanvas) canvas.alt = img.alt; |
| 246 | + if (!imageIsCanvas) canvas.imgsrc = img.src; |
| 247 | + canvas.className = img.className; |
| 248 | + if (img.getAttribute("style")) |
| 249 | + canvas.setAttribute("style", img.getAttribute("style")); |
| 250 | + canvas.cssText = img.cssText; |
| 251 | + canvas.name = img.name; |
| 252 | + canvas.tabIndex = img.tabIndex; |
| 253 | + canvas.id = img.id; |
| 254 | + |
| 255 | + if (img.parentNode && img.parentNode.replaceChild) { |
| 256 | + img.parentNode.replaceChild(canvas, img); |
| 257 | + } |
| 258 | + |
| 259 | + return canvas; |
| 260 | + } |
| 261 | + |
| 262 | + return img; |
| 263 | + }, |
| 264 | + |
| 265 | + prepareData : function(params, getCopy) { |
| 266 | + var ctx = params.canvas.getContext("2d"); |
| 267 | + var rect = params.options.rect; |
| 268 | + var dataDesc = ctx.getImageData(rect.left, rect.top, rect.width, rect.height); |
| 269 | + var data = dataDesc.data; |
| 270 | + if (!getCopy) params.canvasData = dataDesc; |
| 271 | + return data; |
| 272 | + }, |
| 273 | + |
| 274 | + // load the image file |
| 275 | + process : function(img, actionName, options, callback) |
| 276 | + { |
| 277 | + if (img.tagName == "IMG") { |
| 278 | + var dataImg = new Image(); |
| 279 | + dataImg.src = img.src; |
| 280 | + if (dataImg.complete) { |
| 281 | + var res = Pixastic.applyAction(img, dataImg, actionName, options); |
| 282 | + if (callback) callback(res); |
| 283 | + return res; |
| 284 | + } else { |
| 285 | + dataImg.onload = function() { |
| 286 | + var res = Pixastic.applyAction(img, dataImg, actionName, options) |
| 287 | + if (callback) callback(res); |
| 288 | + } |
| 289 | + } |
| 290 | + } |
| 291 | + if (img.tagName == "CANVAS") { |
| 292 | + var res = Pixastic.applyAction(img, img, actionName, options); |
| 293 | + if (callback) callback(res); |
| 294 | + return res; |
| 295 | + } |
| 296 | + }, |
| 297 | + |
| 298 | + Client : { |
| 299 | + hasCanvas : (function() { |
| 300 | + var c = document.createElement("canvas"); |
| 301 | + var val = false; |
| 302 | + try { |
| 303 | + val = !!((typeof c.getContext == "function") && c.getContext("2d")); |
| 304 | + } catch(e) {} |
| 305 | + return function() { |
| 306 | + return val; |
| 307 | + } |
| 308 | + })(), |
| 309 | + |
| 310 | + hasCanvasImageData : (function() { |
| 311 | + var c = document.createElement("canvas"); |
| 312 | + var val = false; |
| 313 | + var ctx; |
| 314 | + try { |
| 315 | + if (typeof c.getContext == "function" && (ctx = c.getContext("2d"))) { |
| 316 | + val = (typeof ctx.getImageData == "function"); |
| 317 | + } |
| 318 | + } catch(e) {} |
| 319 | + return function() { |
| 320 | + return val; |
| 321 | + } |
| 322 | + })(), |
| 323 | + |
| 324 | + isIE : function() { |
| 325 | + return !!document.all && !!window.attachEvent && !window.opera; |
| 326 | + } |
| 327 | + }, |
| 328 | + |
| 329 | + Actions : {} |
| 330 | + } |
| 331 | + |
| 332 | + |
| 333 | +})(); |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/pixastic.core.js |
___________________________________________________________________ |
Added: svn:eol-style |
334 | 334 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/pixastic.jquery.js |
— | — | @@ -1,22 +1,22 @@ |
2 | | -
|
3 | | -if (typeof jQuery != "undefined" && jQuery && jQuery.fn) {
|
4 | | - jQuery.fn.pixastic = function(action, options) {
|
5 | | - var newElements = [];
|
6 | | - this.each(
|
7 | | - function () {
|
8 | | - if (this.tagName == "IMG" && !this.complete) {
|
9 | | - return;
|
10 | | - }
|
11 | | - var res = Pixastic.process(this, action, options);
|
12 | | - if (res) {
|
13 | | - newElements.push(res);
|
14 | | - }
|
15 | | - }
|
16 | | - );
|
17 | | - if (newElements.length > 0)
|
18 | | - return jQuery(newElements);
|
19 | | - else
|
20 | | - return this;
|
21 | | - };
|
22 | | -
|
23 | | -};
|
| 2 | + |
| 3 | +if (typeof jQuery != "undefined" && jQuery && jQuery.fn) { |
| 4 | + jQuery.fn.pixastic = function(action, options) { |
| 5 | + var newElements = []; |
| 6 | + this.each( |
| 7 | + function () { |
| 8 | + if (this.tagName == "IMG" && !this.complete) { |
| 9 | + return; |
| 10 | + } |
| 11 | + var res = Pixastic.process(this, action, options); |
| 12 | + if (res) { |
| 13 | + newElements.push(res); |
| 14 | + } |
| 15 | + } |
| 16 | + ); |
| 17 | + if (newElements.length > 0) |
| 18 | + return jQuery(newElements); |
| 19 | + else |
| 20 | + return this; |
| 21 | + }; |
| 22 | + |
| 23 | +}; |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/pixastic.jquery.js |
___________________________________________________________________ |
Added: svn:eol-style |
24 | 24 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/blend.js |
— | — | @@ -1,462 +1,462 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Blend - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.blend = {
|
9 | | -
|
10 | | - process : function(params) {
|
11 | | - var amount = parseFloat(params.options.amount);
|
12 | | - var mode = (params.options.mode || "normal").toLowerCase();
|
13 | | - var image = params.options.image;
|
14 | | -
|
15 | | - amount = Math.max(0,Math.min(1,amount));
|
16 | | -
|
17 | | - if (!image) return false;
|
18 | | -
|
19 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
20 | | - var rect = params.options.rect;
|
21 | | - var data = Pixastic.prepareData(params);
|
22 | | - var w = rect.width;
|
23 | | - var h = rect.height;
|
24 | | -
|
25 | | - params.useData = false;
|
26 | | -
|
27 | | - var otherCanvas = document.createElement("canvas");
|
28 | | - otherCanvas.width = params.canvas.width;
|
29 | | - otherCanvas.height = params.canvas.height;
|
30 | | - var otherCtx = otherCanvas.getContext("2d");
|
31 | | - otherCtx.drawImage(image,0,0);
|
32 | | -
|
33 | | - var params2 = {canvas:otherCanvas,options:params.options};
|
34 | | - var data2 = Pixastic.prepareData(params2);
|
35 | | - var dataDesc2 = params2.canvasData;
|
36 | | -
|
37 | | - var p = w*h;
|
38 | | - var pix = p*4;
|
39 | | - var pix1, pix2;
|
40 | | - var r1, g1, b1;
|
41 | | - var r2, g2, b2;
|
42 | | - var r3, g3, b3;
|
43 | | - var r4, g4, b4;
|
44 | | -
|
45 | | - switch (mode) {
|
46 | | - case "normal" :
|
47 | | - //while (p--) {
|
48 | | - // data2[pix-=4] = data2[pix];
|
49 | | - // data2[pix1=pix+1] = data2[pix1];
|
50 | | - // data2[pix2=pix+2] = data2[pix2];
|
51 | | - //}
|
52 | | - break;
|
53 | | -
|
54 | | - case "multiply" :
|
55 | | - while (p--) {
|
56 | | - data2[pix-=4] = data[pix] * data2[pix] / 255;
|
57 | | - data2[pix1=pix+1] = data[pix1] * data2[pix1] / 255;
|
58 | | - data2[pix2=pix+2] = data[pix2] * data2[pix2] / 255;
|
59 | | - }
|
60 | | - break;
|
61 | | -
|
62 | | - case "lighten" :
|
63 | | - while (p--) {
|
64 | | - if ((r1 = data[pix-=4]) > data2[pix])
|
65 | | - data2[pix] = r1;
|
66 | | - if ((g1 = data[pix1=pix+1]) > data2[pix1])
|
67 | | - data2[pix1] = g1;
|
68 | | - if ((b1 = data[pix2=pix+2]) > data2[pix2])
|
69 | | - data2[pix2] = b1;
|
70 | | - }
|
71 | | - break;
|
72 | | -
|
73 | | - case "darken" :
|
74 | | - while (p--) {
|
75 | | - if ((r1 = data[pix-=4]) < data2[pix])
|
76 | | - data2[pix] = r1;
|
77 | | - if ((g1 = data[pix1=pix+1]) < data2[pix1])
|
78 | | - data2[pix1] = g1;
|
79 | | - if ((b1 = data[pix2=pix+2]) < data2[pix2])
|
80 | | - data2[pix2] = b1;
|
81 | | -
|
82 | | - }
|
83 | | - break;
|
84 | | -
|
85 | | - case "darkercolor" :
|
86 | | - while (p--) {
|
87 | | - if (((r1 = data[pix-=4])*0.3+(g1 = data[pix1=pix+1])*0.59+(b1 = data[pix2=pix+2])*0.11) <= (data2[pix]*0.3+data2[pix1]*0.59+data2[pix2]*0.11)) {
|
88 | | - data2[pix] = r1;
|
89 | | - data2[pix1] = g1;
|
90 | | - data2[pix2] = b1;
|
91 | | - }
|
92 | | - }
|
93 | | - break;
|
94 | | -
|
95 | | - case "lightercolor" :
|
96 | | - while (p--) {
|
97 | | - if (((r1 = data[pix-=4])*0.3+(g1 = data[pix1=pix+1])*0.59+(b1 = data[pix2=pix+2])*0.11) > (data2[pix]*0.3+data2[pix1]*0.59+data2[pix2]*0.11)) {
|
98 | | - data2[pix] = r1;
|
99 | | - data2[pix1] = g1;
|
100 | | - data2[pix2] = b1;
|
101 | | - }
|
102 | | - }
|
103 | | - break;
|
104 | | -
|
105 | | - case "lineardodge" :
|
106 | | - while (p--) {
|
107 | | - if ((r3 = data[pix-=4] + data2[pix]) > 255)
|
108 | | - data2[pix] = 255;
|
109 | | - else
|
110 | | - data2[pix] = r3;
|
111 | | - if ((g3 = data[pix1=pix+1] + data2[pix1]) > 255)
|
112 | | - data2[pix1] = 255;
|
113 | | - else
|
114 | | - data2[pix1] = g3;
|
115 | | - if ((b3 = data[pix2=pix+2] + data2[pix2]) > 255)
|
116 | | - data2[pix2] = 255;
|
117 | | - else
|
118 | | - data2[pix2] = b3;
|
119 | | - }
|
120 | | - break;
|
121 | | -
|
122 | | - case "linearburn" :
|
123 | | - while (p--) {
|
124 | | - if ((r3 = data[pix-=4] + data2[pix]) < 255)
|
125 | | - data2[pix] = 0;
|
126 | | - else
|
127 | | - data2[pix] = (r3 - 255);
|
128 | | - if ((g3 = data[pix1=pix+1] + data2[pix1]) < 255)
|
129 | | - data2[pix1] = 0;
|
130 | | - else
|
131 | | - data2[pix1] = (g3 - 255);
|
132 | | - if ((b3 = data[pix2=pix+2] + data2[pix2]) < 255)
|
133 | | - data2[pix2] = 0;
|
134 | | - else
|
135 | | - data2[pix2] = (b3 - 255);
|
136 | | - }
|
137 | | - break;
|
138 | | -
|
139 | | - case "difference" :
|
140 | | - while (p--) {
|
141 | | - if ((r3 = data[pix-=4] - data2[pix]) < 0)
|
142 | | - data2[pix] = -r3;
|
143 | | - else
|
144 | | - data2[pix] = r3;
|
145 | | - if ((g3 = data[pix1=pix+1] - data2[pix1]) < 0)
|
146 | | - data2[pix1] = -g3;
|
147 | | - else
|
148 | | - data2[pix1] = g3;
|
149 | | - if ((b3 = data[pix2=pix+2] - data2[pix2]) < 0)
|
150 | | - data2[pix2] = -b3;
|
151 | | - else
|
152 | | - data2[pix2] = b3;
|
153 | | - }
|
154 | | - break;
|
155 | | -
|
156 | | - case "screen" :
|
157 | | - while (p--) {
|
158 | | - data2[pix-=4] = (255 - ( ((255-data2[pix])*(255-data[pix])) >> 8));
|
159 | | - data2[pix1=pix+1] = (255 - ( ((255-data2[pix1])*(255-data[pix1])) >> 8));
|
160 | | - data2[pix2=pix+2] = (255 - ( ((255-data2[pix2])*(255-data[pix2])) >> 8));
|
161 | | - }
|
162 | | - break;
|
163 | | -
|
164 | | - case "exclusion" :
|
165 | | - var div_2_255 = 2 / 255;
|
166 | | - while (p--) {
|
167 | | - data2[pix-=4] = (r1 = data[pix]) - (r1 * div_2_255 - 1) * data2[pix];
|
168 | | - data2[pix1=pix+1] = (g1 = data[pix1]) - (g1 * div_2_255 - 1) * data2[pix1];
|
169 | | - data2[pix2=pix+2] = (b1 = data[pix2]) - (b1 * div_2_255 - 1) * data2[pix2];
|
170 | | - }
|
171 | | - break;
|
172 | | -
|
173 | | - case "overlay" :
|
174 | | - var div_2_255 = 2 / 255;
|
175 | | - while (p--) {
|
176 | | - if ((r1 = data[pix-=4]) < 128)
|
177 | | - data2[pix] = data2[pix]*r1*div_2_255;
|
178 | | - else
|
179 | | - data2[pix] = 255 - (255-data2[pix])*(255-r1)*div_2_255;
|
180 | | -
|
181 | | - if ((g1 = data[pix1=pix+1]) < 128)
|
182 | | - data2[pix1] = data2[pix1]*g1*div_2_255;
|
183 | | - else
|
184 | | - data2[pix1] = 255 - (255-data2[pix1])*(255-g1)*div_2_255;
|
185 | | -
|
186 | | - if ((b1 = data[pix2=pix+2]) < 128)
|
187 | | - data2[pix2] = data2[pix2]*b1*div_2_255;
|
188 | | - else
|
189 | | - data2[pix2] = 255 - (255-data2[pix2])*(255-b1)*div_2_255;
|
190 | | -
|
191 | | - }
|
192 | | - break;
|
193 | | -
|
194 | | - case "softlight" :
|
195 | | - var div_2_255 = 2 / 255;
|
196 | | - while (p--) {
|
197 | | - if ((r1 = data[pix-=4]) < 128)
|
198 | | - data2[pix] = ((data2[pix]>>1) + 64) * r1 * div_2_255;
|
199 | | - else
|
200 | | - data2[pix] = 255 - (191 - (data2[pix]>>1)) * (255-r1) * div_2_255;
|
201 | | -
|
202 | | - if ((g1 = data[pix1=pix+1]) < 128)
|
203 | | - data2[pix1] = ((data2[pix1]>>1)+64) * g1 * div_2_255;
|
204 | | - else
|
205 | | - data2[pix1] = 255 - (191 - (data2[pix1]>>1)) * (255-g1) * div_2_255;
|
206 | | -
|
207 | | - if ((b1 = data[pix2=pix+2]) < 128)
|
208 | | - data2[pix2] = ((data2[pix2]>>1)+64) * b1 * div_2_255;
|
209 | | - else
|
210 | | - data2[pix2] = 255 - (191 - (data2[pix2]>>1)) * (255-b1) * div_2_255;
|
211 | | -
|
212 | | - }
|
213 | | - break;
|
214 | | -
|
215 | | -
|
216 | | - case "hardlight" :
|
217 | | - var div_2_255 = 2 / 255;
|
218 | | - while (p--) {
|
219 | | - if ((r2 = data2[pix-=4]) < 128)
|
220 | | - data2[pix] = data[pix] * r2 * div_2_255;
|
221 | | - else
|
222 | | - data2[pix] = 255 - (255-data[pix]) * (255-r2) * div_2_255;
|
223 | | -
|
224 | | - if ((g2 = data2[pix1=pix+1]) < 128)
|
225 | | - data2[pix1] = data[pix1] * g2 * div_2_255;
|
226 | | - else
|
227 | | - data2[pix1] = 255 - (255-data[pix1]) * (255-g2) * div_2_255;
|
228 | | -
|
229 | | - if ((b2 = data2[pix2=pix+2]) < 128)
|
230 | | - data2[pix2] = data[pix2] * b2 * div_2_255;
|
231 | | - else
|
232 | | - data2[pix2] = 255 - (255-data[pix2]) * (255-b2) * div_2_255;
|
233 | | -
|
234 | | - }
|
235 | | - break;
|
236 | | -
|
237 | | - case "colordodge" :
|
238 | | - while (p--) {
|
239 | | - if ((r3 = (data[pix-=4]<<8)/(255-(r2 = data2[pix]))) > 255 || r2 == 255)
|
240 | | - data2[pix] = 255;
|
241 | | - else
|
242 | | - data2[pix] = r3;
|
243 | | -
|
244 | | - if ((g3 = (data[pix1=pix+1]<<8)/(255-(g2 = data2[pix1]))) > 255 || g2 == 255)
|
245 | | - data2[pix1] = 255;
|
246 | | - else
|
247 | | - data2[pix1] = g3;
|
248 | | -
|
249 | | - if ((b3 = (data[pix2=pix+2]<<8)/(255-(b2 = data2[pix2]))) > 255 || b2 == 255)
|
250 | | - data2[pix2] = 255;
|
251 | | - else
|
252 | | - data2[pix2] = b3;
|
253 | | - }
|
254 | | -
|
255 | | - break;
|
256 | | -
|
257 | | - case "colorburn" :
|
258 | | - while (p--) {
|
259 | | - if ((r3 = 255-((255-data[pix-=4])<<8)/data2[pix]) < 0 || data2[pix] == 0)
|
260 | | - data2[pix] = 0;
|
261 | | - else
|
262 | | - data2[pix] = r3;
|
263 | | -
|
264 | | - if ((g3 = 255-((255-data[pix1=pix+1])<<8)/data2[pix1]) < 0 || data2[pix1] == 0)
|
265 | | - data2[pix1] = 0;
|
266 | | - else
|
267 | | - data2[pix1] = g3;
|
268 | | -
|
269 | | - if ((b3 = 255-((255-data[pix2=pix+2])<<8)/data2[pix2]) < 0 || data2[pix2] == 0)
|
270 | | - data2[pix2] = 0;
|
271 | | - else
|
272 | | - data2[pix2] = b3;
|
273 | | - }
|
274 | | - break;
|
275 | | -
|
276 | | - case "linearlight" :
|
277 | | - while (p--) {
|
278 | | - if ( ((r3 = 2*(r2=data2[pix-=4])+data[pix]-256) < 0) || (r2 < 128 && r3 < 0)) {
|
279 | | - data2[pix] = 0
|
280 | | - } else {
|
281 | | - if (r3 > 255)
|
282 | | - data2[pix] = 255;
|
283 | | - else
|
284 | | - data2[pix] = r3;
|
285 | | - }
|
286 | | - if ( ((g3 = 2*(g2=data2[pix1=pix+1])+data[pix1]-256) < 0) || (g2 < 128 && g3 < 0)) {
|
287 | | - data2[pix1] = 0
|
288 | | - } else {
|
289 | | - if (g3 > 255)
|
290 | | - data2[pix1] = 255;
|
291 | | - else
|
292 | | - data2[pix1] = g3;
|
293 | | - }
|
294 | | - if ( ((b3 = 2*(b2=data2[pix2=pix+2])+data[pix2]-256) < 0) || (b2 < 128 && b3 < 0)) {
|
295 | | - data2[pix2] = 0
|
296 | | - } else {
|
297 | | - if (b3 > 255)
|
298 | | - data2[pix2] = 255;
|
299 | | - else
|
300 | | - data2[pix2] = b3;
|
301 | | - }
|
302 | | - }
|
303 | | -
|
304 | | - break;
|
305 | | -
|
306 | | - case "vividlight" :
|
307 | | - while (p--) {
|
308 | | - if ((r2=data2[pix-=4]) < 128) {
|
309 | | - if (r2) {
|
310 | | - if ((r3 = 255 - ((255-data[pix])<<8) / (2*r2)) < 0)
|
311 | | - data2[pix] = 0;
|
312 | | - else
|
313 | | - data2[pix] = r3
|
314 | | - } else {
|
315 | | - data2[pix] = 0;
|
316 | | - }
|
317 | | - } else if ((r3 = (r4=2*r2-256)) < 255) {
|
318 | | - if ((r3 = (data[pix]<<8)/(255-r4)) > 255)
|
319 | | - data2[pix] = 255;
|
320 | | - else
|
321 | | - data2[pix] = r3;
|
322 | | - } else {
|
323 | | - if (r3 < 0)
|
324 | | - data2[pix] = 0;
|
325 | | - else
|
326 | | - data2[pix] = r3
|
327 | | - }
|
328 | | -
|
329 | | - if ((g2=data2[pix1=pix+1]) < 128) {
|
330 | | - if (g2) {
|
331 | | - if ((g3 = 255 - ((255-data[pix1])<<8) / (2*g2)) < 0)
|
332 | | - data2[pix1] = 0;
|
333 | | - else
|
334 | | - data2[pix1] = g3;
|
335 | | - } else {
|
336 | | - data2[pix1] = 0;
|
337 | | - }
|
338 | | - } else if ((g3 = (g4=2*g2-256)) < 255) {
|
339 | | - if ((g3 = (data[pix1]<<8)/(255-g4)) > 255)
|
340 | | - data2[pix1] = 255;
|
341 | | - else
|
342 | | - data2[pix1] = g3;
|
343 | | - } else {
|
344 | | - if (g3 < 0)
|
345 | | - data2[pix1] = 0;
|
346 | | - else
|
347 | | - data2[pix1] = g3;
|
348 | | - }
|
349 | | -
|
350 | | - if ((b2=data2[pix2=pix+2]) < 128) {
|
351 | | - if (b2) {
|
352 | | - if ((b3 = 255 - ((255-data[pix2])<<8) / (2*b2)) < 0)
|
353 | | - data2[pix2] = 0;
|
354 | | - else
|
355 | | - data2[pix2] = b3;
|
356 | | - } else {
|
357 | | - data2[pix2] = 0;
|
358 | | - }
|
359 | | - } else if ((b3 = (b4=2*b2-256)) < 255) {
|
360 | | - if ((b3 = (data[pix2]<<8)/(255-b4)) > 255)
|
361 | | - data2[pix2] = 255;
|
362 | | - else
|
363 | | - data2[pix2] = b3;
|
364 | | - } else {
|
365 | | - if (b3 < 0)
|
366 | | - data2[pix2] = 0;
|
367 | | - else
|
368 | | - data2[pix2] = b3;
|
369 | | - }
|
370 | | - }
|
371 | | - break;
|
372 | | -
|
373 | | - case "pinlight" :
|
374 | | - while (p--) {
|
375 | | - if ((r2=data2[pix-=4]) < 128)
|
376 | | - if ((r1=data[pix]) < (r4=2*r2))
|
377 | | - data2[pix] = r1;
|
378 | | - else
|
379 | | - data2[pix] = r4;
|
380 | | - else
|
381 | | - if ((r1=data[pix]) > (r4=2*r2-256))
|
382 | | - data2[pix] = r1;
|
383 | | - else
|
384 | | - data2[pix] = r4;
|
385 | | -
|
386 | | - if ((g2=data2[pix1=pix+1]) < 128)
|
387 | | - if ((g1=data[pix1]) < (g4=2*g2))
|
388 | | - data2[pix1] = g1;
|
389 | | - else
|
390 | | - data2[pix1] = g4;
|
391 | | - else
|
392 | | - if ((g1=data[pix1]) > (g4=2*g2-256))
|
393 | | - data2[pix1] = g1;
|
394 | | - else
|
395 | | - data2[pix1] = g4;
|
396 | | -
|
397 | | - if ((r2=data2[pix2=pix+2]) < 128)
|
398 | | - if ((r1=data[pix2]) < (r4=2*r2))
|
399 | | - data2[pix2] = r1;
|
400 | | - else
|
401 | | - data2[pix2] = r4;
|
402 | | - else
|
403 | | - if ((r1=data[pix2]) > (r4=2*r2-256))
|
404 | | - data2[pix2] = r1;
|
405 | | - else
|
406 | | - data2[pix2] = r4;
|
407 | | - }
|
408 | | - break;
|
409 | | -
|
410 | | - case "hardmix" :
|
411 | | - while (p--) {
|
412 | | - if ((r2 = data2[pix-=4]) < 128)
|
413 | | - if (255 - ((255-data[pix])<<8)/(2*r2) < 128 || r2 == 0)
|
414 | | - data2[pix] = 0;
|
415 | | - else
|
416 | | - data2[pix] = 255;
|
417 | | - else if ((r4=2*r2-256) < 255 && (data[pix]<<8)/(255-r4) < 128)
|
418 | | - data2[pix] = 0;
|
419 | | - else
|
420 | | - data2[pix] = 255;
|
421 | | -
|
422 | | - if ((g2 = data2[pix1=pix+1]) < 128)
|
423 | | - if (255 - ((255-data[pix1])<<8)/(2*g2) < 128 || g2 == 0)
|
424 | | - data2[pix1] = 0;
|
425 | | - else
|
426 | | - data2[pix1] = 255;
|
427 | | - else if ((g4=2*g2-256) < 255 && (data[pix1]<<8)/(255-g4) < 128)
|
428 | | - data2[pix1] = 0;
|
429 | | - else
|
430 | | - data2[pix1] = 255;
|
431 | | -
|
432 | | - if ((b2 = data2[pix2=pix+2]) < 128)
|
433 | | - if (255 - ((255-data[pix2])<<8)/(2*b2) < 128 || b2 == 0)
|
434 | | - data2[pix2] = 0;
|
435 | | - else
|
436 | | - data2[pix2] = 255;
|
437 | | - else if ((b4=2*b2-256) < 255 && (data[pix2]<<8)/(255-b4) < 128)
|
438 | | - data2[pix2] = 0;
|
439 | | - else
|
440 | | - data2[pix2] = 255;
|
441 | | - }
|
442 | | - break;
|
443 | | - }
|
444 | | -
|
445 | | - otherCtx.putImageData(dataDesc2,0,0);
|
446 | | - var ctx = params.canvas.getContext("2d");
|
447 | | - ctx.save();
|
448 | | - ctx.globalAlpha = amount;
|
449 | | - ctx.drawImage(
|
450 | | - otherCanvas,
|
451 | | - 0,0,rect.width,rect.height,
|
452 | | - rect.left,rect.top,rect.width,rect.height
|
453 | | - );
|
454 | | - ctx.globalAlpha = 1;
|
455 | | - ctx.restore();
|
456 | | -
|
457 | | - return true;
|
458 | | - }
|
459 | | - },
|
460 | | - checkSupport : function() {
|
461 | | - return Pixastic.Client.hasCanvasImageData();
|
462 | | - }
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Blend - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.blend = { |
| 9 | + |
| 10 | + process : function(params) { |
| 11 | + var amount = parseFloat(params.options.amount); |
| 12 | + var mode = (params.options.mode || "normal").toLowerCase(); |
| 13 | + var image = params.options.image; |
| 14 | + |
| 15 | + amount = Math.max(0,Math.min(1,amount)); |
| 16 | + |
| 17 | + if (!image) return false; |
| 18 | + |
| 19 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 20 | + var rect = params.options.rect; |
| 21 | + var data = Pixastic.prepareData(params); |
| 22 | + var w = rect.width; |
| 23 | + var h = rect.height; |
| 24 | + |
| 25 | + params.useData = false; |
| 26 | + |
| 27 | + var otherCanvas = document.createElement("canvas"); |
| 28 | + otherCanvas.width = params.canvas.width; |
| 29 | + otherCanvas.height = params.canvas.height; |
| 30 | + var otherCtx = otherCanvas.getContext("2d"); |
| 31 | + otherCtx.drawImage(image,0,0); |
| 32 | + |
| 33 | + var params2 = {canvas:otherCanvas,options:params.options}; |
| 34 | + var data2 = Pixastic.prepareData(params2); |
| 35 | + var dataDesc2 = params2.canvasData; |
| 36 | + |
| 37 | + var p = w*h; |
| 38 | + var pix = p*4; |
| 39 | + var pix1, pix2; |
| 40 | + var r1, g1, b1; |
| 41 | + var r2, g2, b2; |
| 42 | + var r3, g3, b3; |
| 43 | + var r4, g4, b4; |
| 44 | + |
| 45 | + switch (mode) { |
| 46 | + case "normal" : |
| 47 | + //while (p--) { |
| 48 | + // data2[pix-=4] = data2[pix]; |
| 49 | + // data2[pix1=pix+1] = data2[pix1]; |
| 50 | + // data2[pix2=pix+2] = data2[pix2]; |
| 51 | + //} |
| 52 | + break; |
| 53 | + |
| 54 | + case "multiply" : |
| 55 | + while (p--) { |
| 56 | + data2[pix-=4] = data[pix] * data2[pix] / 255; |
| 57 | + data2[pix1=pix+1] = data[pix1] * data2[pix1] / 255; |
| 58 | + data2[pix2=pix+2] = data[pix2] * data2[pix2] / 255; |
| 59 | + } |
| 60 | + break; |
| 61 | + |
| 62 | + case "lighten" : |
| 63 | + while (p--) { |
| 64 | + if ((r1 = data[pix-=4]) > data2[pix]) |
| 65 | + data2[pix] = r1; |
| 66 | + if ((g1 = data[pix1=pix+1]) > data2[pix1]) |
| 67 | + data2[pix1] = g1; |
| 68 | + if ((b1 = data[pix2=pix+2]) > data2[pix2]) |
| 69 | + data2[pix2] = b1; |
| 70 | + } |
| 71 | + break; |
| 72 | + |
| 73 | + case "darken" : |
| 74 | + while (p--) { |
| 75 | + if ((r1 = data[pix-=4]) < data2[pix]) |
| 76 | + data2[pix] = r1; |
| 77 | + if ((g1 = data[pix1=pix+1]) < data2[pix1]) |
| 78 | + data2[pix1] = g1; |
| 79 | + if ((b1 = data[pix2=pix+2]) < data2[pix2]) |
| 80 | + data2[pix2] = b1; |
| 81 | + |
| 82 | + } |
| 83 | + break; |
| 84 | + |
| 85 | + case "darkercolor" : |
| 86 | + while (p--) { |
| 87 | + if (((r1 = data[pix-=4])*0.3+(g1 = data[pix1=pix+1])*0.59+(b1 = data[pix2=pix+2])*0.11) <= (data2[pix]*0.3+data2[pix1]*0.59+data2[pix2]*0.11)) { |
| 88 | + data2[pix] = r1; |
| 89 | + data2[pix1] = g1; |
| 90 | + data2[pix2] = b1; |
| 91 | + } |
| 92 | + } |
| 93 | + break; |
| 94 | + |
| 95 | + case "lightercolor" : |
| 96 | + while (p--) { |
| 97 | + if (((r1 = data[pix-=4])*0.3+(g1 = data[pix1=pix+1])*0.59+(b1 = data[pix2=pix+2])*0.11) > (data2[pix]*0.3+data2[pix1]*0.59+data2[pix2]*0.11)) { |
| 98 | + data2[pix] = r1; |
| 99 | + data2[pix1] = g1; |
| 100 | + data2[pix2] = b1; |
| 101 | + } |
| 102 | + } |
| 103 | + break; |
| 104 | + |
| 105 | + case "lineardodge" : |
| 106 | + while (p--) { |
| 107 | + if ((r3 = data[pix-=4] + data2[pix]) > 255) |
| 108 | + data2[pix] = 255; |
| 109 | + else |
| 110 | + data2[pix] = r3; |
| 111 | + if ((g3 = data[pix1=pix+1] + data2[pix1]) > 255) |
| 112 | + data2[pix1] = 255; |
| 113 | + else |
| 114 | + data2[pix1] = g3; |
| 115 | + if ((b3 = data[pix2=pix+2] + data2[pix2]) > 255) |
| 116 | + data2[pix2] = 255; |
| 117 | + else |
| 118 | + data2[pix2] = b3; |
| 119 | + } |
| 120 | + break; |
| 121 | + |
| 122 | + case "linearburn" : |
| 123 | + while (p--) { |
| 124 | + if ((r3 = data[pix-=4] + data2[pix]) < 255) |
| 125 | + data2[pix] = 0; |
| 126 | + else |
| 127 | + data2[pix] = (r3 - 255); |
| 128 | + if ((g3 = data[pix1=pix+1] + data2[pix1]) < 255) |
| 129 | + data2[pix1] = 0; |
| 130 | + else |
| 131 | + data2[pix1] = (g3 - 255); |
| 132 | + if ((b3 = data[pix2=pix+2] + data2[pix2]) < 255) |
| 133 | + data2[pix2] = 0; |
| 134 | + else |
| 135 | + data2[pix2] = (b3 - 255); |
| 136 | + } |
| 137 | + break; |
| 138 | + |
| 139 | + case "difference" : |
| 140 | + while (p--) { |
| 141 | + if ((r3 = data[pix-=4] - data2[pix]) < 0) |
| 142 | + data2[pix] = -r3; |
| 143 | + else |
| 144 | + data2[pix] = r3; |
| 145 | + if ((g3 = data[pix1=pix+1] - data2[pix1]) < 0) |
| 146 | + data2[pix1] = -g3; |
| 147 | + else |
| 148 | + data2[pix1] = g3; |
| 149 | + if ((b3 = data[pix2=pix+2] - data2[pix2]) < 0) |
| 150 | + data2[pix2] = -b3; |
| 151 | + else |
| 152 | + data2[pix2] = b3; |
| 153 | + } |
| 154 | + break; |
| 155 | + |
| 156 | + case "screen" : |
| 157 | + while (p--) { |
| 158 | + data2[pix-=4] = (255 - ( ((255-data2[pix])*(255-data[pix])) >> 8)); |
| 159 | + data2[pix1=pix+1] = (255 - ( ((255-data2[pix1])*(255-data[pix1])) >> 8)); |
| 160 | + data2[pix2=pix+2] = (255 - ( ((255-data2[pix2])*(255-data[pix2])) >> 8)); |
| 161 | + } |
| 162 | + break; |
| 163 | + |
| 164 | + case "exclusion" : |
| 165 | + var div_2_255 = 2 / 255; |
| 166 | + while (p--) { |
| 167 | + data2[pix-=4] = (r1 = data[pix]) - (r1 * div_2_255 - 1) * data2[pix]; |
| 168 | + data2[pix1=pix+1] = (g1 = data[pix1]) - (g1 * div_2_255 - 1) * data2[pix1]; |
| 169 | + data2[pix2=pix+2] = (b1 = data[pix2]) - (b1 * div_2_255 - 1) * data2[pix2]; |
| 170 | + } |
| 171 | + break; |
| 172 | + |
| 173 | + case "overlay" : |
| 174 | + var div_2_255 = 2 / 255; |
| 175 | + while (p--) { |
| 176 | + if ((r1 = data[pix-=4]) < 128) |
| 177 | + data2[pix] = data2[pix]*r1*div_2_255; |
| 178 | + else |
| 179 | + data2[pix] = 255 - (255-data2[pix])*(255-r1)*div_2_255; |
| 180 | + |
| 181 | + if ((g1 = data[pix1=pix+1]) < 128) |
| 182 | + data2[pix1] = data2[pix1]*g1*div_2_255; |
| 183 | + else |
| 184 | + data2[pix1] = 255 - (255-data2[pix1])*(255-g1)*div_2_255; |
| 185 | + |
| 186 | + if ((b1 = data[pix2=pix+2]) < 128) |
| 187 | + data2[pix2] = data2[pix2]*b1*div_2_255; |
| 188 | + else |
| 189 | + data2[pix2] = 255 - (255-data2[pix2])*(255-b1)*div_2_255; |
| 190 | + |
| 191 | + } |
| 192 | + break; |
| 193 | + |
| 194 | + case "softlight" : |
| 195 | + var div_2_255 = 2 / 255; |
| 196 | + while (p--) { |
| 197 | + if ((r1 = data[pix-=4]) < 128) |
| 198 | + data2[pix] = ((data2[pix]>>1) + 64) * r1 * div_2_255; |
| 199 | + else |
| 200 | + data2[pix] = 255 - (191 - (data2[pix]>>1)) * (255-r1) * div_2_255; |
| 201 | + |
| 202 | + if ((g1 = data[pix1=pix+1]) < 128) |
| 203 | + data2[pix1] = ((data2[pix1]>>1)+64) * g1 * div_2_255; |
| 204 | + else |
| 205 | + data2[pix1] = 255 - (191 - (data2[pix1]>>1)) * (255-g1) * div_2_255; |
| 206 | + |
| 207 | + if ((b1 = data[pix2=pix+2]) < 128) |
| 208 | + data2[pix2] = ((data2[pix2]>>1)+64) * b1 * div_2_255; |
| 209 | + else |
| 210 | + data2[pix2] = 255 - (191 - (data2[pix2]>>1)) * (255-b1) * div_2_255; |
| 211 | + |
| 212 | + } |
| 213 | + break; |
| 214 | + |
| 215 | + |
| 216 | + case "hardlight" : |
| 217 | + var div_2_255 = 2 / 255; |
| 218 | + while (p--) { |
| 219 | + if ((r2 = data2[pix-=4]) < 128) |
| 220 | + data2[pix] = data[pix] * r2 * div_2_255; |
| 221 | + else |
| 222 | + data2[pix] = 255 - (255-data[pix]) * (255-r2) * div_2_255; |
| 223 | + |
| 224 | + if ((g2 = data2[pix1=pix+1]) < 128) |
| 225 | + data2[pix1] = data[pix1] * g2 * div_2_255; |
| 226 | + else |
| 227 | + data2[pix1] = 255 - (255-data[pix1]) * (255-g2) * div_2_255; |
| 228 | + |
| 229 | + if ((b2 = data2[pix2=pix+2]) < 128) |
| 230 | + data2[pix2] = data[pix2] * b2 * div_2_255; |
| 231 | + else |
| 232 | + data2[pix2] = 255 - (255-data[pix2]) * (255-b2) * div_2_255; |
| 233 | + |
| 234 | + } |
| 235 | + break; |
| 236 | + |
| 237 | + case "colordodge" : |
| 238 | + while (p--) { |
| 239 | + if ((r3 = (data[pix-=4]<<8)/(255-(r2 = data2[pix]))) > 255 || r2 == 255) |
| 240 | + data2[pix] = 255; |
| 241 | + else |
| 242 | + data2[pix] = r3; |
| 243 | + |
| 244 | + if ((g3 = (data[pix1=pix+1]<<8)/(255-(g2 = data2[pix1]))) > 255 || g2 == 255) |
| 245 | + data2[pix1] = 255; |
| 246 | + else |
| 247 | + data2[pix1] = g3; |
| 248 | + |
| 249 | + if ((b3 = (data[pix2=pix+2]<<8)/(255-(b2 = data2[pix2]))) > 255 || b2 == 255) |
| 250 | + data2[pix2] = 255; |
| 251 | + else |
| 252 | + data2[pix2] = b3; |
| 253 | + } |
| 254 | + |
| 255 | + break; |
| 256 | + |
| 257 | + case "colorburn" : |
| 258 | + while (p--) { |
| 259 | + if ((r3 = 255-((255-data[pix-=4])<<8)/data2[pix]) < 0 || data2[pix] == 0) |
| 260 | + data2[pix] = 0; |
| 261 | + else |
| 262 | + data2[pix] = r3; |
| 263 | + |
| 264 | + if ((g3 = 255-((255-data[pix1=pix+1])<<8)/data2[pix1]) < 0 || data2[pix1] == 0) |
| 265 | + data2[pix1] = 0; |
| 266 | + else |
| 267 | + data2[pix1] = g3; |
| 268 | + |
| 269 | + if ((b3 = 255-((255-data[pix2=pix+2])<<8)/data2[pix2]) < 0 || data2[pix2] == 0) |
| 270 | + data2[pix2] = 0; |
| 271 | + else |
| 272 | + data2[pix2] = b3; |
| 273 | + } |
| 274 | + break; |
| 275 | + |
| 276 | + case "linearlight" : |
| 277 | + while (p--) { |
| 278 | + if ( ((r3 = 2*(r2=data2[pix-=4])+data[pix]-256) < 0) || (r2 < 128 && r3 < 0)) { |
| 279 | + data2[pix] = 0 |
| 280 | + } else { |
| 281 | + if (r3 > 255) |
| 282 | + data2[pix] = 255; |
| 283 | + else |
| 284 | + data2[pix] = r3; |
| 285 | + } |
| 286 | + if ( ((g3 = 2*(g2=data2[pix1=pix+1])+data[pix1]-256) < 0) || (g2 < 128 && g3 < 0)) { |
| 287 | + data2[pix1] = 0 |
| 288 | + } else { |
| 289 | + if (g3 > 255) |
| 290 | + data2[pix1] = 255; |
| 291 | + else |
| 292 | + data2[pix1] = g3; |
| 293 | + } |
| 294 | + if ( ((b3 = 2*(b2=data2[pix2=pix+2])+data[pix2]-256) < 0) || (b2 < 128 && b3 < 0)) { |
| 295 | + data2[pix2] = 0 |
| 296 | + } else { |
| 297 | + if (b3 > 255) |
| 298 | + data2[pix2] = 255; |
| 299 | + else |
| 300 | + data2[pix2] = b3; |
| 301 | + } |
| 302 | + } |
| 303 | + |
| 304 | + break; |
| 305 | + |
| 306 | + case "vividlight" : |
| 307 | + while (p--) { |
| 308 | + if ((r2=data2[pix-=4]) < 128) { |
| 309 | + if (r2) { |
| 310 | + if ((r3 = 255 - ((255-data[pix])<<8) / (2*r2)) < 0) |
| 311 | + data2[pix] = 0; |
| 312 | + else |
| 313 | + data2[pix] = r3 |
| 314 | + } else { |
| 315 | + data2[pix] = 0; |
| 316 | + } |
| 317 | + } else if ((r3 = (r4=2*r2-256)) < 255) { |
| 318 | + if ((r3 = (data[pix]<<8)/(255-r4)) > 255) |
| 319 | + data2[pix] = 255; |
| 320 | + else |
| 321 | + data2[pix] = r3; |
| 322 | + } else { |
| 323 | + if (r3 < 0) |
| 324 | + data2[pix] = 0; |
| 325 | + else |
| 326 | + data2[pix] = r3 |
| 327 | + } |
| 328 | + |
| 329 | + if ((g2=data2[pix1=pix+1]) < 128) { |
| 330 | + if (g2) { |
| 331 | + if ((g3 = 255 - ((255-data[pix1])<<8) / (2*g2)) < 0) |
| 332 | + data2[pix1] = 0; |
| 333 | + else |
| 334 | + data2[pix1] = g3; |
| 335 | + } else { |
| 336 | + data2[pix1] = 0; |
| 337 | + } |
| 338 | + } else if ((g3 = (g4=2*g2-256)) < 255) { |
| 339 | + if ((g3 = (data[pix1]<<8)/(255-g4)) > 255) |
| 340 | + data2[pix1] = 255; |
| 341 | + else |
| 342 | + data2[pix1] = g3; |
| 343 | + } else { |
| 344 | + if (g3 < 0) |
| 345 | + data2[pix1] = 0; |
| 346 | + else |
| 347 | + data2[pix1] = g3; |
| 348 | + } |
| 349 | + |
| 350 | + if ((b2=data2[pix2=pix+2]) < 128) { |
| 351 | + if (b2) { |
| 352 | + if ((b3 = 255 - ((255-data[pix2])<<8) / (2*b2)) < 0) |
| 353 | + data2[pix2] = 0; |
| 354 | + else |
| 355 | + data2[pix2] = b3; |
| 356 | + } else { |
| 357 | + data2[pix2] = 0; |
| 358 | + } |
| 359 | + } else if ((b3 = (b4=2*b2-256)) < 255) { |
| 360 | + if ((b3 = (data[pix2]<<8)/(255-b4)) > 255) |
| 361 | + data2[pix2] = 255; |
| 362 | + else |
| 363 | + data2[pix2] = b3; |
| 364 | + } else { |
| 365 | + if (b3 < 0) |
| 366 | + data2[pix2] = 0; |
| 367 | + else |
| 368 | + data2[pix2] = b3; |
| 369 | + } |
| 370 | + } |
| 371 | + break; |
| 372 | + |
| 373 | + case "pinlight" : |
| 374 | + while (p--) { |
| 375 | + if ((r2=data2[pix-=4]) < 128) |
| 376 | + if ((r1=data[pix]) < (r4=2*r2)) |
| 377 | + data2[pix] = r1; |
| 378 | + else |
| 379 | + data2[pix] = r4; |
| 380 | + else |
| 381 | + if ((r1=data[pix]) > (r4=2*r2-256)) |
| 382 | + data2[pix] = r1; |
| 383 | + else |
| 384 | + data2[pix] = r4; |
| 385 | + |
| 386 | + if ((g2=data2[pix1=pix+1]) < 128) |
| 387 | + if ((g1=data[pix1]) < (g4=2*g2)) |
| 388 | + data2[pix1] = g1; |
| 389 | + else |
| 390 | + data2[pix1] = g4; |
| 391 | + else |
| 392 | + if ((g1=data[pix1]) > (g4=2*g2-256)) |
| 393 | + data2[pix1] = g1; |
| 394 | + else |
| 395 | + data2[pix1] = g4; |
| 396 | + |
| 397 | + if ((r2=data2[pix2=pix+2]) < 128) |
| 398 | + if ((r1=data[pix2]) < (r4=2*r2)) |
| 399 | + data2[pix2] = r1; |
| 400 | + else |
| 401 | + data2[pix2] = r4; |
| 402 | + else |
| 403 | + if ((r1=data[pix2]) > (r4=2*r2-256)) |
| 404 | + data2[pix2] = r1; |
| 405 | + else |
| 406 | + data2[pix2] = r4; |
| 407 | + } |
| 408 | + break; |
| 409 | + |
| 410 | + case "hardmix" : |
| 411 | + while (p--) { |
| 412 | + if ((r2 = data2[pix-=4]) < 128) |
| 413 | + if (255 - ((255-data[pix])<<8)/(2*r2) < 128 || r2 == 0) |
| 414 | + data2[pix] = 0; |
| 415 | + else |
| 416 | + data2[pix] = 255; |
| 417 | + else if ((r4=2*r2-256) < 255 && (data[pix]<<8)/(255-r4) < 128) |
| 418 | + data2[pix] = 0; |
| 419 | + else |
| 420 | + data2[pix] = 255; |
| 421 | + |
| 422 | + if ((g2 = data2[pix1=pix+1]) < 128) |
| 423 | + if (255 - ((255-data[pix1])<<8)/(2*g2) < 128 || g2 == 0) |
| 424 | + data2[pix1] = 0; |
| 425 | + else |
| 426 | + data2[pix1] = 255; |
| 427 | + else if ((g4=2*g2-256) < 255 && (data[pix1]<<8)/(255-g4) < 128) |
| 428 | + data2[pix1] = 0; |
| 429 | + else |
| 430 | + data2[pix1] = 255; |
| 431 | + |
| 432 | + if ((b2 = data2[pix2=pix+2]) < 128) |
| 433 | + if (255 - ((255-data[pix2])<<8)/(2*b2) < 128 || b2 == 0) |
| 434 | + data2[pix2] = 0; |
| 435 | + else |
| 436 | + data2[pix2] = 255; |
| 437 | + else if ((b4=2*b2-256) < 255 && (data[pix2]<<8)/(255-b4) < 128) |
| 438 | + data2[pix2] = 0; |
| 439 | + else |
| 440 | + data2[pix2] = 255; |
| 441 | + } |
| 442 | + break; |
| 443 | + } |
| 444 | + |
| 445 | + otherCtx.putImageData(dataDesc2,0,0); |
| 446 | + var ctx = params.canvas.getContext("2d"); |
| 447 | + ctx.save(); |
| 448 | + ctx.globalAlpha = amount; |
| 449 | + ctx.drawImage( |
| 450 | + otherCanvas, |
| 451 | + 0,0,rect.width,rect.height, |
| 452 | + rect.left,rect.top,rect.width,rect.height |
| 453 | + ); |
| 454 | + ctx.globalAlpha = 1; |
| 455 | + ctx.restore(); |
| 456 | + |
| 457 | + return true; |
| 458 | + } |
| 459 | + }, |
| 460 | + checkSupport : function() { |
| 461 | + return Pixastic.Client.hasCanvasImageData(); |
| 462 | + } |
463 | 463 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/blend.js |
___________________________________________________________________ |
Added: svn:eol-style |
464 | 464 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/posterize.js |
— | — | @@ -1,57 +1,57 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Posterize effect - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.posterize = {
|
9 | | -
|
10 | | - process : function(params) {
|
11 | | -
|
12 | | -
|
13 | | - var numLevels = 256;
|
14 | | - if (typeof params.options.levels != "undefined")
|
15 | | - numLevels = parseInt(params.options.levels,10)||1;
|
16 | | -
|
17 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
18 | | - var data = Pixastic.prepareData(params);
|
19 | | -
|
20 | | - numLevels = Math.max(2,Math.min(256,numLevels));
|
21 | | -
|
22 | | - var numAreas = 256 / numLevels;
|
23 | | - var numValues = 256 / (numLevels-1);
|
24 | | -
|
25 | | - var rect = params.options.rect;
|
26 | | - var w = rect.width;
|
27 | | - var h = rect.height;
|
28 | | - var w4 = w*4;
|
29 | | - var y = h;
|
30 | | - do {
|
31 | | - var offsetY = (y-1)*w4;
|
32 | | - var x = w;
|
33 | | - do {
|
34 | | - var offset = offsetY + (x-1)*4;
|
35 | | -
|
36 | | - var r = numValues * ((data[offset] / numAreas)>>0);
|
37 | | - var g = numValues * ((data[offset+1] / numAreas)>>0);
|
38 | | - var b = numValues * ((data[offset+2] / numAreas)>>0);
|
39 | | -
|
40 | | - if (r > 255) r = 255;
|
41 | | - if (g > 255) g = 255;
|
42 | | - if (b > 255) b = 255;
|
43 | | -
|
44 | | - data[offset] = r;
|
45 | | - data[offset+1] = g;
|
46 | | - data[offset+2] = b;
|
47 | | -
|
48 | | - } while (--x);
|
49 | | - } while (--y);
|
50 | | - return true;
|
51 | | - }
|
52 | | - },
|
53 | | - checkSupport : function() {
|
54 | | - return Pixastic.Client.hasCanvasImageData();
|
55 | | - }
|
56 | | -}
|
57 | | -
|
58 | | -
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Posterize effect - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.posterize = { |
| 9 | + |
| 10 | + process : function(params) { |
| 11 | + |
| 12 | + |
| 13 | + var numLevels = 256; |
| 14 | + if (typeof params.options.levels != "undefined") |
| 15 | + numLevels = parseInt(params.options.levels,10)||1; |
| 16 | + |
| 17 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 18 | + var data = Pixastic.prepareData(params); |
| 19 | + |
| 20 | + numLevels = Math.max(2,Math.min(256,numLevels)); |
| 21 | + |
| 22 | + var numAreas = 256 / numLevels; |
| 23 | + var numValues = 256 / (numLevels-1); |
| 24 | + |
| 25 | + var rect = params.options.rect; |
| 26 | + var w = rect.width; |
| 27 | + var h = rect.height; |
| 28 | + var w4 = w*4; |
| 29 | + var y = h; |
| 30 | + do { |
| 31 | + var offsetY = (y-1)*w4; |
| 32 | + var x = w; |
| 33 | + do { |
| 34 | + var offset = offsetY + (x-1)*4; |
| 35 | + |
| 36 | + var r = numValues * ((data[offset] / numAreas)>>0); |
| 37 | + var g = numValues * ((data[offset+1] / numAreas)>>0); |
| 38 | + var b = numValues * ((data[offset+2] / numAreas)>>0); |
| 39 | + |
| 40 | + if (r > 255) r = 255; |
| 41 | + if (g > 255) g = 255; |
| 42 | + if (b > 255) b = 255; |
| 43 | + |
| 44 | + data[offset] = r; |
| 45 | + data[offset+1] = g; |
| 46 | + data[offset+2] = b; |
| 47 | + |
| 48 | + } while (--x); |
| 49 | + } while (--y); |
| 50 | + return true; |
| 51 | + } |
| 52 | + }, |
| 53 | + checkSupport : function() { |
| 54 | + return Pixastic.Client.hasCanvasImageData(); |
| 55 | + } |
| 56 | +} |
| 57 | + |
| 58 | + |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/posterize.js |
___________________________________________________________________ |
Added: svn:eol-style |
59 | 59 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/hsl.js |
— | — | @@ -1,135 +1,135 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - HSL Adjust - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.hsl = {
|
9 | | - process : function(params) {
|
10 | | -
|
11 | | - var hue = parseInt(params.options.hue,10)||0;
|
12 | | - var saturation = (parseInt(params.options.saturation,10)||0) / 100;
|
13 | | - var lightness = (parseInt(params.options.lightness,10)||0) / 100;
|
14 | | -
|
15 | | -
|
16 | | - // this seems to give the same result as Photoshop
|
17 | | - if (saturation < 0) {
|
18 | | - var satMul = 1+saturation;
|
19 | | - } else {
|
20 | | - var satMul = 1+saturation*2;
|
21 | | - }
|
22 | | -
|
23 | | - hue = (hue%360) / 360;
|
24 | | - var hue6 = hue * 6;
|
25 | | -
|
26 | | - var rgbDiv = 1 / 255;
|
27 | | -
|
28 | | - var light255 = lightness * 255;
|
29 | | - var lightp1 = 1 + lightness;
|
30 | | - var lightm1 = 1 - lightness;
|
31 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
32 | | - var data = Pixastic.prepareData(params);
|
33 | | -
|
34 | | - var rect = params.options.rect;
|
35 | | - var w = rect.width;
|
36 | | - var h = rect.height;
|
37 | | -
|
38 | | - var w4 = w*4;
|
39 | | - var y = h;
|
40 | | -
|
41 | | - do {
|
42 | | - var offsetY = (y-1)*w4;
|
43 | | - var x = w;
|
44 | | - do {
|
45 | | - var offset = offsetY + (x*4-4);
|
46 | | -
|
47 | | - var r = data[offset];
|
48 | | - var g = data[offset+1];
|
49 | | - var b = data[offset+2];
|
50 | | -
|
51 | | - if (hue != 0 || saturation != 0) {
|
52 | | - // ok, here comes rgb to hsl + adjust + hsl to rgb, all in one jumbled mess.
|
53 | | - // It's not so pretty, but it's been optimized to get somewhat decent performance.
|
54 | | - // The transforms were originally adapted from the ones found in Graphics Gems, but have been heavily modified.
|
55 | | - var vs = r;
|
56 | | - if (g > vs) vs = g;
|
57 | | - if (b > vs) vs = b;
|
58 | | - var ms = r;
|
59 | | - if (g < ms) ms = g;
|
60 | | - if (b < ms) ms = b;
|
61 | | - var vm = (vs-ms);
|
62 | | - var l = (ms+vs)/255 * 0.5;
|
63 | | - if (l > 0) {
|
64 | | - if (vm > 0) {
|
65 | | - if (l <= 0.5) {
|
66 | | - var s = vm / (vs+ms) * satMul;
|
67 | | - if (s > 1) s = 1;
|
68 | | - var v = (l * (1+s));
|
69 | | - } else {
|
70 | | - var s = vm / (510-vs-ms) * satMul;
|
71 | | - if (s > 1) s = 1;
|
72 | | - var v = (l+s - l*s);
|
73 | | - }
|
74 | | - if (r == vs) {
|
75 | | - if (g == ms)
|
76 | | - var h = 5 + ((vs-b)/vm) + hue6;
|
77 | | - else
|
78 | | - var h = 1 - ((vs-g)/vm) + hue6;
|
79 | | - } else if (g == vs) {
|
80 | | - if (b == ms)
|
81 | | - var h = 1 + ((vs-r)/vm) + hue6;
|
82 | | - else
|
83 | | - var h = 3 - ((vs-b)/vm) + hue6;
|
84 | | - } else {
|
85 | | - if (r == ms)
|
86 | | - var h = 3 + ((vs-g)/vm) + hue6;
|
87 | | - else
|
88 | | - var h = 5 - ((vs-r)/vm) + hue6;
|
89 | | - }
|
90 | | - if (h < 0) h+=6;
|
91 | | - if (h >= 6) h-=6;
|
92 | | - var m = (l+l-v);
|
93 | | - var sextant = h>>0;
|
94 | | - switch (sextant) {
|
95 | | - case 0: r = v*255; g = (m+((v-m)*(h-sextant)))*255; b = m*255; break;
|
96 | | - case 1: r = (v-((v-m)*(h-sextant)))*255; g = v*255; b = m*255; break;
|
97 | | - case 2: r = m*255; g = v*255; b = (m+((v-m)*(h-sextant)))*255; break;
|
98 | | - case 3: r = m*255; g = (v-((v-m)*(h-sextant)))*255; b = v*255; break;
|
99 | | - case 4: r = (m+((v-m)*(h-sextant)))*255; g = m*255; b = v*255; break;
|
100 | | - case 5: r = v*255; g = m*255; b = (v-((v-m)*(h-sextant)))*255; break;
|
101 | | - }
|
102 | | - }
|
103 | | - }
|
104 | | - }
|
105 | | -
|
106 | | - if (lightness < 0) {
|
107 | | - r *= lightp1;
|
108 | | - g *= lightp1;
|
109 | | - b *= lightp1;
|
110 | | - } else if (lightness > 0) {
|
111 | | - r = r * lightm1 + light255;
|
112 | | - g = g * lightm1 + light255;
|
113 | | - b = b * lightm1 + light255;
|
114 | | - }
|
115 | | -
|
116 | | - if (r < 0) r = 0;
|
117 | | - if (g < 0) g = 0;
|
118 | | - if (b < 0) b = 0;
|
119 | | - if (r > 255) r = 255;
|
120 | | - if (g > 255) g = 255;
|
121 | | - if (b > 255) b = 255;
|
122 | | -
|
123 | | - data[offset] = r;
|
124 | | - data[offset+1] = g;
|
125 | | - data[offset+2] = b;
|
126 | | -
|
127 | | - } while (--x);
|
128 | | - } while (--y);
|
129 | | - return true;
|
130 | | - }
|
131 | | - },
|
132 | | - checkSupport : function() {
|
133 | | - return Pixastic.Client.hasCanvasImageData();
|
134 | | - }
|
135 | | -
|
136 | | -}
|
| 2 | +/* |
| 3 | + * Pixastic Lib - HSL Adjust - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.hsl = { |
| 9 | + process : function(params) { |
| 10 | + |
| 11 | + var hue = parseInt(params.options.hue,10)||0; |
| 12 | + var saturation = (parseInt(params.options.saturation,10)||0) / 100; |
| 13 | + var lightness = (parseInt(params.options.lightness,10)||0) / 100; |
| 14 | + |
| 15 | + |
| 16 | + // this seems to give the same result as Photoshop |
| 17 | + if (saturation < 0) { |
| 18 | + var satMul = 1+saturation; |
| 19 | + } else { |
| 20 | + var satMul = 1+saturation*2; |
| 21 | + } |
| 22 | + |
| 23 | + hue = (hue%360) / 360; |
| 24 | + var hue6 = hue * 6; |
| 25 | + |
| 26 | + var rgbDiv = 1 / 255; |
| 27 | + |
| 28 | + var light255 = lightness * 255; |
| 29 | + var lightp1 = 1 + lightness; |
| 30 | + var lightm1 = 1 - lightness; |
| 31 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 32 | + var data = Pixastic.prepareData(params); |
| 33 | + |
| 34 | + var rect = params.options.rect; |
| 35 | + var w = rect.width; |
| 36 | + var h = rect.height; |
| 37 | + |
| 38 | + var w4 = w*4; |
| 39 | + var y = h; |
| 40 | + |
| 41 | + do { |
| 42 | + var offsetY = (y-1)*w4; |
| 43 | + var x = w; |
| 44 | + do { |
| 45 | + var offset = offsetY + (x*4-4); |
| 46 | + |
| 47 | + var r = data[offset]; |
| 48 | + var g = data[offset+1]; |
| 49 | + var b = data[offset+2]; |
| 50 | + |
| 51 | + if (hue != 0 || saturation != 0) { |
| 52 | + // ok, here comes rgb to hsl + adjust + hsl to rgb, all in one jumbled mess. |
| 53 | + // It's not so pretty, but it's been optimized to get somewhat decent performance. |
| 54 | + // The transforms were originally adapted from the ones found in Graphics Gems, but have been heavily modified. |
| 55 | + var vs = r; |
| 56 | + if (g > vs) vs = g; |
| 57 | + if (b > vs) vs = b; |
| 58 | + var ms = r; |
| 59 | + if (g < ms) ms = g; |
| 60 | + if (b < ms) ms = b; |
| 61 | + var vm = (vs-ms); |
| 62 | + var l = (ms+vs)/255 * 0.5; |
| 63 | + if (l > 0) { |
| 64 | + if (vm > 0) { |
| 65 | + if (l <= 0.5) { |
| 66 | + var s = vm / (vs+ms) * satMul; |
| 67 | + if (s > 1) s = 1; |
| 68 | + var v = (l * (1+s)); |
| 69 | + } else { |
| 70 | + var s = vm / (510-vs-ms) * satMul; |
| 71 | + if (s > 1) s = 1; |
| 72 | + var v = (l+s - l*s); |
| 73 | + } |
| 74 | + if (r == vs) { |
| 75 | + if (g == ms) |
| 76 | + var h = 5 + ((vs-b)/vm) + hue6; |
| 77 | + else |
| 78 | + var h = 1 - ((vs-g)/vm) + hue6; |
| 79 | + } else if (g == vs) { |
| 80 | + if (b == ms) |
| 81 | + var h = 1 + ((vs-r)/vm) + hue6; |
| 82 | + else |
| 83 | + var h = 3 - ((vs-b)/vm) + hue6; |
| 84 | + } else { |
| 85 | + if (r == ms) |
| 86 | + var h = 3 + ((vs-g)/vm) + hue6; |
| 87 | + else |
| 88 | + var h = 5 - ((vs-r)/vm) + hue6; |
| 89 | + } |
| 90 | + if (h < 0) h+=6; |
| 91 | + if (h >= 6) h-=6; |
| 92 | + var m = (l+l-v); |
| 93 | + var sextant = h>>0; |
| 94 | + switch (sextant) { |
| 95 | + case 0: r = v*255; g = (m+((v-m)*(h-sextant)))*255; b = m*255; break; |
| 96 | + case 1: r = (v-((v-m)*(h-sextant)))*255; g = v*255; b = m*255; break; |
| 97 | + case 2: r = m*255; g = v*255; b = (m+((v-m)*(h-sextant)))*255; break; |
| 98 | + case 3: r = m*255; g = (v-((v-m)*(h-sextant)))*255; b = v*255; break; |
| 99 | + case 4: r = (m+((v-m)*(h-sextant)))*255; g = m*255; b = v*255; break; |
| 100 | + case 5: r = v*255; g = m*255; b = (v-((v-m)*(h-sextant)))*255; break; |
| 101 | + } |
| 102 | + } |
| 103 | + } |
| 104 | + } |
| 105 | + |
| 106 | + if (lightness < 0) { |
| 107 | + r *= lightp1; |
| 108 | + g *= lightp1; |
| 109 | + b *= lightp1; |
| 110 | + } else if (lightness > 0) { |
| 111 | + r = r * lightm1 + light255; |
| 112 | + g = g * lightm1 + light255; |
| 113 | + b = b * lightm1 + light255; |
| 114 | + } |
| 115 | + |
| 116 | + if (r < 0) r = 0; |
| 117 | + if (g < 0) g = 0; |
| 118 | + if (b < 0) b = 0; |
| 119 | + if (r > 255) r = 255; |
| 120 | + if (g > 255) g = 255; |
| 121 | + if (b > 255) b = 255; |
| 122 | + |
| 123 | + data[offset] = r; |
| 124 | + data[offset+1] = g; |
| 125 | + data[offset+2] = b; |
| 126 | + |
| 127 | + } while (--x); |
| 128 | + } while (--y); |
| 129 | + return true; |
| 130 | + } |
| 131 | + }, |
| 132 | + checkSupport : function() { |
| 133 | + return Pixastic.Client.hasCanvasImageData(); |
| 134 | + } |
| 135 | + |
| 136 | +} |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/hsl.js |
___________________________________________________________________ |
Added: svn:eol-style |
137 | 137 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/edges.js |
— | — | @@ -1,121 +1,121 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Edge detection filter - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.edges = {
|
9 | | - process : function(params) {
|
10 | | -
|
11 | | - var mono = !!(params.options.mono);
|
12 | | -
|
13 | | - var strength = 1.0;
|
14 | | -
|
15 | | - //if (typeof params.options.strength != "undefined")
|
16 | | - // strength = parseFloat(params.options.strength)||0;
|
17 | | -
|
18 | | - var invert = !!(params.options.invert);
|
19 | | -
|
20 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
21 | | - var data = Pixastic.prepareData(params);
|
22 | | - var dataCopy = Pixastic.prepareData(params, true)
|
23 | | -
|
24 | | - var c = -strength/8;
|
25 | | - var kernel = [
|
26 | | - [c, c, c],
|
27 | | - [c, 1, c],
|
28 | | - [c, c, c]
|
29 | | - ];
|
30 | | -
|
31 | | - weight = 1/c;
|
32 | | -
|
33 | | - var rect = params.options.rect;
|
34 | | - var w = rect.width;
|
35 | | - var h = rect.height;
|
36 | | -
|
37 | | - var w4 = w*4;
|
38 | | - var y = h;
|
39 | | - do {
|
40 | | - var offsetY = (y-1)*w4;
|
41 | | -
|
42 | | - var nextY = (y == h) ? y - 1 : y;
|
43 | | - var prevY = (y == 1) ? 0 : y-2;
|
44 | | -
|
45 | | - var offsetYPrev = prevY*w*4;
|
46 | | - var offsetYNext = nextY*w*4;
|
47 | | -
|
48 | | - var x = w;
|
49 | | - do {
|
50 | | - var offset = offsetY + (x*4-4);
|
51 | | -
|
52 | | - var offsetPrev = offsetYPrev + ((x == 1) ? 0 : x-2) * 4;
|
53 | | - var offsetNext = offsetYNext + ((x == w) ? x-1 : x) * 4;
|
54 | | -
|
55 | | - var r = ((dataCopy[offsetPrev-4]
|
56 | | - + dataCopy[offsetPrev]
|
57 | | - + dataCopy[offsetPrev+4]
|
58 | | - + dataCopy[offset-4]
|
59 | | - + dataCopy[offset+4]
|
60 | | - + dataCopy[offsetNext-4]
|
61 | | - + dataCopy[offsetNext]
|
62 | | - + dataCopy[offsetNext+4]) * c
|
63 | | - + dataCopy[offset]
|
64 | | - )
|
65 | | - * weight;
|
66 | | -
|
67 | | - var g = ((dataCopy[offsetPrev-3]
|
68 | | - + dataCopy[offsetPrev+1]
|
69 | | - + dataCopy[offsetPrev+5]
|
70 | | - + dataCopy[offset-3]
|
71 | | - + dataCopy[offset+5]
|
72 | | - + dataCopy[offsetNext-3]
|
73 | | - + dataCopy[offsetNext+1]
|
74 | | - + dataCopy[offsetNext+5]) * c
|
75 | | - + dataCopy[offset+1])
|
76 | | - * weight;
|
77 | | -
|
78 | | - var b = ((dataCopy[offsetPrev-2]
|
79 | | - + dataCopy[offsetPrev+2]
|
80 | | - + dataCopy[offsetPrev+6]
|
81 | | - + dataCopy[offset-2]
|
82 | | - + dataCopy[offset+6]
|
83 | | - + dataCopy[offsetNext-2]
|
84 | | - + dataCopy[offsetNext+2]
|
85 | | - + dataCopy[offsetNext+6]) * c
|
86 | | - + dataCopy[offset+2])
|
87 | | - * weight;
|
88 | | -
|
89 | | - if (mono) {
|
90 | | - var brightness = (r*0.3 + g*0.59 + b*0.11)||0;
|
91 | | - if (invert) brightness = 255 - brightness;
|
92 | | - if (brightness < 0 ) brightness = 0;
|
93 | | - if (brightness > 255 ) brightness = 255;
|
94 | | - r = g = b = brightness;
|
95 | | - } else {
|
96 | | - if (invert) {
|
97 | | - r = 255 - r;
|
98 | | - g = 255 - g;
|
99 | | - b = 255 - b;
|
100 | | - }
|
101 | | - if (r < 0 ) r = 0;
|
102 | | - if (g < 0 ) g = 0;
|
103 | | - if (b < 0 ) b = 0;
|
104 | | - if (r > 255 ) r = 255;
|
105 | | - if (g > 255 ) g = 255;
|
106 | | - if (b > 255 ) b = 255;
|
107 | | - }
|
108 | | -
|
109 | | - data[offset] = r;
|
110 | | - data[offset+1] = g;
|
111 | | - data[offset+2] = b;
|
112 | | -
|
113 | | - } while (--x);
|
114 | | - } while (--y);
|
115 | | -
|
116 | | - return true;
|
117 | | - }
|
118 | | - },
|
119 | | - checkSupport : function() {
|
120 | | - return Pixastic.Client.hasCanvasImageData();
|
121 | | - }
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Edge detection filter - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.edges = { |
| 9 | + process : function(params) { |
| 10 | + |
| 11 | + var mono = !!(params.options.mono); |
| 12 | + |
| 13 | + var strength = 1.0; |
| 14 | + |
| 15 | + //if (typeof params.options.strength != "undefined") |
| 16 | + // strength = parseFloat(params.options.strength)||0; |
| 17 | + |
| 18 | + var invert = !!(params.options.invert); |
| 19 | + |
| 20 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 21 | + var data = Pixastic.prepareData(params); |
| 22 | + var dataCopy = Pixastic.prepareData(params, true) |
| 23 | + |
| 24 | + var c = -strength/8; |
| 25 | + var kernel = [ |
| 26 | + [c, c, c], |
| 27 | + [c, 1, c], |
| 28 | + [c, c, c] |
| 29 | + ]; |
| 30 | + |
| 31 | + weight = 1/c; |
| 32 | + |
| 33 | + var rect = params.options.rect; |
| 34 | + var w = rect.width; |
| 35 | + var h = rect.height; |
| 36 | + |
| 37 | + var w4 = w*4; |
| 38 | + var y = h; |
| 39 | + do { |
| 40 | + var offsetY = (y-1)*w4; |
| 41 | + |
| 42 | + var nextY = (y == h) ? y - 1 : y; |
| 43 | + var prevY = (y == 1) ? 0 : y-2; |
| 44 | + |
| 45 | + var offsetYPrev = prevY*w*4; |
| 46 | + var offsetYNext = nextY*w*4; |
| 47 | + |
| 48 | + var x = w; |
| 49 | + do { |
| 50 | + var offset = offsetY + (x*4-4); |
| 51 | + |
| 52 | + var offsetPrev = offsetYPrev + ((x == 1) ? 0 : x-2) * 4; |
| 53 | + var offsetNext = offsetYNext + ((x == w) ? x-1 : x) * 4; |
| 54 | + |
| 55 | + var r = ((dataCopy[offsetPrev-4] |
| 56 | + + dataCopy[offsetPrev] |
| 57 | + + dataCopy[offsetPrev+4] |
| 58 | + + dataCopy[offset-4] |
| 59 | + + dataCopy[offset+4] |
| 60 | + + dataCopy[offsetNext-4] |
| 61 | + + dataCopy[offsetNext] |
| 62 | + + dataCopy[offsetNext+4]) * c |
| 63 | + + dataCopy[offset] |
| 64 | + ) |
| 65 | + * weight; |
| 66 | + |
| 67 | + var g = ((dataCopy[offsetPrev-3] |
| 68 | + + dataCopy[offsetPrev+1] |
| 69 | + + dataCopy[offsetPrev+5] |
| 70 | + + dataCopy[offset-3] |
| 71 | + + dataCopy[offset+5] |
| 72 | + + dataCopy[offsetNext-3] |
| 73 | + + dataCopy[offsetNext+1] |
| 74 | + + dataCopy[offsetNext+5]) * c |
| 75 | + + dataCopy[offset+1]) |
| 76 | + * weight; |
| 77 | + |
| 78 | + var b = ((dataCopy[offsetPrev-2] |
| 79 | + + dataCopy[offsetPrev+2] |
| 80 | + + dataCopy[offsetPrev+6] |
| 81 | + + dataCopy[offset-2] |
| 82 | + + dataCopy[offset+6] |
| 83 | + + dataCopy[offsetNext-2] |
| 84 | + + dataCopy[offsetNext+2] |
| 85 | + + dataCopy[offsetNext+6]) * c |
| 86 | + + dataCopy[offset+2]) |
| 87 | + * weight; |
| 88 | + |
| 89 | + if (mono) { |
| 90 | + var brightness = (r*0.3 + g*0.59 + b*0.11)||0; |
| 91 | + if (invert) brightness = 255 - brightness; |
| 92 | + if (brightness < 0 ) brightness = 0; |
| 93 | + if (brightness > 255 ) brightness = 255; |
| 94 | + r = g = b = brightness; |
| 95 | + } else { |
| 96 | + if (invert) { |
| 97 | + r = 255 - r; |
| 98 | + g = 255 - g; |
| 99 | + b = 255 - b; |
| 100 | + } |
| 101 | + if (r < 0 ) r = 0; |
| 102 | + if (g < 0 ) g = 0; |
| 103 | + if (b < 0 ) b = 0; |
| 104 | + if (r > 255 ) r = 255; |
| 105 | + if (g > 255 ) g = 255; |
| 106 | + if (b > 255 ) b = 255; |
| 107 | + } |
| 108 | + |
| 109 | + data[offset] = r; |
| 110 | + data[offset+1] = g; |
| 111 | + data[offset+2] = b; |
| 112 | + |
| 113 | + } while (--x); |
| 114 | + } while (--y); |
| 115 | + |
| 116 | + return true; |
| 117 | + } |
| 118 | + }, |
| 119 | + checkSupport : function() { |
| 120 | + return Pixastic.Client.hasCanvasImageData(); |
| 121 | + } |
122 | 122 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/edges.js |
___________________________________________________________________ |
Added: svn:eol-style |
123 | 123 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/emboss.js |
— | — | @@ -1,134 +1,134 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Emboss filter - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.emboss = {
|
9 | | - process : function(params) {
|
10 | | -
|
11 | | - var strength = parseFloat(params.options.strength)||1;
|
12 | | - var greyLevel = typeof params.options.greyLevel != "undefined" ? parseInt(params.options.greyLevel) : 180;
|
13 | | - var direction = params.options.direction||"topleft";
|
14 | | - var blend = !!params.options.blend;
|
15 | | -
|
16 | | - var dirY = 0;
|
17 | | - var dirX = 0;
|
18 | | -
|
19 | | - switch (direction) {
|
20 | | - case "topleft": // top left
|
21 | | - dirY = -1;
|
22 | | - dirX = -1;
|
23 | | - break;
|
24 | | - case "top": // top
|
25 | | - dirY = -1;
|
26 | | - dirX = 0;
|
27 | | - break;
|
28 | | - case "topright": // top right
|
29 | | - dirY = -1;
|
30 | | - dirX = 1;
|
31 | | - break;
|
32 | | - case "right": // right
|
33 | | - dirY = 0;
|
34 | | - dirX = 1;
|
35 | | - break;
|
36 | | - case "bottomright": // bottom right
|
37 | | - dirY = 1;
|
38 | | - dirX = 1;
|
39 | | - break;
|
40 | | - case "bottom": // bottom
|
41 | | - dirY = 1;
|
42 | | - dirX = 0;
|
43 | | - break;
|
44 | | - case "bottomleft": // bottom left
|
45 | | - dirY = 1;
|
46 | | - dirX = -1;
|
47 | | - break;
|
48 | | - case "left": // left
|
49 | | - dirY = 0;
|
50 | | - dirX = -1;
|
51 | | - break;
|
52 | | - }
|
53 | | -
|
54 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
55 | | - var data = Pixastic.prepareData(params);
|
56 | | - var dataCopy = Pixastic.prepareData(params, true)
|
57 | | -
|
58 | | - var invertAlpha = !!params.options.invertAlpha;
|
59 | | - var rect = params.options.rect;
|
60 | | - var w = rect.width;
|
61 | | - var h = rect.height;
|
62 | | -
|
63 | | - var w4 = w*4;
|
64 | | - var y = h;
|
65 | | - do {
|
66 | | - var offsetY = (y-1)*w4;
|
67 | | -
|
68 | | - var otherY = dirY;
|
69 | | - if (y + otherY < 1) otherY = 0;
|
70 | | - if (y + otherY > h) otherY = 0;
|
71 | | -
|
72 | | - var offsetYOther = (y-1+otherY)*w*4;
|
73 | | -
|
74 | | - var x = w;
|
75 | | - do {
|
76 | | - var offset = offsetY + (x-1)*4;
|
77 | | -
|
78 | | - var otherX = dirX;
|
79 | | - if (x + otherX < 1) otherX = 0;
|
80 | | - if (x + otherX > w) otherX = 0;
|
81 | | -
|
82 | | - var offsetOther = offsetYOther + (x-1+otherX)*4;
|
83 | | -
|
84 | | - var dR = dataCopy[offset] - dataCopy[offsetOther];
|
85 | | - var dG = dataCopy[offset+1] - dataCopy[offsetOther+1];
|
86 | | - var dB = dataCopy[offset+2] - dataCopy[offsetOther+2];
|
87 | | -
|
88 | | - var dif = dR;
|
89 | | - var absDif = dif > 0 ? dif : -dif;
|
90 | | -
|
91 | | - var absG = dG > 0 ? dG : -dG;
|
92 | | - var absB = dB > 0 ? dB : -dB;
|
93 | | -
|
94 | | - if (absG > absDif) {
|
95 | | - dif = dG;
|
96 | | - }
|
97 | | - if (absB > absDif) {
|
98 | | - dif = dB;
|
99 | | - }
|
100 | | -
|
101 | | - dif *= strength;
|
102 | | -
|
103 | | - if (blend) {
|
104 | | - var r = data[offset] + dif;
|
105 | | - var g = data[offset+1] + dif;
|
106 | | - var b = data[offset+2] + dif;
|
107 | | -
|
108 | | - data[offset] = (r > 255) ? 255 : (r < 0 ? 0 : r);
|
109 | | - data[offset+1] = (g > 255) ? 255 : (g < 0 ? 0 : g);
|
110 | | - data[offset+2] = (b > 255) ? 255 : (b < 0 ? 0 : b);
|
111 | | - } else {
|
112 | | - var grey = greyLevel - dif;
|
113 | | - if (grey < 0) {
|
114 | | - grey = 0;
|
115 | | - } else if (grey > 255) {
|
116 | | - grey = 255;
|
117 | | - }
|
118 | | -
|
119 | | - data[offset] = data[offset+1] = data[offset+2] = grey;
|
120 | | - }
|
121 | | -
|
122 | | - } while (--x);
|
123 | | - } while (--y);
|
124 | | - return true;
|
125 | | -
|
126 | | - } else if (Pixastic.Client.isIE()) {
|
127 | | - params.image.style.filter += " progid:DXImageTransform.Microsoft.emboss()";
|
128 | | - return true;
|
129 | | - }
|
130 | | - },
|
131 | | - checkSupport : function() {
|
132 | | - return (Pixastic.Client.hasCanvasImageData() || Pixastic.Client.isIE());
|
133 | | - }
|
134 | | -
|
135 | | -}
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Emboss filter - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.emboss = { |
| 9 | + process : function(params) { |
| 10 | + |
| 11 | + var strength = parseFloat(params.options.strength)||1; |
| 12 | + var greyLevel = typeof params.options.greyLevel != "undefined" ? parseInt(params.options.greyLevel) : 180; |
| 13 | + var direction = params.options.direction||"topleft"; |
| 14 | + var blend = !!params.options.blend; |
| 15 | + |
| 16 | + var dirY = 0; |
| 17 | + var dirX = 0; |
| 18 | + |
| 19 | + switch (direction) { |
| 20 | + case "topleft": // top left |
| 21 | + dirY = -1; |
| 22 | + dirX = -1; |
| 23 | + break; |
| 24 | + case "top": // top |
| 25 | + dirY = -1; |
| 26 | + dirX = 0; |
| 27 | + break; |
| 28 | + case "topright": // top right |
| 29 | + dirY = -1; |
| 30 | + dirX = 1; |
| 31 | + break; |
| 32 | + case "right": // right |
| 33 | + dirY = 0; |
| 34 | + dirX = 1; |
| 35 | + break; |
| 36 | + case "bottomright": // bottom right |
| 37 | + dirY = 1; |
| 38 | + dirX = 1; |
| 39 | + break; |
| 40 | + case "bottom": // bottom |
| 41 | + dirY = 1; |
| 42 | + dirX = 0; |
| 43 | + break; |
| 44 | + case "bottomleft": // bottom left |
| 45 | + dirY = 1; |
| 46 | + dirX = -1; |
| 47 | + break; |
| 48 | + case "left": // left |
| 49 | + dirY = 0; |
| 50 | + dirX = -1; |
| 51 | + break; |
| 52 | + } |
| 53 | + |
| 54 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 55 | + var data = Pixastic.prepareData(params); |
| 56 | + var dataCopy = Pixastic.prepareData(params, true) |
| 57 | + |
| 58 | + var invertAlpha = !!params.options.invertAlpha; |
| 59 | + var rect = params.options.rect; |
| 60 | + var w = rect.width; |
| 61 | + var h = rect.height; |
| 62 | + |
| 63 | + var w4 = w*4; |
| 64 | + var y = h; |
| 65 | + do { |
| 66 | + var offsetY = (y-1)*w4; |
| 67 | + |
| 68 | + var otherY = dirY; |
| 69 | + if (y + otherY < 1) otherY = 0; |
| 70 | + if (y + otherY > h) otherY = 0; |
| 71 | + |
| 72 | + var offsetYOther = (y-1+otherY)*w*4; |
| 73 | + |
| 74 | + var x = w; |
| 75 | + do { |
| 76 | + var offset = offsetY + (x-1)*4; |
| 77 | + |
| 78 | + var otherX = dirX; |
| 79 | + if (x + otherX < 1) otherX = 0; |
| 80 | + if (x + otherX > w) otherX = 0; |
| 81 | + |
| 82 | + var offsetOther = offsetYOther + (x-1+otherX)*4; |
| 83 | + |
| 84 | + var dR = dataCopy[offset] - dataCopy[offsetOther]; |
| 85 | + var dG = dataCopy[offset+1] - dataCopy[offsetOther+1]; |
| 86 | + var dB = dataCopy[offset+2] - dataCopy[offsetOther+2]; |
| 87 | + |
| 88 | + var dif = dR; |
| 89 | + var absDif = dif > 0 ? dif : -dif; |
| 90 | + |
| 91 | + var absG = dG > 0 ? dG : -dG; |
| 92 | + var absB = dB > 0 ? dB : -dB; |
| 93 | + |
| 94 | + if (absG > absDif) { |
| 95 | + dif = dG; |
| 96 | + } |
| 97 | + if (absB > absDif) { |
| 98 | + dif = dB; |
| 99 | + } |
| 100 | + |
| 101 | + dif *= strength; |
| 102 | + |
| 103 | + if (blend) { |
| 104 | + var r = data[offset] + dif; |
| 105 | + var g = data[offset+1] + dif; |
| 106 | + var b = data[offset+2] + dif; |
| 107 | + |
| 108 | + data[offset] = (r > 255) ? 255 : (r < 0 ? 0 : r); |
| 109 | + data[offset+1] = (g > 255) ? 255 : (g < 0 ? 0 : g); |
| 110 | + data[offset+2] = (b > 255) ? 255 : (b < 0 ? 0 : b); |
| 111 | + } else { |
| 112 | + var grey = greyLevel - dif; |
| 113 | + if (grey < 0) { |
| 114 | + grey = 0; |
| 115 | + } else if (grey > 255) { |
| 116 | + grey = 255; |
| 117 | + } |
| 118 | + |
| 119 | + data[offset] = data[offset+1] = data[offset+2] = grey; |
| 120 | + } |
| 121 | + |
| 122 | + } while (--x); |
| 123 | + } while (--y); |
| 124 | + return true; |
| 125 | + |
| 126 | + } else if (Pixastic.Client.isIE()) { |
| 127 | + params.image.style.filter += " progid:DXImageTransform.Microsoft.emboss()"; |
| 128 | + return true; |
| 129 | + } |
| 130 | + }, |
| 131 | + checkSupport : function() { |
| 132 | + return (Pixastic.Client.hasCanvasImageData() || Pixastic.Client.isIE()); |
| 133 | + } |
| 134 | + |
| 135 | +} |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/emboss.js |
___________________________________________________________________ |
Added: svn:eol-style |
136 | 136 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/solarize.js |
— | — | @@ -1,45 +1,45 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Solarize filter - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.solarize = {
|
9 | | -
|
10 | | - process : function(params) {
|
11 | | - var useAverage = !!params.options.average;
|
12 | | -
|
13 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
14 | | - var data = Pixastic.prepareData(params);
|
15 | | - var rect = params.options.rect;
|
16 | | - var w = rect.width;
|
17 | | - var h = rect.height;
|
18 | | - var w4 = w*4;
|
19 | | - var y = h;
|
20 | | - do {
|
21 | | - var offsetY = (y-1)*w4;
|
22 | | - var x = w;
|
23 | | - do {
|
24 | | - var offset = offsetY + (x-1)*4;
|
25 | | -
|
26 | | - var r = data[offset];
|
27 | | - var g = data[offset+1];
|
28 | | - var b = data[offset+2];
|
29 | | -
|
30 | | - if (r > 127) r = 255 - r;
|
31 | | - if (g > 127) g = 255 - g;
|
32 | | - if (b > 127) b = 255 - b;
|
33 | | -
|
34 | | - data[offset] = r;
|
35 | | - data[offset+1] = g;
|
36 | | - data[offset+2] = b;
|
37 | | -
|
38 | | - } while (--x);
|
39 | | - } while (--y);
|
40 | | - return true;
|
41 | | - }
|
42 | | - },
|
43 | | - checkSupport : function() {
|
44 | | - return (Pixastic.Client.hasCanvasImageData());
|
45 | | - }
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Solarize filter - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.solarize = { |
| 9 | + |
| 10 | + process : function(params) { |
| 11 | + var useAverage = !!params.options.average; |
| 12 | + |
| 13 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 14 | + var data = Pixastic.prepareData(params); |
| 15 | + var rect = params.options.rect; |
| 16 | + var w = rect.width; |
| 17 | + var h = rect.height; |
| 18 | + var w4 = w*4; |
| 19 | + var y = h; |
| 20 | + do { |
| 21 | + var offsetY = (y-1)*w4; |
| 22 | + var x = w; |
| 23 | + do { |
| 24 | + var offset = offsetY + (x-1)*4; |
| 25 | + |
| 26 | + var r = data[offset]; |
| 27 | + var g = data[offset+1]; |
| 28 | + var b = data[offset+2]; |
| 29 | + |
| 30 | + if (r > 127) r = 255 - r; |
| 31 | + if (g > 127) g = 255 - g; |
| 32 | + if (b > 127) b = 255 - b; |
| 33 | + |
| 34 | + data[offset] = r; |
| 35 | + data[offset+1] = g; |
| 36 | + data[offset+2] = b; |
| 37 | + |
| 38 | + } while (--x); |
| 39 | + } while (--y); |
| 40 | + return true; |
| 41 | + } |
| 42 | + }, |
| 43 | + checkSupport : function() { |
| 44 | + return (Pixastic.Client.hasCanvasImageData()); |
| 45 | + } |
46 | 46 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/solarize.js |
___________________________________________________________________ |
Added: svn:eol-style |
47 | 47 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/coloradjust.js |
— | — | @@ -1,54 +1,54 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Color adjust filter - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.coloradjust = {
|
9 | | -
|
10 | | - process : function(params) {
|
11 | | - var red = parseFloat(params.options.red) || 0;
|
12 | | - var green = parseFloat(params.options.green) || 0;
|
13 | | - var blue = parseFloat(params.options.blue) || 0;
|
14 | | -
|
15 | | - red = Math.round(red*255);
|
16 | | - green = Math.round(green*255);
|
17 | | - blue = Math.round(blue*255);
|
18 | | -
|
19 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
20 | | - var data = Pixastic.prepareData(params);
|
21 | | - var rect = params.options.rect;
|
22 | | - var w = rect.width;
|
23 | | - var h = rect.height;
|
24 | | - var w4 = w*4;
|
25 | | - var y = h;
|
26 | | - do {
|
27 | | - var offsetY = (y-1)*w4;
|
28 | | - var x = w;
|
29 | | - do {
|
30 | | - var offset = offsetY + (x-1)*4;
|
31 | | -
|
32 | | - var r = data[offset] + red;
|
33 | | - var g = data[offset+1] + green;
|
34 | | - var b = data[offset+2] + blue;
|
35 | | -
|
36 | | - if (r < 0 ) r = 0;
|
37 | | - if (g < 0 ) g = 0;
|
38 | | - if (b < 0 ) b = 0;
|
39 | | - if (r > 255 ) r = 255;
|
40 | | - if (g > 255 ) g = 255;
|
41 | | - if (b > 255 ) b = 255;
|
42 | | -
|
43 | | - data[offset] = r;
|
44 | | - data[offset+1] = g;
|
45 | | - data[offset+2] = b;
|
46 | | -
|
47 | | - } while (--x);
|
48 | | - } while (--y);
|
49 | | - return true;
|
50 | | - }
|
51 | | - },
|
52 | | - checkSupport : function() {
|
53 | | - return (Pixastic.Client.hasCanvasImageData());
|
54 | | - }
|
55 | | -}
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Color adjust filter - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.coloradjust = { |
| 9 | + |
| 10 | + process : function(params) { |
| 11 | + var red = parseFloat(params.options.red) || 0; |
| 12 | + var green = parseFloat(params.options.green) || 0; |
| 13 | + var blue = parseFloat(params.options.blue) || 0; |
| 14 | + |
| 15 | + red = Math.round(red*255); |
| 16 | + green = Math.round(green*255); |
| 17 | + blue = Math.round(blue*255); |
| 18 | + |
| 19 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 20 | + var data = Pixastic.prepareData(params); |
| 21 | + var rect = params.options.rect; |
| 22 | + var w = rect.width; |
| 23 | + var h = rect.height; |
| 24 | + var w4 = w*4; |
| 25 | + var y = h; |
| 26 | + do { |
| 27 | + var offsetY = (y-1)*w4; |
| 28 | + var x = w; |
| 29 | + do { |
| 30 | + var offset = offsetY + (x-1)*4; |
| 31 | + |
| 32 | + var r = data[offset] + red; |
| 33 | + var g = data[offset+1] + green; |
| 34 | + var b = data[offset+2] + blue; |
| 35 | + |
| 36 | + if (r < 0 ) r = 0; |
| 37 | + if (g < 0 ) g = 0; |
| 38 | + if (b < 0 ) b = 0; |
| 39 | + if (r > 255 ) r = 255; |
| 40 | + if (g > 255 ) g = 255; |
| 41 | + if (b > 255 ) b = 255; |
| 42 | + |
| 43 | + data[offset] = r; |
| 44 | + data[offset+1] = g; |
| 45 | + data[offset+2] = b; |
| 46 | + |
| 47 | + } while (--x); |
| 48 | + } while (--y); |
| 49 | + return true; |
| 50 | + } |
| 51 | + }, |
| 52 | + checkSupport : function() { |
| 53 | + return (Pixastic.Client.hasCanvasImageData()); |
| 54 | + } |
| 55 | +} |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/coloradjust.js |
___________________________________________________________________ |
Added: svn:eol-style |
56 | 56 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/lighten.js |
— | — | @@ -1,73 +1,73 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Lighten filter - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.lighten = {
|
9 | | -
|
10 | | - process : function(params) {
|
11 | | - var amount = parseFloat(params.options.amount) || 0;
|
12 | | -
|
13 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
14 | | - var data = Pixastic.prepareData(params);
|
15 | | - var rect = params.options.rect;
|
16 | | - var w = rect.width;
|
17 | | - var h = rect.height;
|
18 | | - var w4 = w*4;
|
19 | | - var y = h;
|
20 | | - do {
|
21 | | - var offsetY = (y-1)*w4;
|
22 | | - var x = w;
|
23 | | - do {
|
24 | | - var offset = offsetY + (x-1)*4;
|
25 | | -
|
26 | | - var r = data[offset];
|
27 | | - var g = data[offset+1];
|
28 | | - var b = data[offset+2];
|
29 | | -
|
30 | | - r += r*amount;
|
31 | | - g += g*amount;
|
32 | | - b += b*amount;
|
33 | | -
|
34 | | - if (r < 0 ) r = 0;
|
35 | | - if (g < 0 ) g = 0;
|
36 | | - if (b < 0 ) b = 0;
|
37 | | - if (r > 255 ) r = 255;
|
38 | | - if (g > 255 ) g = 255;
|
39 | | - if (b > 255 ) b = 255;
|
40 | | -
|
41 | | - data[offset] = r;
|
42 | | - data[offset+1] = g;
|
43 | | - data[offset+2] = b;
|
44 | | -
|
45 | | - } while (--x);
|
46 | | - } while (--y);
|
47 | | - return true;
|
48 | | -
|
49 | | - } else if (Pixastic.Client.isIE()) {
|
50 | | - var img = params.image;
|
51 | | - if (amount < 0) {
|
52 | | - img.style.filter += " light()";
|
53 | | - img.filters[img.filters.length-1].addAmbient(
|
54 | | - 255,255,255,
|
55 | | - 100 * -amount
|
56 | | - );
|
57 | | - } else if (amount > 0) {
|
58 | | - img.style.filter += " light()";
|
59 | | - img.filters[img.filters.length-1].addAmbient(
|
60 | | - 255,255,255,
|
61 | | - 100
|
62 | | - );
|
63 | | - img.filters[img.filters.length-1].addAmbient(
|
64 | | - 255,255,255,
|
65 | | - 100 * amount
|
66 | | - );
|
67 | | - }
|
68 | | - return true;
|
69 | | - }
|
70 | | - },
|
71 | | - checkSupport : function() {
|
72 | | - return (Pixastic.Client.hasCanvasImageData() || Pixastic.Client.isIE());
|
73 | | - }
|
74 | | -}
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Lighten filter - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.lighten = { |
| 9 | + |
| 10 | + process : function(params) { |
| 11 | + var amount = parseFloat(params.options.amount) || 0; |
| 12 | + |
| 13 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 14 | + var data = Pixastic.prepareData(params); |
| 15 | + var rect = params.options.rect; |
| 16 | + var w = rect.width; |
| 17 | + var h = rect.height; |
| 18 | + var w4 = w*4; |
| 19 | + var y = h; |
| 20 | + do { |
| 21 | + var offsetY = (y-1)*w4; |
| 22 | + var x = w; |
| 23 | + do { |
| 24 | + var offset = offsetY + (x-1)*4; |
| 25 | + |
| 26 | + var r = data[offset]; |
| 27 | + var g = data[offset+1]; |
| 28 | + var b = data[offset+2]; |
| 29 | + |
| 30 | + r += r*amount; |
| 31 | + g += g*amount; |
| 32 | + b += b*amount; |
| 33 | + |
| 34 | + if (r < 0 ) r = 0; |
| 35 | + if (g < 0 ) g = 0; |
| 36 | + if (b < 0 ) b = 0; |
| 37 | + if (r > 255 ) r = 255; |
| 38 | + if (g > 255 ) g = 255; |
| 39 | + if (b > 255 ) b = 255; |
| 40 | + |
| 41 | + data[offset] = r; |
| 42 | + data[offset+1] = g; |
| 43 | + data[offset+2] = b; |
| 44 | + |
| 45 | + } while (--x); |
| 46 | + } while (--y); |
| 47 | + return true; |
| 48 | + |
| 49 | + } else if (Pixastic.Client.isIE()) { |
| 50 | + var img = params.image; |
| 51 | + if (amount < 0) { |
| 52 | + img.style.filter += " light()"; |
| 53 | + img.filters[img.filters.length-1].addAmbient( |
| 54 | + 255,255,255, |
| 55 | + 100 * -amount |
| 56 | + ); |
| 57 | + } else if (amount > 0) { |
| 58 | + img.style.filter += " light()"; |
| 59 | + img.filters[img.filters.length-1].addAmbient( |
| 60 | + 255,255,255, |
| 61 | + 100 |
| 62 | + ); |
| 63 | + img.filters[img.filters.length-1].addAmbient( |
| 64 | + 255,255,255, |
| 65 | + 100 * amount |
| 66 | + ); |
| 67 | + } |
| 68 | + return true; |
| 69 | + } |
| 70 | + }, |
| 71 | + checkSupport : function() { |
| 72 | + return (Pixastic.Client.hasCanvasImageData() || Pixastic.Client.isIE()); |
| 73 | + } |
| 74 | +} |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/lighten.js |
___________________________________________________________________ |
Added: svn:eol-style |
75 | 75 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/removenoise.js |
— | — | @@ -1,89 +1,89 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Remove noise - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.removenoise = {
|
9 | | - process : function(params) {
|
10 | | -
|
11 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
12 | | - var data = Pixastic.prepareData(params);
|
13 | | -
|
14 | | - var rect = params.options.rect;
|
15 | | - var w = rect.width;
|
16 | | - var h = rect.height;
|
17 | | -
|
18 | | - var w4 = w*4;
|
19 | | - var y = h;
|
20 | | - do {
|
21 | | - var offsetY = (y-1)*w4;
|
22 | | -
|
23 | | - var nextY = (y == h) ? y - 1 : y;
|
24 | | - var prevY = (y == 1) ? 0 : y-2;
|
25 | | -
|
26 | | - var offsetYPrev = prevY*w*4;
|
27 | | - var offsetYNext = nextY*w*4;
|
28 | | -
|
29 | | - var x = w;
|
30 | | - do {
|
31 | | - var offset = offsetY + (x*4-4);
|
32 | | -
|
33 | | - var offsetPrev = offsetYPrev + ((x == 1) ? 0 : x-2) * 4;
|
34 | | - var offsetNext = offsetYNext + ((x == w) ? x-1 : x) * 4;
|
35 | | -
|
36 | | - var minR, maxR, minG, maxG, minB, maxB;
|
37 | | -
|
38 | | - minR = maxR = data[offsetPrev];
|
39 | | - var r1 = data[offset-4], r2 = data[offset+4], r3 = data[offsetNext];
|
40 | | - if (r1 < minR) minR = r1;
|
41 | | - if (r2 < minR) minR = r2;
|
42 | | - if (r3 < minR) minR = r3;
|
43 | | - if (r1 > maxR) maxR = r1;
|
44 | | - if (r2 > maxR) maxR = r2;
|
45 | | - if (r3 > maxR) maxR = r3;
|
46 | | -
|
47 | | - minG = maxG = data[offsetPrev+1];
|
48 | | - var g1 = data[offset-3], g2 = data[offset+5], g3 = data[offsetNext+1];
|
49 | | - if (g1 < minG) minG = g1;
|
50 | | - if (g2 < minG) minG = g2;
|
51 | | - if (g3 < minG) minG = g3;
|
52 | | - if (g1 > maxG) maxG = g1;
|
53 | | - if (g2 > maxG) maxG = g2;
|
54 | | - if (g3 > maxG) maxG = g3;
|
55 | | -
|
56 | | - minB = maxB = data[offsetPrev+2];
|
57 | | - var b1 = data[offset-2], b2 = data[offset+6], b3 = data[offsetNext+2];
|
58 | | - if (b1 < minB) minB = b1;
|
59 | | - if (b2 < minB) minB = b2;
|
60 | | - if (b3 < minB) minB = b3;
|
61 | | - if (b1 > maxB) maxB = b1;
|
62 | | - if (b2 > maxB) maxB = b2;
|
63 | | - if (b3 > maxB) maxB = b3;
|
64 | | -
|
65 | | - if (data[offset] > maxR) {
|
66 | | - data[offset] = maxR;
|
67 | | - } else if (data[offset] < minR) {
|
68 | | - data[offset] = minR;
|
69 | | - }
|
70 | | - if (data[offset+1] > maxG) {
|
71 | | - data[offset+1] = maxG;
|
72 | | - } else if (data[offset+1] < minG) {
|
73 | | - data[offset+1] = minG;
|
74 | | - }
|
75 | | - if (data[offset+2] > maxB) {
|
76 | | - data[offset+2] = maxB;
|
77 | | - } else if (data[offset+2] < minB) {
|
78 | | - data[offset+2] = minB;
|
79 | | - }
|
80 | | -
|
81 | | - } while (--x);
|
82 | | - } while (--y);
|
83 | | -
|
84 | | - return true;
|
85 | | - }
|
86 | | - },
|
87 | | - checkSupport : function() {
|
88 | | - return Pixastic.Client.hasCanvasImageData();
|
89 | | - }
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Remove noise - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.removenoise = { |
| 9 | + process : function(params) { |
| 10 | + |
| 11 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 12 | + var data = Pixastic.prepareData(params); |
| 13 | + |
| 14 | + var rect = params.options.rect; |
| 15 | + var w = rect.width; |
| 16 | + var h = rect.height; |
| 17 | + |
| 18 | + var w4 = w*4; |
| 19 | + var y = h; |
| 20 | + do { |
| 21 | + var offsetY = (y-1)*w4; |
| 22 | + |
| 23 | + var nextY = (y == h) ? y - 1 : y; |
| 24 | + var prevY = (y == 1) ? 0 : y-2; |
| 25 | + |
| 26 | + var offsetYPrev = prevY*w*4; |
| 27 | + var offsetYNext = nextY*w*4; |
| 28 | + |
| 29 | + var x = w; |
| 30 | + do { |
| 31 | + var offset = offsetY + (x*4-4); |
| 32 | + |
| 33 | + var offsetPrev = offsetYPrev + ((x == 1) ? 0 : x-2) * 4; |
| 34 | + var offsetNext = offsetYNext + ((x == w) ? x-1 : x) * 4; |
| 35 | + |
| 36 | + var minR, maxR, minG, maxG, minB, maxB; |
| 37 | + |
| 38 | + minR = maxR = data[offsetPrev]; |
| 39 | + var r1 = data[offset-4], r2 = data[offset+4], r3 = data[offsetNext]; |
| 40 | + if (r1 < minR) minR = r1; |
| 41 | + if (r2 < minR) minR = r2; |
| 42 | + if (r3 < minR) minR = r3; |
| 43 | + if (r1 > maxR) maxR = r1; |
| 44 | + if (r2 > maxR) maxR = r2; |
| 45 | + if (r3 > maxR) maxR = r3; |
| 46 | + |
| 47 | + minG = maxG = data[offsetPrev+1]; |
| 48 | + var g1 = data[offset-3], g2 = data[offset+5], g3 = data[offsetNext+1]; |
| 49 | + if (g1 < minG) minG = g1; |
| 50 | + if (g2 < minG) minG = g2; |
| 51 | + if (g3 < minG) minG = g3; |
| 52 | + if (g1 > maxG) maxG = g1; |
| 53 | + if (g2 > maxG) maxG = g2; |
| 54 | + if (g3 > maxG) maxG = g3; |
| 55 | + |
| 56 | + minB = maxB = data[offsetPrev+2]; |
| 57 | + var b1 = data[offset-2], b2 = data[offset+6], b3 = data[offsetNext+2]; |
| 58 | + if (b1 < minB) minB = b1; |
| 59 | + if (b2 < minB) minB = b2; |
| 60 | + if (b3 < minB) minB = b3; |
| 61 | + if (b1 > maxB) maxB = b1; |
| 62 | + if (b2 > maxB) maxB = b2; |
| 63 | + if (b3 > maxB) maxB = b3; |
| 64 | + |
| 65 | + if (data[offset] > maxR) { |
| 66 | + data[offset] = maxR; |
| 67 | + } else if (data[offset] < minR) { |
| 68 | + data[offset] = minR; |
| 69 | + } |
| 70 | + if (data[offset+1] > maxG) { |
| 71 | + data[offset+1] = maxG; |
| 72 | + } else if (data[offset+1] < minG) { |
| 73 | + data[offset+1] = minG; |
| 74 | + } |
| 75 | + if (data[offset+2] > maxB) { |
| 76 | + data[offset+2] = maxB; |
| 77 | + } else if (data[offset+2] < minB) { |
| 78 | + data[offset+2] = minB; |
| 79 | + } |
| 80 | + |
| 81 | + } while (--x); |
| 82 | + } while (--y); |
| 83 | + |
| 84 | + return true; |
| 85 | + } |
| 86 | + }, |
| 87 | + checkSupport : function() { |
| 88 | + return Pixastic.Client.hasCanvasImageData(); |
| 89 | + } |
90 | 90 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/removenoise.js |
___________________________________________________________________ |
Added: svn:eol-style |
91 | 91 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/unsharpmask.js |
— | — | @@ -1,111 +1,111 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - USM - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -
|
9 | | -Pixastic.Actions.unsharpmask = {
|
10 | | - process : function(params) {
|
11 | | -
|
12 | | - var amount = (parseFloat(params.options.amount)||0);
|
13 | | - var blurAmount = parseFloat(params.options.radius)||0;
|
14 | | - var threshold = parseFloat(params.options.threshold)||0;
|
15 | | -
|
16 | | - amount = Math.min(500,Math.max(0,amount)) / 2;
|
17 | | - blurAmount = Math.min(5,Math.max(0,blurAmount)) / 10;
|
18 | | - threshold = Math.min(255,Math.max(0,threshold));
|
19 | | -
|
20 | | - threshold--;
|
21 | | - var thresholdNeg = -threshold;
|
22 | | -
|
23 | | - amount *= 0.016;
|
24 | | - amount++;
|
25 | | -
|
26 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
27 | | - var rect = params.options.rect;
|
28 | | -
|
29 | | - var blurCanvas = document.createElement("canvas");
|
30 | | - blurCanvas.width = params.width;
|
31 | | - blurCanvas.height = params.height;
|
32 | | - var blurCtx = blurCanvas.getContext("2d");
|
33 | | - blurCtx.drawImage(params.canvas,0,0);
|
34 | | -
|
35 | | - var scale = 2;
|
36 | | - var smallWidth = Math.round(params.width / scale);
|
37 | | - var smallHeight = Math.round(params.height / scale);
|
38 | | -
|
39 | | - var copy = document.createElement("canvas");
|
40 | | - copy.width = smallWidth;
|
41 | | - copy.height = smallHeight;
|
42 | | -
|
43 | | - var steps = Math.round(blurAmount * 20);
|
44 | | -
|
45 | | - var copyCtx = copy.getContext("2d");
|
46 | | - for (var i=0;i<steps;i++) {
|
47 | | - var scaledWidth = Math.max(1,Math.round(smallWidth - i));
|
48 | | - var scaledHeight = Math.max(1,Math.round(smallHeight - i));
|
49 | | -
|
50 | | - copyCtx.clearRect(0,0,smallWidth,smallHeight);
|
51 | | -
|
52 | | - copyCtx.drawImage(
|
53 | | - blurCanvas,
|
54 | | - 0,0,params.width,params.height,
|
55 | | - 0,0,scaledWidth,scaledHeight
|
56 | | - );
|
57 | | -
|
58 | | - blurCtx.clearRect(0,0,params.width,params.height);
|
59 | | -
|
60 | | - blurCtx.drawImage(
|
61 | | - copy,
|
62 | | - 0,0,scaledWidth,scaledHeight,
|
63 | | - 0,0,params.width,params.height
|
64 | | - );
|
65 | | - }
|
66 | | -
|
67 | | - var data = Pixastic.prepareData(params);
|
68 | | - var blurData = Pixastic.prepareData({canvas:blurCanvas,options:params.options});
|
69 | | - var w = rect.width;
|
70 | | - var h = rect.height;
|
71 | | - var w4 = w*4;
|
72 | | - var y = h;
|
73 | | - do {
|
74 | | - var offsetY = (y-1)*w4;
|
75 | | - var x = w;
|
76 | | - do {
|
77 | | - var offset = offsetY + (x*4-4);
|
78 | | -
|
79 | | - var difR = data[offset] - blurData[offset];
|
80 | | - if (difR > threshold || difR < thresholdNeg) {
|
81 | | - var blurR = blurData[offset];
|
82 | | - blurR = amount * difR + blurR;
|
83 | | - data[offset] = blurR > 255 ? 255 : (blurR < 0 ? 0 : blurR);
|
84 | | - }
|
85 | | -
|
86 | | - var difG = data[offset+1] - blurData[offset+1];
|
87 | | - if (difG > threshold || difG < thresholdNeg) {
|
88 | | - var blurG = blurData[offset+1];
|
89 | | - blurG = amount * difG + blurG;
|
90 | | - data[offset+1] = blurG > 255 ? 255 : (blurG < 0 ? 0 : blurG);
|
91 | | - }
|
92 | | -
|
93 | | - var difB = data[offset+2] - blurData[offset+2];
|
94 | | - if (difB > threshold || difB < thresholdNeg) {
|
95 | | - var blurB = blurData[offset+2];
|
96 | | - blurB = amount * difB + blurB;
|
97 | | - data[offset+2] = blurB > 255 ? 255 : (blurB < 0 ? 0 : blurB);
|
98 | | - }
|
99 | | -
|
100 | | - } while (--x);
|
101 | | - } while (--y);
|
102 | | -
|
103 | | - return true;
|
104 | | - }
|
105 | | - },
|
106 | | - checkSupport : function() {
|
107 | | - return Pixastic.Client.hasCanvasImageData();
|
108 | | - }
|
109 | | -}
|
110 | | -
|
111 | | -
|
112 | | -
|
| 2 | +/* |
| 3 | + * Pixastic Lib - USM - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | + |
| 9 | +Pixastic.Actions.unsharpmask = { |
| 10 | + process : function(params) { |
| 11 | + |
| 12 | + var amount = (parseFloat(params.options.amount)||0); |
| 13 | + var blurAmount = parseFloat(params.options.radius)||0; |
| 14 | + var threshold = parseFloat(params.options.threshold)||0; |
| 15 | + |
| 16 | + amount = Math.min(500,Math.max(0,amount)) / 2; |
| 17 | + blurAmount = Math.min(5,Math.max(0,blurAmount)) / 10; |
| 18 | + threshold = Math.min(255,Math.max(0,threshold)); |
| 19 | + |
| 20 | + threshold--; |
| 21 | + var thresholdNeg = -threshold; |
| 22 | + |
| 23 | + amount *= 0.016; |
| 24 | + amount++; |
| 25 | + |
| 26 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 27 | + var rect = params.options.rect; |
| 28 | + |
| 29 | + var blurCanvas = document.createElement("canvas"); |
| 30 | + blurCanvas.width = params.width; |
| 31 | + blurCanvas.height = params.height; |
| 32 | + var blurCtx = blurCanvas.getContext("2d"); |
| 33 | + blurCtx.drawImage(params.canvas,0,0); |
| 34 | + |
| 35 | + var scale = 2; |
| 36 | + var smallWidth = Math.round(params.width / scale); |
| 37 | + var smallHeight = Math.round(params.height / scale); |
| 38 | + |
| 39 | + var copy = document.createElement("canvas"); |
| 40 | + copy.width = smallWidth; |
| 41 | + copy.height = smallHeight; |
| 42 | + |
| 43 | + var steps = Math.round(blurAmount * 20); |
| 44 | + |
| 45 | + var copyCtx = copy.getContext("2d"); |
| 46 | + for (var i=0;i<steps;i++) { |
| 47 | + var scaledWidth = Math.max(1,Math.round(smallWidth - i)); |
| 48 | + var scaledHeight = Math.max(1,Math.round(smallHeight - i)); |
| 49 | + |
| 50 | + copyCtx.clearRect(0,0,smallWidth,smallHeight); |
| 51 | + |
| 52 | + copyCtx.drawImage( |
| 53 | + blurCanvas, |
| 54 | + 0,0,params.width,params.height, |
| 55 | + 0,0,scaledWidth,scaledHeight |
| 56 | + ); |
| 57 | + |
| 58 | + blurCtx.clearRect(0,0,params.width,params.height); |
| 59 | + |
| 60 | + blurCtx.drawImage( |
| 61 | + copy, |
| 62 | + 0,0,scaledWidth,scaledHeight, |
| 63 | + 0,0,params.width,params.height |
| 64 | + ); |
| 65 | + } |
| 66 | + |
| 67 | + var data = Pixastic.prepareData(params); |
| 68 | + var blurData = Pixastic.prepareData({canvas:blurCanvas,options:params.options}); |
| 69 | + var w = rect.width; |
| 70 | + var h = rect.height; |
| 71 | + var w4 = w*4; |
| 72 | + var y = h; |
| 73 | + do { |
| 74 | + var offsetY = (y-1)*w4; |
| 75 | + var x = w; |
| 76 | + do { |
| 77 | + var offset = offsetY + (x*4-4); |
| 78 | + |
| 79 | + var difR = data[offset] - blurData[offset]; |
| 80 | + if (difR > threshold || difR < thresholdNeg) { |
| 81 | + var blurR = blurData[offset]; |
| 82 | + blurR = amount * difR + blurR; |
| 83 | + data[offset] = blurR > 255 ? 255 : (blurR < 0 ? 0 : blurR); |
| 84 | + } |
| 85 | + |
| 86 | + var difG = data[offset+1] - blurData[offset+1]; |
| 87 | + if (difG > threshold || difG < thresholdNeg) { |
| 88 | + var blurG = blurData[offset+1]; |
| 89 | + blurG = amount * difG + blurG; |
| 90 | + data[offset+1] = blurG > 255 ? 255 : (blurG < 0 ? 0 : blurG); |
| 91 | + } |
| 92 | + |
| 93 | + var difB = data[offset+2] - blurData[offset+2]; |
| 94 | + if (difB > threshold || difB < thresholdNeg) { |
| 95 | + var blurB = blurData[offset+2]; |
| 96 | + blurB = amount * difB + blurB; |
| 97 | + data[offset+2] = blurB > 255 ? 255 : (blurB < 0 ? 0 : blurB); |
| 98 | + } |
| 99 | + |
| 100 | + } while (--x); |
| 101 | + } while (--y); |
| 102 | + |
| 103 | + return true; |
| 104 | + } |
| 105 | + }, |
| 106 | + checkSupport : function() { |
| 107 | + return Pixastic.Client.hasCanvasImageData(); |
| 108 | + } |
| 109 | +} |
| 110 | + |
| 111 | + |
| 112 | + |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/unsharpmask.js |
___________________________________________________________________ |
Added: svn:eol-style |
113 | 113 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/histogram.js |
— | — | @@ -1,76 +1,76 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Histogram - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.histogram = {
|
9 | | - process : function(params) {
|
10 | | -
|
11 | | - var average = !!(params.options.average);
|
12 | | - var paint = !!(params.options.paint);
|
13 | | - var color = params.options.color || "rgba(255,255,255,0.5)";
|
14 | | - var values = [];
|
15 | | - if (typeof params.options.returnValue != "object") {
|
16 | | - params.options.returnValue = {values:[]};
|
17 | | - }
|
18 | | - var returnValue = params.options.returnValue;
|
19 | | - if (typeof returnValue.values != "array") {
|
20 | | - returnValue.values = [];
|
21 | | - }
|
22 | | - values = returnValue.values;
|
23 | | -
|
24 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
25 | | - var data = Pixastic.prepareData(params);
|
26 | | - params.useData = false;
|
27 | | -
|
28 | | - for (var i=0;i<256;i++) {
|
29 | | - values[i] = 0;
|
30 | | - }
|
31 | | -
|
32 | | - var rect = params.options.rect;
|
33 | | - var w = rect.width;
|
34 | | - var h = rect.height;
|
35 | | - var w4 = w*4;
|
36 | | - var y = h;
|
37 | | - do {
|
38 | | - var offsetY = (y-1)*w4;
|
39 | | - var x = w;
|
40 | | - do {
|
41 | | - var offset = offsetY + (x*4-4);
|
42 | | - var brightness = average ?
|
43 | | - Math.round((data[offset]+data[offset+1]+data[offset+2])/3)
|
44 | | - : Math.round(data[offset]*0.3 + data[offset+1]*0.59 + data[offset+2]*0.11);
|
45 | | - values[brightness]++;
|
46 | | -
|
47 | | - } while (--x);
|
48 | | - } while (--y);
|
49 | | -
|
50 | | - if (paint) {
|
51 | | - var maxValue = 0;
|
52 | | - for (var i=0;i<256;i++) {
|
53 | | - if (values[i] > maxValue) {
|
54 | | - maxValue = values[i];
|
55 | | - }
|
56 | | - }
|
57 | | - var heightScale = params.height / maxValue;
|
58 | | - var widthScale = params.width / 256;
|
59 | | - var ctx = params.canvas.getContext("2d");
|
60 | | - ctx.fillStyle = color;
|
61 | | - for (var i=0;i<256;i++) {
|
62 | | - ctx.fillRect(
|
63 | | - i * widthScale, params.height - heightScale * values[i],
|
64 | | - widthScale, values[i] * heightScale
|
65 | | - );
|
66 | | - }
|
67 | | - }
|
68 | | -
|
69 | | - returnValue.values = values;
|
70 | | -
|
71 | | - return true;
|
72 | | - }
|
73 | | - },
|
74 | | - checkSupport : function() {
|
75 | | - return Pixastic.Client.hasCanvasImageData();
|
76 | | - }
|
77 | | -}
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Histogram - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.histogram = { |
| 9 | + process : function(params) { |
| 10 | + |
| 11 | + var average = !!(params.options.average); |
| 12 | + var paint = !!(params.options.paint); |
| 13 | + var color = params.options.color || "rgba(255,255,255,0.5)"; |
| 14 | + var values = []; |
| 15 | + if (typeof params.options.returnValue != "object") { |
| 16 | + params.options.returnValue = {values:[]}; |
| 17 | + } |
| 18 | + var returnValue = params.options.returnValue; |
| 19 | + if (typeof returnValue.values != "array") { |
| 20 | + returnValue.values = []; |
| 21 | + } |
| 22 | + values = returnValue.values; |
| 23 | + |
| 24 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 25 | + var data = Pixastic.prepareData(params); |
| 26 | + params.useData = false; |
| 27 | + |
| 28 | + for (var i=0;i<256;i++) { |
| 29 | + values[i] = 0; |
| 30 | + } |
| 31 | + |
| 32 | + var rect = params.options.rect; |
| 33 | + var w = rect.width; |
| 34 | + var h = rect.height; |
| 35 | + var w4 = w*4; |
| 36 | + var y = h; |
| 37 | + do { |
| 38 | + var offsetY = (y-1)*w4; |
| 39 | + var x = w; |
| 40 | + do { |
| 41 | + var offset = offsetY + (x*4-4); |
| 42 | + var brightness = average ? |
| 43 | + Math.round((data[offset]+data[offset+1]+data[offset+2])/3) |
| 44 | + : Math.round(data[offset]*0.3 + data[offset+1]*0.59 + data[offset+2]*0.11); |
| 45 | + values[brightness]++; |
| 46 | + |
| 47 | + } while (--x); |
| 48 | + } while (--y); |
| 49 | + |
| 50 | + if (paint) { |
| 51 | + var maxValue = 0; |
| 52 | + for (var i=0;i<256;i++) { |
| 53 | + if (values[i] > maxValue) { |
| 54 | + maxValue = values[i]; |
| 55 | + } |
| 56 | + } |
| 57 | + var heightScale = params.height / maxValue; |
| 58 | + var widthScale = params.width / 256; |
| 59 | + var ctx = params.canvas.getContext("2d"); |
| 60 | + ctx.fillStyle = color; |
| 61 | + for (var i=0;i<256;i++) { |
| 62 | + ctx.fillRect( |
| 63 | + i * widthScale, params.height - heightScale * values[i], |
| 64 | + widthScale, values[i] * heightScale |
| 65 | + ); |
| 66 | + } |
| 67 | + } |
| 68 | + |
| 69 | + returnValue.values = values; |
| 70 | + |
| 71 | + return true; |
| 72 | + } |
| 73 | + }, |
| 74 | + checkSupport : function() { |
| 75 | + return Pixastic.Client.hasCanvasImageData(); |
| 76 | + } |
| 77 | +} |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/histogram.js |
___________________________________________________________________ |
Added: svn:eol-style |
78 | 78 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/sharpen.js |
— | — | @@ -1,110 +1,110 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Sharpen filter - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.sharpen = {
|
9 | | - process : function(params) {
|
10 | | -
|
11 | | - var strength = 0;
|
12 | | - if (typeof params.options.amount != "undefined")
|
13 | | - strength = parseFloat(params.options.amount)||0;
|
14 | | -
|
15 | | - if (strength < 0) strength = 0;
|
16 | | - if (strength > 1) strength = 1;
|
17 | | -
|
18 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
19 | | - var data = Pixastic.prepareData(params);
|
20 | | - var dataCopy = Pixastic.prepareData(params, true)
|
21 | | -
|
22 | | - var mul = 15;
|
23 | | - var mulOther = 1 + 3*strength;
|
24 | | -
|
25 | | - var kernel = [
|
26 | | - [0, -mulOther, 0],
|
27 | | - [-mulOther, mul, -mulOther],
|
28 | | - [0, -mulOther, 0]
|
29 | | - ];
|
30 | | -
|
31 | | - var weight = 0;
|
32 | | - for (var i=0;i<3;i++) {
|
33 | | - for (var j=0;j<3;j++) {
|
34 | | - weight += kernel[i][j];
|
35 | | - }
|
36 | | - }
|
37 | | -
|
38 | | - weight = 1 / weight;
|
39 | | -
|
40 | | - var rect = params.options.rect;
|
41 | | - var w = rect.width;
|
42 | | - var h = rect.height;
|
43 | | -
|
44 | | - mul *= weight;
|
45 | | - mulOther *= weight;
|
46 | | -
|
47 | | - var w4 = w*4;
|
48 | | - var y = h;
|
49 | | - do {
|
50 | | - var offsetY = (y-1)*w4;
|
51 | | -
|
52 | | - var nextY = (y == h) ? y - 1 : y;
|
53 | | - var prevY = (y == 1) ? 0 : y-2;
|
54 | | -
|
55 | | - var offsetYPrev = prevY*w4;
|
56 | | - var offsetYNext = nextY*w4;
|
57 | | -
|
58 | | - var x = w;
|
59 | | - do {
|
60 | | - var offset = offsetY + (x*4-4);
|
61 | | -
|
62 | | - var offsetPrev = offsetYPrev + ((x == 1) ? 0 : x-2) * 4;
|
63 | | - var offsetNext = offsetYNext + ((x == w) ? x-1 : x) * 4;
|
64 | | -
|
65 | | - var r = ((
|
66 | | - - dataCopy[offsetPrev]
|
67 | | - - dataCopy[offset-4]
|
68 | | - - dataCopy[offset+4]
|
69 | | - - dataCopy[offsetNext]) * mulOther
|
70 | | - + dataCopy[offset] * mul
|
71 | | - );
|
72 | | -
|
73 | | - var g = ((
|
74 | | - - dataCopy[offsetPrev+1]
|
75 | | - - dataCopy[offset-3]
|
76 | | - - dataCopy[offset+5]
|
77 | | - - dataCopy[offsetNext+1]) * mulOther
|
78 | | - + dataCopy[offset+1] * mul
|
79 | | - );
|
80 | | -
|
81 | | - var b = ((
|
82 | | - - dataCopy[offsetPrev+2]
|
83 | | - - dataCopy[offset-2]
|
84 | | - - dataCopy[offset+6]
|
85 | | - - dataCopy[offsetNext+2]) * mulOther
|
86 | | - + dataCopy[offset+2] * mul
|
87 | | - );
|
88 | | -
|
89 | | -
|
90 | | - if (r < 0 ) r = 0;
|
91 | | - if (g < 0 ) g = 0;
|
92 | | - if (b < 0 ) b = 0;
|
93 | | - if (r > 255 ) r = 255;
|
94 | | - if (g > 255 ) g = 255;
|
95 | | - if (b > 255 ) b = 255;
|
96 | | -
|
97 | | - data[offset] = r;
|
98 | | - data[offset+1] = g;
|
99 | | - data[offset+2] = b;
|
100 | | -
|
101 | | - } while (--x);
|
102 | | - } while (--y);
|
103 | | -
|
104 | | - return true;
|
105 | | -
|
106 | | - }
|
107 | | - },
|
108 | | - checkSupport : function() {
|
109 | | - return Pixastic.Client.hasCanvasImageData();
|
110 | | - }
|
111 | | -}
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Sharpen filter - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.sharpen = { |
| 9 | + process : function(params) { |
| 10 | + |
| 11 | + var strength = 0; |
| 12 | + if (typeof params.options.amount != "undefined") |
| 13 | + strength = parseFloat(params.options.amount)||0; |
| 14 | + |
| 15 | + if (strength < 0) strength = 0; |
| 16 | + if (strength > 1) strength = 1; |
| 17 | + |
| 18 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 19 | + var data = Pixastic.prepareData(params); |
| 20 | + var dataCopy = Pixastic.prepareData(params, true) |
| 21 | + |
| 22 | + var mul = 15; |
| 23 | + var mulOther = 1 + 3*strength; |
| 24 | + |
| 25 | + var kernel = [ |
| 26 | + [0, -mulOther, 0], |
| 27 | + [-mulOther, mul, -mulOther], |
| 28 | + [0, -mulOther, 0] |
| 29 | + ]; |
| 30 | + |
| 31 | + var weight = 0; |
| 32 | + for (var i=0;i<3;i++) { |
| 33 | + for (var j=0;j<3;j++) { |
| 34 | + weight += kernel[i][j]; |
| 35 | + } |
| 36 | + } |
| 37 | + |
| 38 | + weight = 1 / weight; |
| 39 | + |
| 40 | + var rect = params.options.rect; |
| 41 | + var w = rect.width; |
| 42 | + var h = rect.height; |
| 43 | + |
| 44 | + mul *= weight; |
| 45 | + mulOther *= weight; |
| 46 | + |
| 47 | + var w4 = w*4; |
| 48 | + var y = h; |
| 49 | + do { |
| 50 | + var offsetY = (y-1)*w4; |
| 51 | + |
| 52 | + var nextY = (y == h) ? y - 1 : y; |
| 53 | + var prevY = (y == 1) ? 0 : y-2; |
| 54 | + |
| 55 | + var offsetYPrev = prevY*w4; |
| 56 | + var offsetYNext = nextY*w4; |
| 57 | + |
| 58 | + var x = w; |
| 59 | + do { |
| 60 | + var offset = offsetY + (x*4-4); |
| 61 | + |
| 62 | + var offsetPrev = offsetYPrev + ((x == 1) ? 0 : x-2) * 4; |
| 63 | + var offsetNext = offsetYNext + ((x == w) ? x-1 : x) * 4; |
| 64 | + |
| 65 | + var r = (( |
| 66 | + - dataCopy[offsetPrev] |
| 67 | + - dataCopy[offset-4] |
| 68 | + - dataCopy[offset+4] |
| 69 | + - dataCopy[offsetNext]) * mulOther |
| 70 | + + dataCopy[offset] * mul |
| 71 | + ); |
| 72 | + |
| 73 | + var g = (( |
| 74 | + - dataCopy[offsetPrev+1] |
| 75 | + - dataCopy[offset-3] |
| 76 | + - dataCopy[offset+5] |
| 77 | + - dataCopy[offsetNext+1]) * mulOther |
| 78 | + + dataCopy[offset+1] * mul |
| 79 | + ); |
| 80 | + |
| 81 | + var b = (( |
| 82 | + - dataCopy[offsetPrev+2] |
| 83 | + - dataCopy[offset-2] |
| 84 | + - dataCopy[offset+6] |
| 85 | + - dataCopy[offsetNext+2]) * mulOther |
| 86 | + + dataCopy[offset+2] * mul |
| 87 | + ); |
| 88 | + |
| 89 | + |
| 90 | + if (r < 0 ) r = 0; |
| 91 | + if (g < 0 ) g = 0; |
| 92 | + if (b < 0 ) b = 0; |
| 93 | + if (r > 255 ) r = 255; |
| 94 | + if (g > 255 ) g = 255; |
| 95 | + if (b > 255 ) b = 255; |
| 96 | + |
| 97 | + data[offset] = r; |
| 98 | + data[offset+1] = g; |
| 99 | + data[offset+2] = b; |
| 100 | + |
| 101 | + } while (--x); |
| 102 | + } while (--y); |
| 103 | + |
| 104 | + return true; |
| 105 | + |
| 106 | + } |
| 107 | + }, |
| 108 | + checkSupport : function() { |
| 109 | + return Pixastic.Client.hasCanvasImageData(); |
| 110 | + } |
| 111 | +} |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/sharpen.js |
___________________________________________________________________ |
Added: svn:eol-style |
112 | 112 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/sepia.js |
— | — | @@ -1,60 +1,60 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Sepia filter - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.sepia = {
|
9 | | -
|
10 | | - process : function(params) {
|
11 | | - var mode = (parseInt(params.options.mode,10)||0);
|
12 | | - if (mode < 0) mode = 0;
|
13 | | - if (mode > 1) mode = 1;
|
14 | | -
|
15 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
16 | | - var data = Pixastic.prepareData(params);
|
17 | | - var rect = params.options.rect;
|
18 | | - var w = rect.width;
|
19 | | - var h = rect.height;
|
20 | | - var w4 = w*4;
|
21 | | - var y = h;
|
22 | | - do {
|
23 | | - var offsetY = (y-1)*w4;
|
24 | | - var x = w;
|
25 | | - do {
|
26 | | - var offset = offsetY + (x-1)*4;
|
27 | | -
|
28 | | - if (mode) {
|
29 | | - // a bit faster, but not as good
|
30 | | - var d = data[offset] * 0.299 + data[offset+1] * 0.587 + data[offset+2] * 0.114;
|
31 | | - var r = (d + 39);
|
32 | | - var g = (d + 14);
|
33 | | - var b = (d - 36);
|
34 | | - } else {
|
35 | | - // Microsoft
|
36 | | - var or = data[offset];
|
37 | | - var og = data[offset+1];
|
38 | | - var ob = data[offset+2];
|
39 | | -
|
40 | | - var r = (or * 0.393 + og * 0.769 + ob * 0.189);
|
41 | | - var g = (or * 0.349 + og * 0.686 + ob * 0.168);
|
42 | | - var b = (or * 0.272 + og * 0.534 + ob * 0.131);
|
43 | | - }
|
44 | | -
|
45 | | - if (r < 0) r = 0; if (r > 255) r = 255;
|
46 | | - if (g < 0) g = 0; if (g > 255) g = 255;
|
47 | | - if (b < 0) b = 0; if (b > 255) b = 255;
|
48 | | -
|
49 | | - data[offset] = r;
|
50 | | - data[offset+1] = g;
|
51 | | - data[offset+2] = b;
|
52 | | -
|
53 | | - } while (--x);
|
54 | | - } while (--y);
|
55 | | - return true;
|
56 | | - }
|
57 | | - },
|
58 | | - checkSupport : function() {
|
59 | | - return Pixastic.Client.hasCanvasImageData();
|
60 | | - }
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Sepia filter - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.sepia = { |
| 9 | + |
| 10 | + process : function(params) { |
| 11 | + var mode = (parseInt(params.options.mode,10)||0); |
| 12 | + if (mode < 0) mode = 0; |
| 13 | + if (mode > 1) mode = 1; |
| 14 | + |
| 15 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 16 | + var data = Pixastic.prepareData(params); |
| 17 | + var rect = params.options.rect; |
| 18 | + var w = rect.width; |
| 19 | + var h = rect.height; |
| 20 | + var w4 = w*4; |
| 21 | + var y = h; |
| 22 | + do { |
| 23 | + var offsetY = (y-1)*w4; |
| 24 | + var x = w; |
| 25 | + do { |
| 26 | + var offset = offsetY + (x-1)*4; |
| 27 | + |
| 28 | + if (mode) { |
| 29 | + // a bit faster, but not as good |
| 30 | + var d = data[offset] * 0.299 + data[offset+1] * 0.587 + data[offset+2] * 0.114; |
| 31 | + var r = (d + 39); |
| 32 | + var g = (d + 14); |
| 33 | + var b = (d - 36); |
| 34 | + } else { |
| 35 | + // Microsoft |
| 36 | + var or = data[offset]; |
| 37 | + var og = data[offset+1]; |
| 38 | + var ob = data[offset+2]; |
| 39 | + |
| 40 | + var r = (or * 0.393 + og * 0.769 + ob * 0.189); |
| 41 | + var g = (or * 0.349 + og * 0.686 + ob * 0.168); |
| 42 | + var b = (or * 0.272 + og * 0.534 + ob * 0.131); |
| 43 | + } |
| 44 | + |
| 45 | + if (r < 0) r = 0; if (r > 255) r = 255; |
| 46 | + if (g < 0) g = 0; if (g > 255) g = 255; |
| 47 | + if (b < 0) b = 0; if (b > 255) b = 255; |
| 48 | + |
| 49 | + data[offset] = r; |
| 50 | + data[offset+1] = g; |
| 51 | + data[offset+2] = b; |
| 52 | + |
| 53 | + } while (--x); |
| 54 | + } while (--y); |
| 55 | + return true; |
| 56 | + } |
| 57 | + }, |
| 58 | + checkSupport : function() { |
| 59 | + return Pixastic.Client.hasCanvasImageData(); |
| 60 | + } |
61 | 61 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/sepia.js |
___________________________________________________________________ |
Added: svn:eol-style |
62 | 62 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/laplace.js |
— | — | @@ -1,112 +1,112 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Laplace filter - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.laplace = {
|
9 | | - process : function(params) {
|
10 | | -
|
11 | | - var strength = 1.0;
|
12 | | - var invert = !!(params.options.invert);
|
13 | | - var contrast = parseFloat(params.options.edgeStrength)||0;
|
14 | | -
|
15 | | - var greyLevel = parseInt(params.options.greyLevel)||0;
|
16 | | -
|
17 | | - contrast = -contrast;
|
18 | | -
|
19 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
20 | | - var data = Pixastic.prepareData(params);
|
21 | | - var dataCopy = Pixastic.prepareData(params, true)
|
22 | | -
|
23 | | - var kernel = [
|
24 | | - [-1, -1, -1],
|
25 | | - [-1, 8, -1],
|
26 | | - [-1, -1, -1]
|
27 | | - ];
|
28 | | -
|
29 | | - var weight = 1/8;
|
30 | | -
|
31 | | - var rect = params.options.rect;
|
32 | | - var w = rect.width;
|
33 | | - var h = rect.height;
|
34 | | -
|
35 | | - var w4 = w*4;
|
36 | | - var y = h;
|
37 | | - do {
|
38 | | - var offsetY = (y-1)*w4;
|
39 | | -
|
40 | | - var nextY = (y == h) ? y - 1 : y;
|
41 | | - var prevY = (y == 1) ? 0 : y-2;
|
42 | | -
|
43 | | - var offsetYPrev = prevY*w*4;
|
44 | | - var offsetYNext = nextY*w*4;
|
45 | | -
|
46 | | - var x = w;
|
47 | | - do {
|
48 | | - var offset = offsetY + (x*4-4);
|
49 | | -
|
50 | | - var offsetPrev = offsetYPrev + ((x == 1) ? 0 : x-2) * 4;
|
51 | | - var offsetNext = offsetYNext + ((x == w) ? x-1 : x) * 4;
|
52 | | -
|
53 | | - var r = ((-dataCopy[offsetPrev-4]
|
54 | | - - dataCopy[offsetPrev]
|
55 | | - - dataCopy[offsetPrev+4]
|
56 | | - - dataCopy[offset-4]
|
57 | | - - dataCopy[offset+4]
|
58 | | - - dataCopy[offsetNext-4]
|
59 | | - - dataCopy[offsetNext]
|
60 | | - - dataCopy[offsetNext+4])
|
61 | | - + dataCopy[offset] * 8)
|
62 | | - * weight;
|
63 | | -
|
64 | | - var g = ((-dataCopy[offsetPrev-3]
|
65 | | - - dataCopy[offsetPrev+1]
|
66 | | - - dataCopy[offsetPrev+5]
|
67 | | - - dataCopy[offset-3]
|
68 | | - - dataCopy[offset+5]
|
69 | | - - dataCopy[offsetNext-3]
|
70 | | - - dataCopy[offsetNext+1]
|
71 | | - - dataCopy[offsetNext+5])
|
72 | | - + dataCopy[offset+1] * 8)
|
73 | | - * weight;
|
74 | | -
|
75 | | - var b = ((-dataCopy[offsetPrev-2]
|
76 | | - - dataCopy[offsetPrev+2]
|
77 | | - - dataCopy[offsetPrev+6]
|
78 | | - - dataCopy[offset-2]
|
79 | | - - dataCopy[offset+6]
|
80 | | - - dataCopy[offsetNext-2]
|
81 | | - - dataCopy[offsetNext+2]
|
82 | | - - dataCopy[offsetNext+6])
|
83 | | - + dataCopy[offset+2] * 8)
|
84 | | - * weight;
|
85 | | -
|
86 | | - var brightness = ((r + g + b)/3) + greyLevel;
|
87 | | -
|
88 | | - if (contrast != 0) {
|
89 | | - if (brightness > 127) {
|
90 | | - brightness += ((brightness + 1) - 128) * contrast;
|
91 | | - } else if (brightness < 127) {
|
92 | | - brightness -= (brightness + 1) * contrast;
|
93 | | - }
|
94 | | - }
|
95 | | - if (invert) {
|
96 | | - brightness = 255 - brightness;
|
97 | | - }
|
98 | | - if (brightness < 0 ) brightness = 0;
|
99 | | - if (brightness > 255 ) brightness = 255;
|
100 | | -
|
101 | | - data[offset] = data[offset+1] = data[offset+2] = brightness;
|
102 | | -
|
103 | | - } while (--x);
|
104 | | - } while (--y);
|
105 | | -
|
106 | | - return true;
|
107 | | - }
|
108 | | - },
|
109 | | - checkSupport : function() {
|
110 | | - return Pixastic.Client.hasCanvasImageData();
|
111 | | - }
|
112 | | -}
|
113 | | -
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Laplace filter - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.laplace = { |
| 9 | + process : function(params) { |
| 10 | + |
| 11 | + var strength = 1.0; |
| 12 | + var invert = !!(params.options.invert); |
| 13 | + var contrast = parseFloat(params.options.edgeStrength)||0; |
| 14 | + |
| 15 | + var greyLevel = parseInt(params.options.greyLevel)||0; |
| 16 | + |
| 17 | + contrast = -contrast; |
| 18 | + |
| 19 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 20 | + var data = Pixastic.prepareData(params); |
| 21 | + var dataCopy = Pixastic.prepareData(params, true) |
| 22 | + |
| 23 | + var kernel = [ |
| 24 | + [-1, -1, -1], |
| 25 | + [-1, 8, -1], |
| 26 | + [-1, -1, -1] |
| 27 | + ]; |
| 28 | + |
| 29 | + var weight = 1/8; |
| 30 | + |
| 31 | + var rect = params.options.rect; |
| 32 | + var w = rect.width; |
| 33 | + var h = rect.height; |
| 34 | + |
| 35 | + var w4 = w*4; |
| 36 | + var y = h; |
| 37 | + do { |
| 38 | + var offsetY = (y-1)*w4; |
| 39 | + |
| 40 | + var nextY = (y == h) ? y - 1 : y; |
| 41 | + var prevY = (y == 1) ? 0 : y-2; |
| 42 | + |
| 43 | + var offsetYPrev = prevY*w*4; |
| 44 | + var offsetYNext = nextY*w*4; |
| 45 | + |
| 46 | + var x = w; |
| 47 | + do { |
| 48 | + var offset = offsetY + (x*4-4); |
| 49 | + |
| 50 | + var offsetPrev = offsetYPrev + ((x == 1) ? 0 : x-2) * 4; |
| 51 | + var offsetNext = offsetYNext + ((x == w) ? x-1 : x) * 4; |
| 52 | + |
| 53 | + var r = ((-dataCopy[offsetPrev-4] |
| 54 | + - dataCopy[offsetPrev] |
| 55 | + - dataCopy[offsetPrev+4] |
| 56 | + - dataCopy[offset-4] |
| 57 | + - dataCopy[offset+4] |
| 58 | + - dataCopy[offsetNext-4] |
| 59 | + - dataCopy[offsetNext] |
| 60 | + - dataCopy[offsetNext+4]) |
| 61 | + + dataCopy[offset] * 8) |
| 62 | + * weight; |
| 63 | + |
| 64 | + var g = ((-dataCopy[offsetPrev-3] |
| 65 | + - dataCopy[offsetPrev+1] |
| 66 | + - dataCopy[offsetPrev+5] |
| 67 | + - dataCopy[offset-3] |
| 68 | + - dataCopy[offset+5] |
| 69 | + - dataCopy[offsetNext-3] |
| 70 | + - dataCopy[offsetNext+1] |
| 71 | + - dataCopy[offsetNext+5]) |
| 72 | + + dataCopy[offset+1] * 8) |
| 73 | + * weight; |
| 74 | + |
| 75 | + var b = ((-dataCopy[offsetPrev-2] |
| 76 | + - dataCopy[offsetPrev+2] |
| 77 | + - dataCopy[offsetPrev+6] |
| 78 | + - dataCopy[offset-2] |
| 79 | + - dataCopy[offset+6] |
| 80 | + - dataCopy[offsetNext-2] |
| 81 | + - dataCopy[offsetNext+2] |
| 82 | + - dataCopy[offsetNext+6]) |
| 83 | + + dataCopy[offset+2] * 8) |
| 84 | + * weight; |
| 85 | + |
| 86 | + var brightness = ((r + g + b)/3) + greyLevel; |
| 87 | + |
| 88 | + if (contrast != 0) { |
| 89 | + if (brightness > 127) { |
| 90 | + brightness += ((brightness + 1) - 128) * contrast; |
| 91 | + } else if (brightness < 127) { |
| 92 | + brightness -= (brightness + 1) * contrast; |
| 93 | + } |
| 94 | + } |
| 95 | + if (invert) { |
| 96 | + brightness = 255 - brightness; |
| 97 | + } |
| 98 | + if (brightness < 0 ) brightness = 0; |
| 99 | + if (brightness > 255 ) brightness = 255; |
| 100 | + |
| 101 | + data[offset] = data[offset+1] = data[offset+2] = brightness; |
| 102 | + |
| 103 | + } while (--x); |
| 104 | + } while (--y); |
| 105 | + |
| 106 | + return true; |
| 107 | + } |
| 108 | + }, |
| 109 | + checkSupport : function() { |
| 110 | + return Pixastic.Client.hasCanvasImageData(); |
| 111 | + } |
| 112 | +} |
| 113 | + |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/laplace.js |
___________________________________________________________________ |
Added: svn:eol-style |
114 | 114 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/desaturate.js |
— | — | @@ -1,39 +1,39 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Desaturation filter - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.desaturate = {
|
9 | | -
|
10 | | - process : function(params) {
|
11 | | - var useAverage = !!params.options.average;
|
12 | | -
|
13 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
14 | | - var data = Pixastic.prepareData(params);
|
15 | | - var rect = params.options.rect;
|
16 | | - var w = rect.width;
|
17 | | - var h = rect.height;
|
18 | | - var w4 = w*4;
|
19 | | - var y = h;
|
20 | | - do {
|
21 | | - var offsetY = (y-1)*w4;
|
22 | | - var x = w;
|
23 | | - do {
|
24 | | - var offset = offsetY + (x-1)*4;
|
25 | | - var brightness = useAverage ?
|
26 | | - (data[offset]+data[offset+1]+data[offset+2])/3
|
27 | | - : (data[offset]*0.3 + data[offset+1]*0.59 + data[offset+2]*0.11);
|
28 | | - data[offset] = data[offset+1] = data[offset+2] = brightness;
|
29 | | - } while (--x);
|
30 | | - } while (--y);
|
31 | | - return true;
|
32 | | - } else if (Pixastic.Client.isIE()) {
|
33 | | - params.image.style.filter += " gray";
|
34 | | - return true;
|
35 | | - }
|
36 | | - },
|
37 | | - checkSupport : function() {
|
38 | | - return (Pixastic.Client.hasCanvasImageData() || Pixastic.Client.isIE());
|
39 | | - }
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Desaturation filter - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.desaturate = { |
| 9 | + |
| 10 | + process : function(params) { |
| 11 | + var useAverage = !!params.options.average; |
| 12 | + |
| 13 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 14 | + var data = Pixastic.prepareData(params); |
| 15 | + var rect = params.options.rect; |
| 16 | + var w = rect.width; |
| 17 | + var h = rect.height; |
| 18 | + var w4 = w*4; |
| 19 | + var y = h; |
| 20 | + do { |
| 21 | + var offsetY = (y-1)*w4; |
| 22 | + var x = w; |
| 23 | + do { |
| 24 | + var offset = offsetY + (x-1)*4; |
| 25 | + var brightness = useAverage ? |
| 26 | + (data[offset]+data[offset+1]+data[offset+2])/3 |
| 27 | + : (data[offset]*0.3 + data[offset+1]*0.59 + data[offset+2]*0.11); |
| 28 | + data[offset] = data[offset+1] = data[offset+2] = brightness; |
| 29 | + } while (--x); |
| 30 | + } while (--y); |
| 31 | + return true; |
| 32 | + } else if (Pixastic.Client.isIE()) { |
| 33 | + params.image.style.filter += " gray"; |
| 34 | + return true; |
| 35 | + } |
| 36 | + }, |
| 37 | + checkSupport : function() { |
| 38 | + return (Pixastic.Client.hasCanvasImageData() || Pixastic.Client.isIE()); |
| 39 | + } |
40 | 40 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/desaturate.js |
___________________________________________________________________ |
Added: svn:eol-style |
41 | 41 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/pointillize.js |
— | — | @@ -1,71 +1,71 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Pointillize filter - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.pointillize = {
|
9 | | -
|
10 | | - process : function(params) {
|
11 | | - var radius = Math.max(1,parseInt(params.options.radius,10));
|
12 | | - var density = Math.min(5,Math.max(0,parseFloat(params.options.density)||0));
|
13 | | - var noise = Math.max(0,parseFloat(params.options.noise)||0);
|
14 | | - var transparent = !!params.options.transparent;
|
15 | | -
|
16 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
17 | | - var rect = params.options.rect;
|
18 | | - var w = rect.width;
|
19 | | - var h = rect.height;
|
20 | | - var w4 = w*4;
|
21 | | - var y = h;
|
22 | | -
|
23 | | - var ctx = params.canvas.getContext("2d");
|
24 | | -
|
25 | | - var pixel = document.createElement("canvas");
|
26 | | - pixel.width = pixel.height = 1;
|
27 | | - var pixelCtx = pixel.getContext("2d");
|
28 | | -
|
29 | | - var copy = document.createElement("canvas");
|
30 | | - copy.width = w;
|
31 | | - copy.height = h;
|
32 | | - var copyCtx = copy.getContext("2d");
|
33 | | - copyCtx.drawImage(params.canvas,rect.left,rect.top,w,h, 0,0,w,h);
|
34 | | -
|
35 | | - var diameter = radius * 2;
|
36 | | -
|
37 | | - if (transparent)
|
38 | | - ctx.clearRect(rect.left, rect.top, rect.width, rect.height);
|
39 | | -
|
40 | | - var noiseRadius = radius * noise;
|
41 | | -
|
42 | | - var dist = 1 / density;
|
43 | | -
|
44 | | - for (var y=0;y<h+radius;y+=diameter*dist) {
|
45 | | - for (var x=0;x<w+radius;x+=diameter*dist) {
|
46 | | - rndX = noise ? (x+((Math.random()*2-1) * noiseRadius))>>0 : x;
|
47 | | - rndY = noise ? (y+((Math.random()*2-1) * noiseRadius))>>0 : y;
|
48 | | -
|
49 | | - var pixX = rndX - radius;
|
50 | | - var pixY = rndY - radius;
|
51 | | - if (pixX < 0) pixX = 0;
|
52 | | - if (pixY < 0) pixY = 0;
|
53 | | -
|
54 | | - pixelCtx.drawImage(copy, pixX, pixY, diameter, diameter, 0, 0, 1, 1);
|
55 | | - var data = pixelCtx.getImageData(0,0,1,1).data;
|
56 | | - ctx.fillStyle = "rgb(" + data[0] + "," + data[1] + "," + data[2] + ")";
|
57 | | - ctx.beginPath();
|
58 | | - ctx.arc(rect.left + rndX,rect.top + rndY, radius, 0, Math.PI*2, true);
|
59 | | - ctx.closePath();
|
60 | | - ctx.fill();
|
61 | | - }
|
62 | | - }
|
63 | | -
|
64 | | - params.useData = false;
|
65 | | -
|
66 | | - return true;
|
67 | | - }
|
68 | | - },
|
69 | | - checkSupport : function() {
|
70 | | - return (Pixastic.Client.hasCanvasImageData());
|
71 | | - }
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Pointillize filter - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.pointillize = { |
| 9 | + |
| 10 | + process : function(params) { |
| 11 | + var radius = Math.max(1,parseInt(params.options.radius,10)); |
| 12 | + var density = Math.min(5,Math.max(0,parseFloat(params.options.density)||0)); |
| 13 | + var noise = Math.max(0,parseFloat(params.options.noise)||0); |
| 14 | + var transparent = !!params.options.transparent; |
| 15 | + |
| 16 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 17 | + var rect = params.options.rect; |
| 18 | + var w = rect.width; |
| 19 | + var h = rect.height; |
| 20 | + var w4 = w*4; |
| 21 | + var y = h; |
| 22 | + |
| 23 | + var ctx = params.canvas.getContext("2d"); |
| 24 | + |
| 25 | + var pixel = document.createElement("canvas"); |
| 26 | + pixel.width = pixel.height = 1; |
| 27 | + var pixelCtx = pixel.getContext("2d"); |
| 28 | + |
| 29 | + var copy = document.createElement("canvas"); |
| 30 | + copy.width = w; |
| 31 | + copy.height = h; |
| 32 | + var copyCtx = copy.getContext("2d"); |
| 33 | + copyCtx.drawImage(params.canvas,rect.left,rect.top,w,h, 0,0,w,h); |
| 34 | + |
| 35 | + var diameter = radius * 2; |
| 36 | + |
| 37 | + if (transparent) |
| 38 | + ctx.clearRect(rect.left, rect.top, rect.width, rect.height); |
| 39 | + |
| 40 | + var noiseRadius = radius * noise; |
| 41 | + |
| 42 | + var dist = 1 / density; |
| 43 | + |
| 44 | + for (var y=0;y<h+radius;y+=diameter*dist) { |
| 45 | + for (var x=0;x<w+radius;x+=diameter*dist) { |
| 46 | + rndX = noise ? (x+((Math.random()*2-1) * noiseRadius))>>0 : x; |
| 47 | + rndY = noise ? (y+((Math.random()*2-1) * noiseRadius))>>0 : y; |
| 48 | + |
| 49 | + var pixX = rndX - radius; |
| 50 | + var pixY = rndY - radius; |
| 51 | + if (pixX < 0) pixX = 0; |
| 52 | + if (pixY < 0) pixY = 0; |
| 53 | + |
| 54 | + pixelCtx.drawImage(copy, pixX, pixY, diameter, diameter, 0, 0, 1, 1); |
| 55 | + var data = pixelCtx.getImageData(0,0,1,1).data; |
| 56 | + ctx.fillStyle = "rgb(" + data[0] + "," + data[1] + "," + data[2] + ")"; |
| 57 | + ctx.beginPath(); |
| 58 | + ctx.arc(rect.left + rndX,rect.top + rndY, radius, 0, Math.PI*2, true); |
| 59 | + ctx.closePath(); |
| 60 | + ctx.fill(); |
| 61 | + } |
| 62 | + } |
| 63 | + |
| 64 | + params.useData = false; |
| 65 | + |
| 66 | + return true; |
| 67 | + } |
| 68 | + }, |
| 69 | + checkSupport : function() { |
| 70 | + return (Pixastic.Client.hasCanvasImageData()); |
| 71 | + } |
72 | 72 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/pointillize.js |
___________________________________________________________________ |
Added: svn:eol-style |
73 | 73 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/fliph.js |
— | — | @@ -1,33 +1,33 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Horizontal flip - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.fliph = {
|
9 | | - process : function(params) {
|
10 | | - if (Pixastic.Client.hasCanvas()) {
|
11 | | - var rect = params.options.rect;
|
12 | | - var copyCanvas = document.createElement("canvas");
|
13 | | - copyCanvas.width = rect.width;
|
14 | | - copyCanvas.height = rect.height;
|
15 | | - copyCanvas.getContext("2d").drawImage(params.image, rect.left, rect.top, rect.width, rect.height, 0, 0, rect.width, rect.height);
|
16 | | -
|
17 | | - var ctx = params.canvas.getContext("2d");
|
18 | | - ctx.clearRect(rect.left, rect.top, rect.width, rect.height);
|
19 | | - ctx.scale(-1,1);
|
20 | | - ctx.drawImage(copyCanvas, -rect.left-rect.width, rect.top, rect.width, rect.height)
|
21 | | - params.useData = false;
|
22 | | -
|
23 | | - return true;
|
24 | | -
|
25 | | - } else if (Pixastic.Client.isIE()) {
|
26 | | - params.image.style.filter += " fliph";
|
27 | | - return true;
|
28 | | - }
|
29 | | - },
|
30 | | - checkSupport : function() {
|
31 | | - return (Pixastic.Client.hasCanvas() || Pixastic.Client.isIE());
|
32 | | - }
|
33 | | -}
|
34 | | -
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Horizontal flip - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.fliph = { |
| 9 | + process : function(params) { |
| 10 | + if (Pixastic.Client.hasCanvas()) { |
| 11 | + var rect = params.options.rect; |
| 12 | + var copyCanvas = document.createElement("canvas"); |
| 13 | + copyCanvas.width = rect.width; |
| 14 | + copyCanvas.height = rect.height; |
| 15 | + copyCanvas.getContext("2d").drawImage(params.image, rect.left, rect.top, rect.width, rect.height, 0, 0, rect.width, rect.height); |
| 16 | + |
| 17 | + var ctx = params.canvas.getContext("2d"); |
| 18 | + ctx.clearRect(rect.left, rect.top, rect.width, rect.height); |
| 19 | + ctx.scale(-1,1); |
| 20 | + ctx.drawImage(copyCanvas, -rect.left-rect.width, rect.top, rect.width, rect.height) |
| 21 | + params.useData = false; |
| 22 | + |
| 23 | + return true; |
| 24 | + |
| 25 | + } else if (Pixastic.Client.isIE()) { |
| 26 | + params.image.style.filter += " fliph"; |
| 27 | + return true; |
| 28 | + } |
| 29 | + }, |
| 30 | + checkSupport : function() { |
| 31 | + return (Pixastic.Client.hasCanvas() || Pixastic.Client.isIE()); |
| 32 | + } |
| 33 | +} |
| 34 | + |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/fliph.js |
___________________________________________________________________ |
Added: svn:eol-style |
35 | 35 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/crop.js |
— | — | @@ -1,35 +1,35 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Crop - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.crop = {
|
9 | | - process : function(params) {
|
10 | | - if (Pixastic.Client.hasCanvas()) {
|
11 | | - var rect = params.options.rect;
|
12 | | -
|
13 | | - var copy = document.createElement("canvas");
|
14 | | - copy.width = params.width;
|
15 | | - copy.height = params.height;
|
16 | | - copy.getContext("2d").drawImage(params.canvas,0,0);
|
17 | | -
|
18 | | - params.canvas.width = rect.width;
|
19 | | - params.canvas.height = rect.height;
|
20 | | - params.canvas.getContext("2d").clearRect(0,0,rect.width,rect.height);
|
21 | | -
|
22 | | - params.canvas.getContext("2d").drawImage(copy,
|
23 | | - rect.left,rect.top,rect.width,rect.height,
|
24 | | - 0,0,rect.width,rect.height
|
25 | | - );
|
26 | | -
|
27 | | - params.useData = false;
|
28 | | - return true;
|
29 | | - }
|
30 | | - },
|
31 | | - checkSupport : function() {
|
32 | | - return Pixastic.Client.hasCanvas();
|
33 | | - }
|
34 | | -}
|
35 | | -
|
36 | | -
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Crop - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.crop = { |
| 9 | + process : function(params) { |
| 10 | + if (Pixastic.Client.hasCanvas()) { |
| 11 | + var rect = params.options.rect; |
| 12 | + |
| 13 | + var copy = document.createElement("canvas"); |
| 14 | + copy.width = params.width; |
| 15 | + copy.height = params.height; |
| 16 | + copy.getContext("2d").drawImage(params.canvas,0,0); |
| 17 | + |
| 18 | + params.canvas.width = rect.width; |
| 19 | + params.canvas.height = rect.height; |
| 20 | + params.canvas.getContext("2d").clearRect(0,0,rect.width,rect.height); |
| 21 | + |
| 22 | + params.canvas.getContext("2d").drawImage(copy, |
| 23 | + rect.left,rect.top,rect.width,rect.height, |
| 24 | + 0,0,rect.width,rect.height |
| 25 | + ); |
| 26 | + |
| 27 | + params.useData = false; |
| 28 | + return true; |
| 29 | + } |
| 30 | + }, |
| 31 | + checkSupport : function() { |
| 32 | + return Pixastic.Client.hasCanvas(); |
| 33 | + } |
| 34 | +} |
| 35 | + |
| 36 | + |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/crop.js |
___________________________________________________________________ |
Added: svn:eol-style |
37 | 37 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/blur.js |
— | — | @@ -1,126 +1,126 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Blur filter - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.blur = {
|
9 | | - process : function(params) {
|
10 | | -
|
11 | | - if (typeof params.options.fixMargin == "undefined")
|
12 | | - params.options.fixMargin = true;
|
13 | | -
|
14 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
15 | | - var data = Pixastic.prepareData(params);
|
16 | | - var dataCopy = Pixastic.prepareData(params, true)
|
17 | | -
|
18 | | - /*
|
19 | | - var kernel = [
|
20 | | - [0.5, 1, 0.5],
|
21 | | - [1, 2, 1],
|
22 | | - [0.5, 1, 0.5]
|
23 | | - ];
|
24 | | - */
|
25 | | -
|
26 | | - var kernel = [
|
27 | | - [0, 1, 0],
|
28 | | - [1, 2, 1],
|
29 | | - [0, 1, 0]
|
30 | | - ];
|
31 | | -
|
32 | | - var weight = 0;
|
33 | | - for (var i=0;i<3;i++) {
|
34 | | - for (var j=0;j<3;j++) {
|
35 | | - weight += kernel[i][j];
|
36 | | - }
|
37 | | - }
|
38 | | -
|
39 | | - weight = 1 / (weight*2);
|
40 | | -
|
41 | | - var rect = params.options.rect;
|
42 | | - var w = rect.width;
|
43 | | - var h = rect.height;
|
44 | | -
|
45 | | - var w4 = w*4;
|
46 | | - var y = h;
|
47 | | - do {
|
48 | | - var offsetY = (y-1)*w4;
|
49 | | -
|
50 | | - var prevY = (y == 1) ? 0 : y-2;
|
51 | | - var nextY = (y == h) ? y - 1 : y;
|
52 | | -
|
53 | | - var offsetYPrev = prevY*w*4;
|
54 | | - var offsetYNext = nextY*w*4;
|
55 | | -
|
56 | | - var x = w;
|
57 | | - do {
|
58 | | - var offset = offsetY + (x*4-4);
|
59 | | -
|
60 | | - var offsetPrev = offsetYPrev + ((x == 1) ? 0 : x-2) * 4;
|
61 | | - var offsetNext = offsetYNext + ((x == w) ? x-1 : x) * 4;
|
62 | | -
|
63 | | - data[offset] = (
|
64 | | - /*
|
65 | | - dataCopy[offsetPrev - 4]
|
66 | | - + dataCopy[offsetPrev+4]
|
67 | | - + dataCopy[offsetNext - 4]
|
68 | | - + dataCopy[offsetNext+4]
|
69 | | - +
|
70 | | - */
|
71 | | - (dataCopy[offsetPrev]
|
72 | | - + dataCopy[offset-4]
|
73 | | - + dataCopy[offset+4]
|
74 | | - + dataCopy[offsetNext]) * 2
|
75 | | - + dataCopy[offset] * 4
|
76 | | - ) * weight;
|
77 | | -
|
78 | | - data[offset+1] = (
|
79 | | - /*
|
80 | | - dataCopy[offsetPrev - 3]
|
81 | | - + dataCopy[offsetPrev+5]
|
82 | | - + dataCopy[offsetNext - 3]
|
83 | | - + dataCopy[offsetNext+5]
|
84 | | - +
|
85 | | - */
|
86 | | - (dataCopy[offsetPrev+1]
|
87 | | - + dataCopy[offset-3]
|
88 | | - + dataCopy[offset+5]
|
89 | | - + dataCopy[offsetNext+1]) * 2
|
90 | | - + dataCopy[offset+1] * 4
|
91 | | - ) * weight;
|
92 | | -
|
93 | | - data[offset+2] = (
|
94 | | - /*
|
95 | | - dataCopy[offsetPrev - 2]
|
96 | | - + dataCopy[offsetPrev+6]
|
97 | | - + dataCopy[offsetNext - 2]
|
98 | | - + dataCopy[offsetNext+6]
|
99 | | - +
|
100 | | - */
|
101 | | - (dataCopy[offsetPrev+2]
|
102 | | - + dataCopy[offset-2]
|
103 | | - + dataCopy[offset+6]
|
104 | | - + dataCopy[offsetNext+2]) * 2
|
105 | | - + dataCopy[offset+2] * 4
|
106 | | - ) * weight;
|
107 | | -
|
108 | | - } while (--x);
|
109 | | - } while (--y);
|
110 | | -
|
111 | | - return true;
|
112 | | -
|
113 | | - } else if (Pixastic.Client.isIE()) {
|
114 | | - params.image.style.filter += " progid:DXImageTransform.Microsoft.Blur(pixelradius=1.5)";
|
115 | | -
|
116 | | - if (params.options.fixMargin) {
|
117 | | - params.image.style.marginLeft = (parseInt(params.image.style.marginLeft,10)||0) - 2 + "px";
|
118 | | - params.image.style.marginTop = (parseInt(params.image.style.marginTop,10)||0) - 2 + "px";
|
119 | | - }
|
120 | | -
|
121 | | - return true;
|
122 | | - }
|
123 | | - },
|
124 | | - checkSupport : function() {
|
125 | | - return (Pixastic.Client.hasCanvasImageData() || Pixastic.Client.isIE());
|
126 | | - }
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Blur filter - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.blur = { |
| 9 | + process : function(params) { |
| 10 | + |
| 11 | + if (typeof params.options.fixMargin == "undefined") |
| 12 | + params.options.fixMargin = true; |
| 13 | + |
| 14 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 15 | + var data = Pixastic.prepareData(params); |
| 16 | + var dataCopy = Pixastic.prepareData(params, true) |
| 17 | + |
| 18 | + /* |
| 19 | + var kernel = [ |
| 20 | + [0.5, 1, 0.5], |
| 21 | + [1, 2, 1], |
| 22 | + [0.5, 1, 0.5] |
| 23 | + ]; |
| 24 | + */ |
| 25 | + |
| 26 | + var kernel = [ |
| 27 | + [0, 1, 0], |
| 28 | + [1, 2, 1], |
| 29 | + [0, 1, 0] |
| 30 | + ]; |
| 31 | + |
| 32 | + var weight = 0; |
| 33 | + for (var i=0;i<3;i++) { |
| 34 | + for (var j=0;j<3;j++) { |
| 35 | + weight += kernel[i][j]; |
| 36 | + } |
| 37 | + } |
| 38 | + |
| 39 | + weight = 1 / (weight*2); |
| 40 | + |
| 41 | + var rect = params.options.rect; |
| 42 | + var w = rect.width; |
| 43 | + var h = rect.height; |
| 44 | + |
| 45 | + var w4 = w*4; |
| 46 | + var y = h; |
| 47 | + do { |
| 48 | + var offsetY = (y-1)*w4; |
| 49 | + |
| 50 | + var prevY = (y == 1) ? 0 : y-2; |
| 51 | + var nextY = (y == h) ? y - 1 : y; |
| 52 | + |
| 53 | + var offsetYPrev = prevY*w*4; |
| 54 | + var offsetYNext = nextY*w*4; |
| 55 | + |
| 56 | + var x = w; |
| 57 | + do { |
| 58 | + var offset = offsetY + (x*4-4); |
| 59 | + |
| 60 | + var offsetPrev = offsetYPrev + ((x == 1) ? 0 : x-2) * 4; |
| 61 | + var offsetNext = offsetYNext + ((x == w) ? x-1 : x) * 4; |
| 62 | + |
| 63 | + data[offset] = ( |
| 64 | + /* |
| 65 | + dataCopy[offsetPrev - 4] |
| 66 | + + dataCopy[offsetPrev+4] |
| 67 | + + dataCopy[offsetNext - 4] |
| 68 | + + dataCopy[offsetNext+4] |
| 69 | + + |
| 70 | + */ |
| 71 | + (dataCopy[offsetPrev] |
| 72 | + + dataCopy[offset-4] |
| 73 | + + dataCopy[offset+4] |
| 74 | + + dataCopy[offsetNext]) * 2 |
| 75 | + + dataCopy[offset] * 4 |
| 76 | + ) * weight; |
| 77 | + |
| 78 | + data[offset+1] = ( |
| 79 | + /* |
| 80 | + dataCopy[offsetPrev - 3] |
| 81 | + + dataCopy[offsetPrev+5] |
| 82 | + + dataCopy[offsetNext - 3] |
| 83 | + + dataCopy[offsetNext+5] |
| 84 | + + |
| 85 | + */ |
| 86 | + (dataCopy[offsetPrev+1] |
| 87 | + + dataCopy[offset-3] |
| 88 | + + dataCopy[offset+5] |
| 89 | + + dataCopy[offsetNext+1]) * 2 |
| 90 | + + dataCopy[offset+1] * 4 |
| 91 | + ) * weight; |
| 92 | + |
| 93 | + data[offset+2] = ( |
| 94 | + /* |
| 95 | + dataCopy[offsetPrev - 2] |
| 96 | + + dataCopy[offsetPrev+6] |
| 97 | + + dataCopy[offsetNext - 2] |
| 98 | + + dataCopy[offsetNext+6] |
| 99 | + + |
| 100 | + */ |
| 101 | + (dataCopy[offsetPrev+2] |
| 102 | + + dataCopy[offset-2] |
| 103 | + + dataCopy[offset+6] |
| 104 | + + dataCopy[offsetNext+2]) * 2 |
| 105 | + + dataCopy[offset+2] * 4 |
| 106 | + ) * weight; |
| 107 | + |
| 108 | + } while (--x); |
| 109 | + } while (--y); |
| 110 | + |
| 111 | + return true; |
| 112 | + |
| 113 | + } else if (Pixastic.Client.isIE()) { |
| 114 | + params.image.style.filter += " progid:DXImageTransform.Microsoft.Blur(pixelradius=1.5)"; |
| 115 | + |
| 116 | + if (params.options.fixMargin) { |
| 117 | + params.image.style.marginLeft = (parseInt(params.image.style.marginLeft,10)||0) - 2 + "px"; |
| 118 | + params.image.style.marginTop = (parseInt(params.image.style.marginTop,10)||0) - 2 + "px"; |
| 119 | + } |
| 120 | + |
| 121 | + return true; |
| 122 | + } |
| 123 | + }, |
| 124 | + checkSupport : function() { |
| 125 | + return (Pixastic.Client.hasCanvasImageData() || Pixastic.Client.isIE()); |
| 126 | + } |
127 | 127 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/blur.js |
___________________________________________________________________ |
Added: svn:eol-style |
128 | 128 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/invert.js |
— | — | @@ -1,39 +1,39 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Invert filter - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.invert = {
|
9 | | - process : function(params) {
|
10 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
11 | | - var data = Pixastic.prepareData(params);
|
12 | | -
|
13 | | - var invertAlpha = !!params.options.invertAlpha;
|
14 | | - var rect = params.options.rect;
|
15 | | - var w = rect.width;
|
16 | | - var h = rect.height;
|
17 | | -
|
18 | | - var w4 = w*4;
|
19 | | - var y = h;
|
20 | | - do {
|
21 | | - var offsetY = (y-1)*w4;
|
22 | | - var x = w;
|
23 | | - do {
|
24 | | - var offset = offsetY + (x-1)*4;
|
25 | | - data[offset] = 255 - data[offset];
|
26 | | - data[offset+1] = 255 - data[offset+1];
|
27 | | - data[offset+2] = 255 - data[offset+2];
|
28 | | - if (invertAlpha) data[offset+3] = 255 - data[offset+3];
|
29 | | - } while (--x);
|
30 | | - } while (--y);
|
31 | | - return true;
|
32 | | - } else if (Pixastic.Client.isIE()) {
|
33 | | - params.image.style.filter += " invert";
|
34 | | - return true;
|
35 | | - }
|
36 | | - },
|
37 | | - checkSupport : function() {
|
38 | | - return (Pixastic.Client.hasCanvasImageData() || Pixastic.Client.isIE());
|
39 | | - }
|
40 | | -}
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Invert filter - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.invert = { |
| 9 | + process : function(params) { |
| 10 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 11 | + var data = Pixastic.prepareData(params); |
| 12 | + |
| 13 | + var invertAlpha = !!params.options.invertAlpha; |
| 14 | + var rect = params.options.rect; |
| 15 | + var w = rect.width; |
| 16 | + var h = rect.height; |
| 17 | + |
| 18 | + var w4 = w*4; |
| 19 | + var y = h; |
| 20 | + do { |
| 21 | + var offsetY = (y-1)*w4; |
| 22 | + var x = w; |
| 23 | + do { |
| 24 | + var offset = offsetY + (x-1)*4; |
| 25 | + data[offset] = 255 - data[offset]; |
| 26 | + data[offset+1] = 255 - data[offset+1]; |
| 27 | + data[offset+2] = 255 - data[offset+2]; |
| 28 | + if (invertAlpha) data[offset+3] = 255 - data[offset+3]; |
| 29 | + } while (--x); |
| 30 | + } while (--y); |
| 31 | + return true; |
| 32 | + } else if (Pixastic.Client.isIE()) { |
| 33 | + params.image.style.filter += " invert"; |
| 34 | + return true; |
| 35 | + } |
| 36 | + }, |
| 37 | + checkSupport : function() { |
| 38 | + return (Pixastic.Client.hasCanvasImageData() || Pixastic.Client.isIE()); |
| 39 | + } |
| 40 | +} |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/invert.js |
___________________________________________________________________ |
Added: svn:eol-style |
41 | 41 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/brightness.js |
— | — | @@ -1,71 +1,71 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Brightness/Contrast filter - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.brightness = {
|
9 | | -
|
10 | | - process : function(params) {
|
11 | | -
|
12 | | - var brightness = parseInt(params.options.brightness,10) || 0;
|
13 | | - var contrast = parseFloat(params.options.contrast)||0;
|
14 | | - var legacy = !!(params.options.legacy);
|
15 | | -
|
16 | | - if (legacy) {
|
17 | | - brightness = Math.min(150,Math.max(-150,brightness));
|
18 | | - } else {
|
19 | | - var brightMul = 1 + Math.min(150,Math.max(-150,brightness)) / 150;
|
20 | | - }
|
21 | | - contrast = Math.max(0,contrast+1);
|
22 | | -
|
23 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
24 | | - var data = Pixastic.prepareData(params);
|
25 | | - var rect = params.options.rect;
|
26 | | - var w = rect.width;
|
27 | | - var h = rect.height;
|
28 | | - var w4 = w*4;
|
29 | | - var y = h;
|
30 | | - do {
|
31 | | - var offsetY = (y-1)*w4;
|
32 | | - var x = w;
|
33 | | - do {
|
34 | | - var offset = offsetY + (x-1)*4;
|
35 | | -
|
36 | | - if (legacy) {
|
37 | | - var r = data[offset] + brightness;
|
38 | | - var g = data[offset+1] + brightness;
|
39 | | - var b = data[offset+2] + brightness;
|
40 | | - } else {
|
41 | | - var r = data[offset] * brightMul;
|
42 | | - var g = data[offset+1] * brightMul;
|
43 | | - var b = data[offset+2] * brightMul;
|
44 | | - }
|
45 | | -
|
46 | | - if (contrast != 1) {
|
47 | | - r = (r - 128) * contrast + 128;
|
48 | | - g = (g - 128) * contrast + 128;
|
49 | | - b = (b - 128) * contrast + 128;
|
50 | | - }
|
51 | | -
|
52 | | - if (r < 0 ) r = 0;
|
53 | | - if (g < 0 ) g = 0;
|
54 | | - if (b < 0 ) b = 0;
|
55 | | - if (r > 255 ) r = 255;
|
56 | | - if (g > 255 ) g = 255;
|
57 | | - if (b > 255 ) b = 255;
|
58 | | -
|
59 | | - data[offset] = r;
|
60 | | - data[offset+1] = g;
|
61 | | - data[offset+2] = b;
|
62 | | -
|
63 | | - } while (--x);
|
64 | | - } while (--y);
|
65 | | - return true;
|
66 | | - }
|
67 | | - },
|
68 | | - checkSupport : function() {
|
69 | | - return Pixastic.Client.hasCanvasImageData();
|
70 | | - }
|
71 | | -}
|
72 | | -
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Brightness/Contrast filter - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.brightness = { |
| 9 | + |
| 10 | + process : function(params) { |
| 11 | + |
| 12 | + var brightness = parseInt(params.options.brightness,10) || 0; |
| 13 | + var contrast = parseFloat(params.options.contrast)||0; |
| 14 | + var legacy = !!(params.options.legacy); |
| 15 | + |
| 16 | + if (legacy) { |
| 17 | + brightness = Math.min(150,Math.max(-150,brightness)); |
| 18 | + } else { |
| 19 | + var brightMul = 1 + Math.min(150,Math.max(-150,brightness)) / 150; |
| 20 | + } |
| 21 | + contrast = Math.max(0,contrast+1); |
| 22 | + |
| 23 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 24 | + var data = Pixastic.prepareData(params); |
| 25 | + var rect = params.options.rect; |
| 26 | + var w = rect.width; |
| 27 | + var h = rect.height; |
| 28 | + var w4 = w*4; |
| 29 | + var y = h; |
| 30 | + do { |
| 31 | + var offsetY = (y-1)*w4; |
| 32 | + var x = w; |
| 33 | + do { |
| 34 | + var offset = offsetY + (x-1)*4; |
| 35 | + |
| 36 | + if (legacy) { |
| 37 | + var r = data[offset] + brightness; |
| 38 | + var g = data[offset+1] + brightness; |
| 39 | + var b = data[offset+2] + brightness; |
| 40 | + } else { |
| 41 | + var r = data[offset] * brightMul; |
| 42 | + var g = data[offset+1] * brightMul; |
| 43 | + var b = data[offset+2] * brightMul; |
| 44 | + } |
| 45 | + |
| 46 | + if (contrast != 1) { |
| 47 | + r = (r - 128) * contrast + 128; |
| 48 | + g = (g - 128) * contrast + 128; |
| 49 | + b = (b - 128) * contrast + 128; |
| 50 | + } |
| 51 | + |
| 52 | + if (r < 0 ) r = 0; |
| 53 | + if (g < 0 ) g = 0; |
| 54 | + if (b < 0 ) b = 0; |
| 55 | + if (r > 255 ) r = 255; |
| 56 | + if (g > 255 ) g = 255; |
| 57 | + if (b > 255 ) b = 255; |
| 58 | + |
| 59 | + data[offset] = r; |
| 60 | + data[offset+1] = g; |
| 61 | + data[offset+2] = b; |
| 62 | + |
| 63 | + } while (--x); |
| 64 | + } while (--y); |
| 65 | + return true; |
| 66 | + } |
| 67 | + }, |
| 68 | + checkSupport : function() { |
| 69 | + return Pixastic.Client.hasCanvasImageData(); |
| 70 | + } |
| 71 | +} |
| 72 | + |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/brightness.js |
___________________________________________________________________ |
Added: svn:eol-style |
73 | 73 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/glow.js |
— | — | @@ -1,98 +1,98 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Glow - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -
|
9 | | -Pixastic.Actions.glow = {
|
10 | | - process : function(params) {
|
11 | | -
|
12 | | - var amount = (parseFloat(params.options.amount)||0);
|
13 | | - var blurAmount = parseFloat(params.options.radius)||0;
|
14 | | -
|
15 | | - amount = Math.min(1,Math.max(0,amount));
|
16 | | - blurAmount = Math.min(5,Math.max(0,blurAmount));
|
17 | | -
|
18 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
19 | | - var rect = params.options.rect;
|
20 | | -
|
21 | | - var blurCanvas = document.createElement("canvas");
|
22 | | - blurCanvas.width = params.width;
|
23 | | - blurCanvas.height = params.height;
|
24 | | - var blurCtx = blurCanvas.getContext("2d");
|
25 | | - blurCtx.drawImage(params.canvas,0,0);
|
26 | | -
|
27 | | - var scale = 2;
|
28 | | - var smallWidth = Math.round(params.width / scale);
|
29 | | - var smallHeight = Math.round(params.height / scale);
|
30 | | -
|
31 | | - var copy = document.createElement("canvas");
|
32 | | - copy.width = smallWidth;
|
33 | | - copy.height = smallHeight;
|
34 | | -
|
35 | | - var clear = true;
|
36 | | - var steps = Math.round(blurAmount * 20);
|
37 | | -
|
38 | | - var copyCtx = copy.getContext("2d");
|
39 | | - for (var i=0;i<steps;i++) {
|
40 | | - var scaledWidth = Math.max(1,Math.round(smallWidth - i));
|
41 | | - var scaledHeight = Math.max(1,Math.round(smallHeight - i));
|
42 | | -
|
43 | | - copyCtx.clearRect(0,0,smallWidth,smallHeight);
|
44 | | -
|
45 | | - copyCtx.drawImage(
|
46 | | - blurCanvas,
|
47 | | - 0,0,params.width,params.height,
|
48 | | - 0,0,scaledWidth,scaledHeight
|
49 | | - );
|
50 | | -
|
51 | | - blurCtx.clearRect(0,0,params.width,params.height);
|
52 | | -
|
53 | | - blurCtx.drawImage(
|
54 | | - copy,
|
55 | | - 0,0,scaledWidth,scaledHeight,
|
56 | | - 0,0,params.width,params.height
|
57 | | - );
|
58 | | - }
|
59 | | -
|
60 | | - var data = Pixastic.prepareData(params);
|
61 | | - var blurData = Pixastic.prepareData({canvas:blurCanvas,options:params.options});
|
62 | | - var w = rect.width;
|
63 | | - var h = rect.height;
|
64 | | - var w4 = w*4;
|
65 | | - var y = h;
|
66 | | - do {
|
67 | | - var offsetY = (y-1)*w4;
|
68 | | - var x = w;
|
69 | | - do {
|
70 | | - var offset = offsetY + (x*4-4);
|
71 | | -
|
72 | | - var r = data[offset] + amount * blurData[offset];
|
73 | | - var g = data[offset+1] + amount * blurData[offset+1];
|
74 | | - var b = data[offset+2] + amount * blurData[offset+2];
|
75 | | -
|
76 | | - if (r > 255) r = 255;
|
77 | | - if (g > 255) g = 255;
|
78 | | - if (b > 255) b = 255;
|
79 | | - if (r < 0) r = 0;
|
80 | | - if (g < 0) g = 0;
|
81 | | - if (b < 0) b = 0;
|
82 | | -
|
83 | | - data[offset] = r;
|
84 | | - data[offset+1] = g;
|
85 | | - data[offset+2] = b;
|
86 | | -
|
87 | | - } while (--x);
|
88 | | - } while (--y);
|
89 | | -
|
90 | | - return true;
|
91 | | - }
|
92 | | - },
|
93 | | - checkSupport : function() {
|
94 | | - return Pixastic.Client.hasCanvasImageData();
|
95 | | - }
|
96 | | -}
|
97 | | -
|
98 | | -
|
99 | | -
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Glow - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | + |
| 9 | +Pixastic.Actions.glow = { |
| 10 | + process : function(params) { |
| 11 | + |
| 12 | + var amount = (parseFloat(params.options.amount)||0); |
| 13 | + var blurAmount = parseFloat(params.options.radius)||0; |
| 14 | + |
| 15 | + amount = Math.min(1,Math.max(0,amount)); |
| 16 | + blurAmount = Math.min(5,Math.max(0,blurAmount)); |
| 17 | + |
| 18 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 19 | + var rect = params.options.rect; |
| 20 | + |
| 21 | + var blurCanvas = document.createElement("canvas"); |
| 22 | + blurCanvas.width = params.width; |
| 23 | + blurCanvas.height = params.height; |
| 24 | + var blurCtx = blurCanvas.getContext("2d"); |
| 25 | + blurCtx.drawImage(params.canvas,0,0); |
| 26 | + |
| 27 | + var scale = 2; |
| 28 | + var smallWidth = Math.round(params.width / scale); |
| 29 | + var smallHeight = Math.round(params.height / scale); |
| 30 | + |
| 31 | + var copy = document.createElement("canvas"); |
| 32 | + copy.width = smallWidth; |
| 33 | + copy.height = smallHeight; |
| 34 | + |
| 35 | + var clear = true; |
| 36 | + var steps = Math.round(blurAmount * 20); |
| 37 | + |
| 38 | + var copyCtx = copy.getContext("2d"); |
| 39 | + for (var i=0;i<steps;i++) { |
| 40 | + var scaledWidth = Math.max(1,Math.round(smallWidth - i)); |
| 41 | + var scaledHeight = Math.max(1,Math.round(smallHeight - i)); |
| 42 | + |
| 43 | + copyCtx.clearRect(0,0,smallWidth,smallHeight); |
| 44 | + |
| 45 | + copyCtx.drawImage( |
| 46 | + blurCanvas, |
| 47 | + 0,0,params.width,params.height, |
| 48 | + 0,0,scaledWidth,scaledHeight |
| 49 | + ); |
| 50 | + |
| 51 | + blurCtx.clearRect(0,0,params.width,params.height); |
| 52 | + |
| 53 | + blurCtx.drawImage( |
| 54 | + copy, |
| 55 | + 0,0,scaledWidth,scaledHeight, |
| 56 | + 0,0,params.width,params.height |
| 57 | + ); |
| 58 | + } |
| 59 | + |
| 60 | + var data = Pixastic.prepareData(params); |
| 61 | + var blurData = Pixastic.prepareData({canvas:blurCanvas,options:params.options}); |
| 62 | + var w = rect.width; |
| 63 | + var h = rect.height; |
| 64 | + var w4 = w*4; |
| 65 | + var y = h; |
| 66 | + do { |
| 67 | + var offsetY = (y-1)*w4; |
| 68 | + var x = w; |
| 69 | + do { |
| 70 | + var offset = offsetY + (x*4-4); |
| 71 | + |
| 72 | + var r = data[offset] + amount * blurData[offset]; |
| 73 | + var g = data[offset+1] + amount * blurData[offset+1]; |
| 74 | + var b = data[offset+2] + amount * blurData[offset+2]; |
| 75 | + |
| 76 | + if (r > 255) r = 255; |
| 77 | + if (g > 255) g = 255; |
| 78 | + if (b > 255) b = 255; |
| 79 | + if (r < 0) r = 0; |
| 80 | + if (g < 0) g = 0; |
| 81 | + if (b < 0) b = 0; |
| 82 | + |
| 83 | + data[offset] = r; |
| 84 | + data[offset+1] = g; |
| 85 | + data[offset+2] = b; |
| 86 | + |
| 87 | + } while (--x); |
| 88 | + } while (--y); |
| 89 | + |
| 90 | + return true; |
| 91 | + } |
| 92 | + }, |
| 93 | + checkSupport : function() { |
| 94 | + return Pixastic.Client.hasCanvasImageData(); |
| 95 | + } |
| 96 | +} |
| 97 | + |
| 98 | + |
| 99 | + |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/glow.js |
___________________________________________________________________ |
Added: svn:eol-style |
100 | 100 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/edges2.js |
— | — | @@ -1,103 +1,103 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Edge detection 2 - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - *
|
7 | | - * Contribution by Oliver Hunt (http://nerget.com/, http://nerget.com/canvas/edgeDetection.js). Thanks Oliver!
|
8 | | - *
|
9 | | - */
|
10 | | -
|
11 | | -Pixastic.Actions.edges2 = {
|
12 | | - process : function(params) {
|
13 | | -
|
14 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
15 | | - var data = Pixastic.prepareData(params);
|
16 | | - var dataCopy = Pixastic.prepareData(params, true)
|
17 | | -
|
18 | | - var rect = params.options.rect;
|
19 | | - var w = rect.width;
|
20 | | - var h = rect.height;
|
21 | | -
|
22 | | - var w4 = w * 4;
|
23 | | - var pixel = w4 + 4; // Start at (1,1)
|
24 | | - var hm1 = h - 1;
|
25 | | - var wm1 = w - 1;
|
26 | | - for (var y = 1; y < hm1; ++y) {
|
27 | | - // Prepare initial cached values for current row
|
28 | | - var centerRow = pixel - 4;
|
29 | | - var priorRow = centerRow - w4;
|
30 | | - var nextRow = centerRow + w4;
|
31 | | -
|
32 | | - var r1 = - dataCopy[priorRow] - dataCopy[centerRow] - dataCopy[nextRow];
|
33 | | - var g1 = - dataCopy[++priorRow] - dataCopy[++centerRow] - dataCopy[++nextRow];
|
34 | | - var b1 = - dataCopy[++priorRow] - dataCopy[++centerRow] - dataCopy[++nextRow];
|
35 | | -
|
36 | | - var rp = dataCopy[priorRow += 2];
|
37 | | - var gp = dataCopy[++priorRow];
|
38 | | - var bp = dataCopy[++priorRow];
|
39 | | -
|
40 | | - var rc = dataCopy[centerRow += 2];
|
41 | | - var gc = dataCopy[++centerRow];
|
42 | | - var bc = dataCopy[++centerRow];
|
43 | | -
|
44 | | - var rn = dataCopy[nextRow += 2];
|
45 | | - var gn = dataCopy[++nextRow];
|
46 | | - var bn = dataCopy[++nextRow];
|
47 | | -
|
48 | | - var r2 = - rp - rc - rn;
|
49 | | - var g2 = - gp - gc - gn;
|
50 | | - var b2 = - bp - bc - bn;
|
51 | | -
|
52 | | - // Main convolution loop
|
53 | | - for (var x = 1; x < wm1; ++x) {
|
54 | | - centerRow = pixel + 4;
|
55 | | - priorRow = centerRow - w4;
|
56 | | - nextRow = centerRow + w4;
|
57 | | -
|
58 | | - var r = 127 + r1 - rp - (rc * -8) - rn;
|
59 | | - var g = 127 + g1 - gp - (gc * -8) - gn;
|
60 | | - var b = 127 + b1 - bp - (bc * -8) - bn;
|
61 | | -
|
62 | | - r1 = r2;
|
63 | | - g1 = g2;
|
64 | | - b1 = b2;
|
65 | | -
|
66 | | - rp = dataCopy[ priorRow];
|
67 | | - gp = dataCopy[++priorRow];
|
68 | | - bp = dataCopy[++priorRow];
|
69 | | -
|
70 | | - rc = dataCopy[ centerRow];
|
71 | | - gc = dataCopy[++centerRow];
|
72 | | - bc = dataCopy[++centerRow];
|
73 | | -
|
74 | | - rn = dataCopy[ nextRow];
|
75 | | - gn = dataCopy[++nextRow];
|
76 | | - bn = dataCopy[++nextRow];
|
77 | | -
|
78 | | - r += (r2 = - rp - rc - rn);
|
79 | | - g += (g2 = - gp - gc - gn);
|
80 | | - b += (b2 = - bp - bc - bn);
|
81 | | -
|
82 | | - if (r > 255) r = 255;
|
83 | | - if (g > 255) g = 255;
|
84 | | - if (b > 255) b = 255;
|
85 | | - if (r < 0) r = 0;
|
86 | | - if (g < 0) g = 0;
|
87 | | - if (b < 0) b = 0;
|
88 | | -
|
89 | | - data[pixel] = r;
|
90 | | - data[++pixel] = g;
|
91 | | - data[++pixel] = b;
|
92 | | - //data[++pixel] = 255; // alpha
|
93 | | -
|
94 | | - pixel+=2;
|
95 | | - }
|
96 | | - pixel += 8;
|
97 | | - }
|
98 | | - return true;
|
99 | | - }
|
100 | | - },
|
101 | | - checkSupport : function() {
|
102 | | - return Pixastic.Client.hasCanvasImageData();
|
103 | | - }
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Edge detection 2 - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + * |
| 7 | + * Contribution by Oliver Hunt (http://nerget.com/, http://nerget.com/canvas/edgeDetection.js). Thanks Oliver! |
| 8 | + * |
| 9 | + */ |
| 10 | + |
| 11 | +Pixastic.Actions.edges2 = { |
| 12 | + process : function(params) { |
| 13 | + |
| 14 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 15 | + var data = Pixastic.prepareData(params); |
| 16 | + var dataCopy = Pixastic.prepareData(params, true) |
| 17 | + |
| 18 | + var rect = params.options.rect; |
| 19 | + var w = rect.width; |
| 20 | + var h = rect.height; |
| 21 | + |
| 22 | + var w4 = w * 4; |
| 23 | + var pixel = w4 + 4; // Start at (1,1) |
| 24 | + var hm1 = h - 1; |
| 25 | + var wm1 = w - 1; |
| 26 | + for (var y = 1; y < hm1; ++y) { |
| 27 | + // Prepare initial cached values for current row |
| 28 | + var centerRow = pixel - 4; |
| 29 | + var priorRow = centerRow - w4; |
| 30 | + var nextRow = centerRow + w4; |
| 31 | + |
| 32 | + var r1 = - dataCopy[priorRow] - dataCopy[centerRow] - dataCopy[nextRow]; |
| 33 | + var g1 = - dataCopy[++priorRow] - dataCopy[++centerRow] - dataCopy[++nextRow]; |
| 34 | + var b1 = - dataCopy[++priorRow] - dataCopy[++centerRow] - dataCopy[++nextRow]; |
| 35 | + |
| 36 | + var rp = dataCopy[priorRow += 2]; |
| 37 | + var gp = dataCopy[++priorRow]; |
| 38 | + var bp = dataCopy[++priorRow]; |
| 39 | + |
| 40 | + var rc = dataCopy[centerRow += 2]; |
| 41 | + var gc = dataCopy[++centerRow]; |
| 42 | + var bc = dataCopy[++centerRow]; |
| 43 | + |
| 44 | + var rn = dataCopy[nextRow += 2]; |
| 45 | + var gn = dataCopy[++nextRow]; |
| 46 | + var bn = dataCopy[++nextRow]; |
| 47 | + |
| 48 | + var r2 = - rp - rc - rn; |
| 49 | + var g2 = - gp - gc - gn; |
| 50 | + var b2 = - bp - bc - bn; |
| 51 | + |
| 52 | + // Main convolution loop |
| 53 | + for (var x = 1; x < wm1; ++x) { |
| 54 | + centerRow = pixel + 4; |
| 55 | + priorRow = centerRow - w4; |
| 56 | + nextRow = centerRow + w4; |
| 57 | + |
| 58 | + var r = 127 + r1 - rp - (rc * -8) - rn; |
| 59 | + var g = 127 + g1 - gp - (gc * -8) - gn; |
| 60 | + var b = 127 + b1 - bp - (bc * -8) - bn; |
| 61 | + |
| 62 | + r1 = r2; |
| 63 | + g1 = g2; |
| 64 | + b1 = b2; |
| 65 | + |
| 66 | + rp = dataCopy[ priorRow]; |
| 67 | + gp = dataCopy[++priorRow]; |
| 68 | + bp = dataCopy[++priorRow]; |
| 69 | + |
| 70 | + rc = dataCopy[ centerRow]; |
| 71 | + gc = dataCopy[++centerRow]; |
| 72 | + bc = dataCopy[++centerRow]; |
| 73 | + |
| 74 | + rn = dataCopy[ nextRow]; |
| 75 | + gn = dataCopy[++nextRow]; |
| 76 | + bn = dataCopy[++nextRow]; |
| 77 | + |
| 78 | + r += (r2 = - rp - rc - rn); |
| 79 | + g += (g2 = - gp - gc - gn); |
| 80 | + b += (b2 = - bp - bc - bn); |
| 81 | + |
| 82 | + if (r > 255) r = 255; |
| 83 | + if (g > 255) g = 255; |
| 84 | + if (b > 255) b = 255; |
| 85 | + if (r < 0) r = 0; |
| 86 | + if (g < 0) g = 0; |
| 87 | + if (b < 0) b = 0; |
| 88 | + |
| 89 | + data[pixel] = r; |
| 90 | + data[++pixel] = g; |
| 91 | + data[++pixel] = b; |
| 92 | + //data[++pixel] = 255; // alpha |
| 93 | + |
| 94 | + pixel+=2; |
| 95 | + } |
| 96 | + pixel += 8; |
| 97 | + } |
| 98 | + return true; |
| 99 | + } |
| 100 | + }, |
| 101 | + checkSupport : function() { |
| 102 | + return Pixastic.Client.hasCanvasImageData(); |
| 103 | + } |
104 | 104 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/edges2.js |
___________________________________________________________________ |
Added: svn:eol-style |
105 | 105 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/mosaic.js |
— | — | @@ -1,48 +1,48 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Mosaic filter - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.mosaic = {
|
9 | | -
|
10 | | - process : function(params) {
|
11 | | - var blockSize = Math.max(1,parseInt(params.options.blockSize,10));
|
12 | | -
|
13 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
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 | | -
|
20 | | - var ctx = params.canvas.getContext("2d");
|
21 | | -
|
22 | | - var pixel = document.createElement("canvas");
|
23 | | - pixel.width = pixel.height = 1;
|
24 | | - var pixelCtx = pixel.getContext("2d");
|
25 | | -
|
26 | | - var copy = document.createElement("canvas");
|
27 | | - copy.width = w;
|
28 | | - copy.height = h;
|
29 | | - var copyCtx = copy.getContext("2d");
|
30 | | - copyCtx.drawImage(params.canvas,rect.left,rect.top,w,h, 0,0,w,h);
|
31 | | -
|
32 | | - for (var y=0;y<h;y+=blockSize) {
|
33 | | - for (var x=0;x<w;x+=blockSize) {
|
34 | | - pixelCtx.drawImage(copy, x, y, blockSize, blockSize, 0, 0, 1, 1);
|
35 | | - var data = pixelCtx.getImageData(0,0,1,1).data;
|
36 | | - ctx.fillStyle = "rgb(" + data[0] + "," + data[1] + "," + data[2] + ")";
|
37 | | - ctx.fillRect(rect.left + x, rect.top + y, blockSize, blockSize);
|
38 | | - }
|
39 | | - }
|
40 | | -
|
41 | | - params.useData = false;
|
42 | | -
|
43 | | - return true;
|
44 | | - }
|
45 | | - },
|
46 | | - checkSupport : function() {
|
47 | | - return (Pixastic.Client.hasCanvasImageData());
|
48 | | - }
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Mosaic filter - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.mosaic = { |
| 9 | + |
| 10 | + process : function(params) { |
| 11 | + var blockSize = Math.max(1,parseInt(params.options.blockSize,10)); |
| 12 | + |
| 13 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 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 | + |
| 20 | + var ctx = params.canvas.getContext("2d"); |
| 21 | + |
| 22 | + var pixel = document.createElement("canvas"); |
| 23 | + pixel.width = pixel.height = 1; |
| 24 | + var pixelCtx = pixel.getContext("2d"); |
| 25 | + |
| 26 | + var copy = document.createElement("canvas"); |
| 27 | + copy.width = w; |
| 28 | + copy.height = h; |
| 29 | + var copyCtx = copy.getContext("2d"); |
| 30 | + copyCtx.drawImage(params.canvas,rect.left,rect.top,w,h, 0,0,w,h); |
| 31 | + |
| 32 | + for (var y=0;y<h;y+=blockSize) { |
| 33 | + for (var x=0;x<w;x+=blockSize) { |
| 34 | + pixelCtx.drawImage(copy, x, y, blockSize, blockSize, 0, 0, 1, 1); |
| 35 | + var data = pixelCtx.getImageData(0,0,1,1).data; |
| 36 | + ctx.fillStyle = "rgb(" + data[0] + "," + data[1] + "," + data[2] + ")"; |
| 37 | + ctx.fillRect(rect.left + x, rect.top + y, blockSize, blockSize); |
| 38 | + } |
| 39 | + } |
| 40 | + |
| 41 | + params.useData = false; |
| 42 | + |
| 43 | + return true; |
| 44 | + } |
| 45 | + }, |
| 46 | + checkSupport : function() { |
| 47 | + return (Pixastic.Client.hasCanvasImageData()); |
| 48 | + } |
49 | 49 | } |
\ No newline at end of file |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/mosaic.js |
___________________________________________________________________ |
Added: svn:eol-style |
50 | 50 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/noise.js |
— | — | @@ -1,73 +1,73 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Noise filter - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.noise = {
|
9 | | -
|
10 | | - process : function(params) {
|
11 | | - var amount = 0;
|
12 | | - var strength = 0;
|
13 | | - var mono = false;
|
14 | | -
|
15 | | - if (typeof params.options.amount != "undefined")
|
16 | | - amount = parseFloat(params.options.amount)||0;
|
17 | | - if (typeof params.options.strength != "undefined")
|
18 | | - strength = parseFloat(params.options.strength)||0;
|
19 | | - if (typeof params.options.mono != "undefined")
|
20 | | - mono = !!(params.options.mono);
|
21 | | -
|
22 | | - amount = Math.max(0,Math.min(1,amount));
|
23 | | - strength = Math.max(0,Math.min(1,strength));
|
24 | | -
|
25 | | - var noise = 128 * strength;
|
26 | | - var noise2 = noise / 2;
|
27 | | -
|
28 | | - if (Pixastic.Client.hasCanvasImageData()) {
|
29 | | - var data = Pixastic.prepareData(params);
|
30 | | - var rect = params.options.rect;
|
31 | | - var w = rect.width;
|
32 | | - var h = rect.height;
|
33 | | - var w4 = w*4;
|
34 | | - var y = h;
|
35 | | - var random = Math.random;
|
36 | | -
|
37 | | - do {
|
38 | | - var offsetY = (y-1)*w4;
|
39 | | - var x = w;
|
40 | | - do {
|
41 | | - var offset = offsetY + (x-1)*4;
|
42 | | - if (random() < amount) {
|
43 | | - if (mono) {
|
44 | | - var pixelNoise = - noise2 + random() * noise;
|
45 | | - var r = data[offset] + pixelNoise;
|
46 | | - var g = data[offset+1] + pixelNoise;
|
47 | | - var b = data[offset+2] + pixelNoise;
|
48 | | - } else {
|
49 | | - var r = data[offset] - noise2 + (random() * noise);
|
50 | | - var g = data[offset+1] - noise2 + (random() * noise);
|
51 | | - var b = data[offset+2] - noise2 + (random() * noise);
|
52 | | - }
|
53 | | -
|
54 | | - if (r < 0 ) r = 0;
|
55 | | - if (g < 0 ) g = 0;
|
56 | | - if (b < 0 ) b = 0;
|
57 | | - if (r > 255 ) r = 255;
|
58 | | - if (g > 255 ) g = 255;
|
59 | | - if (b > 255 ) b = 255;
|
60 | | -
|
61 | | - data[offset] = r;
|
62 | | - data[offset+1] = g;
|
63 | | - data[offset+2] = b;
|
64 | | - }
|
65 | | - } while (--x);
|
66 | | - } while (--y);
|
67 | | - return true;
|
68 | | - }
|
69 | | - },
|
70 | | - checkSupport : function() {
|
71 | | - return Pixastic.Client.hasCanvasImageData();
|
72 | | - }
|
73 | | -}
|
74 | | -
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Noise filter - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.noise = { |
| 9 | + |
| 10 | + process : function(params) { |
| 11 | + var amount = 0; |
| 12 | + var strength = 0; |
| 13 | + var mono = false; |
| 14 | + |
| 15 | + if (typeof params.options.amount != "undefined") |
| 16 | + amount = parseFloat(params.options.amount)||0; |
| 17 | + if (typeof params.options.strength != "undefined") |
| 18 | + strength = parseFloat(params.options.strength)||0; |
| 19 | + if (typeof params.options.mono != "undefined") |
| 20 | + mono = !!(params.options.mono); |
| 21 | + |
| 22 | + amount = Math.max(0,Math.min(1,amount)); |
| 23 | + strength = Math.max(0,Math.min(1,strength)); |
| 24 | + |
| 25 | + var noise = 128 * strength; |
| 26 | + var noise2 = noise / 2; |
| 27 | + |
| 28 | + if (Pixastic.Client.hasCanvasImageData()) { |
| 29 | + var data = Pixastic.prepareData(params); |
| 30 | + var rect = params.options.rect; |
| 31 | + var w = rect.width; |
| 32 | + var h = rect.height; |
| 33 | + var w4 = w*4; |
| 34 | + var y = h; |
| 35 | + var random = Math.random; |
| 36 | + |
| 37 | + do { |
| 38 | + var offsetY = (y-1)*w4; |
| 39 | + var x = w; |
| 40 | + do { |
| 41 | + var offset = offsetY + (x-1)*4; |
| 42 | + if (random() < amount) { |
| 43 | + if (mono) { |
| 44 | + var pixelNoise = - noise2 + random() * noise; |
| 45 | + var r = data[offset] + pixelNoise; |
| 46 | + var g = data[offset+1] + pixelNoise; |
| 47 | + var b = data[offset+2] + pixelNoise; |
| 48 | + } else { |
| 49 | + var r = data[offset] - noise2 + (random() * noise); |
| 50 | + var g = data[offset+1] - noise2 + (random() * noise); |
| 51 | + var b = data[offset+2] - noise2 + (random() * noise); |
| 52 | + } |
| 53 | + |
| 54 | + if (r < 0 ) r = 0; |
| 55 | + if (g < 0 ) g = 0; |
| 56 | + if (b < 0 ) b = 0; |
| 57 | + if (r > 255 ) r = 255; |
| 58 | + if (g > 255 ) g = 255; |
| 59 | + if (b > 255 ) b = 255; |
| 60 | + |
| 61 | + data[offset] = r; |
| 62 | + data[offset+1] = g; |
| 63 | + data[offset+2] = b; |
| 64 | + } |
| 65 | + } while (--x); |
| 66 | + } while (--y); |
| 67 | + return true; |
| 68 | + } |
| 69 | + }, |
| 70 | + checkSupport : function() { |
| 71 | + return Pixastic.Client.hasCanvasImageData(); |
| 72 | + } |
| 73 | +} |
| 74 | + |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/noise.js |
___________________________________________________________________ |
Added: svn:eol-style |
75 | 75 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/flipv.js |
— | — | @@ -1,33 +1,33 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Vertical flip - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.flipv = {
|
9 | | - process : function(params) {
|
10 | | - if (Pixastic.Client.hasCanvas()) {
|
11 | | - var rect = params.options.rect;
|
12 | | - var copyCanvas = document.createElement("canvas");
|
13 | | - copyCanvas.width = rect.width;
|
14 | | - copyCanvas.height = rect.height;
|
15 | | - copyCanvas.getContext("2d").drawImage(params.image, rect.left, rect.top, rect.width, rect.height, 0, 0, rect.width, rect.height);
|
16 | | -
|
17 | | - var ctx = params.canvas.getContext("2d");
|
18 | | - ctx.clearRect(rect.left, rect.top, rect.width, rect.height);
|
19 | | - ctx.scale(1,-1);
|
20 | | - ctx.drawImage(copyCanvas, rect.left, -rect.top-rect.height, rect.width, rect.height)
|
21 | | - params.useData = false;
|
22 | | -
|
23 | | - return true;
|
24 | | -
|
25 | | - } else if (Pixastic.Client.isIE()) {
|
26 | | - params.image.style.filter += " flipv";
|
27 | | - return true;
|
28 | | - }
|
29 | | - },
|
30 | | - checkSupport : function() {
|
31 | | - return (Pixastic.Client.hasCanvas() || Pixastic.Client.isIE());
|
32 | | - }
|
33 | | -}
|
34 | | -
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Vertical flip - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.flipv = { |
| 9 | + process : function(params) { |
| 10 | + if (Pixastic.Client.hasCanvas()) { |
| 11 | + var rect = params.options.rect; |
| 12 | + var copyCanvas = document.createElement("canvas"); |
| 13 | + copyCanvas.width = rect.width; |
| 14 | + copyCanvas.height = rect.height; |
| 15 | + copyCanvas.getContext("2d").drawImage(params.image, rect.left, rect.top, rect.width, rect.height, 0, 0, rect.width, rect.height); |
| 16 | + |
| 17 | + var ctx = params.canvas.getContext("2d"); |
| 18 | + ctx.clearRect(rect.left, rect.top, rect.width, rect.height); |
| 19 | + ctx.scale(1,-1); |
| 20 | + ctx.drawImage(copyCanvas, rect.left, -rect.top-rect.height, rect.width, rect.height) |
| 21 | + params.useData = false; |
| 22 | + |
| 23 | + return true; |
| 24 | + |
| 25 | + } else if (Pixastic.Client.isIE()) { |
| 26 | + params.image.style.filter += " flipv"; |
| 27 | + return true; |
| 28 | + } |
| 29 | + }, |
| 30 | + checkSupport : function() { |
| 31 | + return (Pixastic.Client.hasCanvas() || Pixastic.Client.isIE()); |
| 32 | + } |
| 33 | +} |
| 34 | + |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/flipv.js |
___________________________________________________________________ |
Added: svn:eol-style |
35 | 35 | + native |
Index: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/blurfast.js |
— | — | @@ -1,81 +1,81 @@ |
2 | | -/*
|
3 | | - * Pixastic Lib - Blur Fast - v0.1.0
|
4 | | - * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
|
5 | | - * MIT License [http://www.opensource.org/licenses/mit-license.php]
|
6 | | - */
|
7 | | -
|
8 | | -Pixastic.Actions.blurfast = {
|
9 | | - process : function(params) {
|
10 | | -
|
11 | | - var amount = parseFloat(params.options.amount)||0;
|
12 | | -
|
13 | | - amount = Math.max(0,Math.min(5,amount));
|
14 | | -
|
15 | | - if (Pixastic.Client.hasCanvas()) {
|
16 | | - var rect = params.options.rect;
|
17 | | -
|
18 | | - var ctx = params.canvas.getContext("2d");
|
19 | | - ctx.save();
|
20 | | - ctx.beginPath();
|
21 | | - ctx.moveTo(rect.left,rect.top);
|
22 | | - ctx.lineTo(rect.left+rect.width,rect.top);
|
23 | | - ctx.lineTo(rect.left+rect.width,rect.top+rect.height);
|
24 | | - ctx.lineTo(rect.left,rect.top+rect.height);
|
25 | | - ctx.lineTo(rect.left,rect.top);
|
26 | | - ctx.closePath();
|
27 | | - ctx.clip();
|
28 | | -
|
29 | | - var scale = 2;
|
30 | | - var smallWidth = Math.round(params.width / scale);
|
31 | | - var smallHeight = Math.round(params.height / scale);
|
32 | | -
|
33 | | - var copy = document.createElement("canvas");
|
34 | | - copy.width = smallWidth;
|
35 | | - copy.height = smallHeight;
|
36 | | -
|
37 | | - var clear = true;
|
38 | | - var steps = Math.round(amount * 20);
|
39 | | -
|
40 | | - var copyCtx = copy.getContext("2d");
|
41 | | - for (var i=0;i<steps;i++) {
|
42 | | - var scaledWidth = Math.max(1,Math.round(smallWidth - i));
|
43 | | - var scaledHeight = Math.max(1,Math.round(smallHeight - i));
|
44 | | -
|
45 | | - copyCtx.clearRect(0,0,smallWidth,smallHeight);
|
46 | | -
|
47 | | - copyCtx.drawImage(
|
48 | | - params.canvas,
|
49 | | - 0,0,params.width,params.height,
|
50 | | - 0,0,scaledWidth,scaledHeight
|
51 | | - );
|
52 | | -
|
53 | | - if (clear)
|
54 | | - ctx.clearRect(rect.left,rect.top,rect.width,rect.height);
|
55 | | -
|
56 | | - ctx.drawImage(
|
57 | | - copy,
|
58 | | - 0,0,scaledWidth,scaledHeight,
|
59 | | - 0,0,params.width,params.height
|
60 | | - );
|
61 | | - }
|
62 | | -
|
63 | | - ctx.restore();
|
64 | | -
|
65 | | - params.useData = false;
|
66 | | - return true;
|
67 | | - } else if (Pixastic.Client.isIE()) {
|
68 | | - var radius = 10 * amount;
|
69 | | - params.image.style.filter += " progid:DXImageTransform.Microsoft.Blur(pixelradius=" + radius + ")";
|
70 | | -
|
71 | | - if (params.options.fixMargin || 1) {
|
72 | | - params.image.style.marginLeft = (parseInt(params.image.style.marginLeft,10)||0) - Math.round(radius) + "px";
|
73 | | - params.image.style.marginTop = (parseInt(params.image.style.marginTop,10)||0) - Math.round(radius) + "px";
|
74 | | - }
|
75 | | -
|
76 | | - return true;
|
77 | | - }
|
78 | | - },
|
79 | | - checkSupport : function() {
|
80 | | - return (Pixastic.Client.hasCanvas() || Pixastic.Client.isIE());
|
81 | | - }
|
82 | | -}
|
| 2 | +/* |
| 3 | + * Pixastic Lib - Blur Fast - v0.1.0 |
| 4 | + * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/ |
| 5 | + * MIT License [http://www.opensource.org/licenses/mit-license.php] |
| 6 | + */ |
| 7 | + |
| 8 | +Pixastic.Actions.blurfast = { |
| 9 | + process : function(params) { |
| 10 | + |
| 11 | + var amount = parseFloat(params.options.amount)||0; |
| 12 | + |
| 13 | + amount = Math.max(0,Math.min(5,amount)); |
| 14 | + |
| 15 | + if (Pixastic.Client.hasCanvas()) { |
| 16 | + var rect = params.options.rect; |
| 17 | + |
| 18 | + var ctx = params.canvas.getContext("2d"); |
| 19 | + ctx.save(); |
| 20 | + ctx.beginPath(); |
| 21 | + ctx.moveTo(rect.left,rect.top); |
| 22 | + ctx.lineTo(rect.left+rect.width,rect.top); |
| 23 | + ctx.lineTo(rect.left+rect.width,rect.top+rect.height); |
| 24 | + ctx.lineTo(rect.left,rect.top+rect.height); |
| 25 | + ctx.lineTo(rect.left,rect.top); |
| 26 | + ctx.closePath(); |
| 27 | + ctx.clip(); |
| 28 | + |
| 29 | + var scale = 2; |
| 30 | + var smallWidth = Math.round(params.width / scale); |
| 31 | + var smallHeight = Math.round(params.height / scale); |
| 32 | + |
| 33 | + var copy = document.createElement("canvas"); |
| 34 | + copy.width = smallWidth; |
| 35 | + copy.height = smallHeight; |
| 36 | + |
| 37 | + var clear = true; |
| 38 | + var steps = Math.round(amount * 20); |
| 39 | + |
| 40 | + var copyCtx = copy.getContext("2d"); |
| 41 | + for (var i=0;i<steps;i++) { |
| 42 | + var scaledWidth = Math.max(1,Math.round(smallWidth - i)); |
| 43 | + var scaledHeight = Math.max(1,Math.round(smallHeight - i)); |
| 44 | + |
| 45 | + copyCtx.clearRect(0,0,smallWidth,smallHeight); |
| 46 | + |
| 47 | + copyCtx.drawImage( |
| 48 | + params.canvas, |
| 49 | + 0,0,params.width,params.height, |
| 50 | + 0,0,scaledWidth,scaledHeight |
| 51 | + ); |
| 52 | + |
| 53 | + if (clear) |
| 54 | + ctx.clearRect(rect.left,rect.top,rect.width,rect.height); |
| 55 | + |
| 56 | + ctx.drawImage( |
| 57 | + copy, |
| 58 | + 0,0,scaledWidth,scaledHeight, |
| 59 | + 0,0,params.width,params.height |
| 60 | + ); |
| 61 | + } |
| 62 | + |
| 63 | + ctx.restore(); |
| 64 | + |
| 65 | + params.useData = false; |
| 66 | + return true; |
| 67 | + } else if (Pixastic.Client.isIE()) { |
| 68 | + var radius = 10 * amount; |
| 69 | + params.image.style.filter += " progid:DXImageTransform.Microsoft.Blur(pixelradius=" + radius + ")"; |
| 70 | + |
| 71 | + if (params.options.fixMargin || 1) { |
| 72 | + params.image.style.marginLeft = (parseInt(params.image.style.marginLeft,10)||0) - Math.round(radius) + "px"; |
| 73 | + params.image.style.marginTop = (parseInt(params.image.style.marginTop,10)||0) - Math.round(radius) + "px"; |
| 74 | + } |
| 75 | + |
| 76 | + return true; |
| 77 | + } |
| 78 | + }, |
| 79 | + checkSupport : function() { |
| 80 | + return (Pixastic.Client.hasCanvas() || Pixastic.Client.isIE()); |
| 81 | + } |
| 82 | +} |
Property changes on: trunk/extensions/MetavidWiki/skins/mv_embed/libClipEdit/pixastic-lib/actions/blurfast.js |
___________________________________________________________________ |
Added: svn:eol-style |
83 | 83 | + native |