Bug 20489 Configure illegal file characters https://bugzilla.wikimedia.org/show_bug...
[mediawiki.git] / js2 / mwEmbed / libClipEdit / pixastic-lib / actions / fliph.js
blob5b7b0d2775b5aeef332b932e5f42f36a620bf49e
1 /*
2  * Pixastic Lib - Horizontal flip - v0.1.0
3  * Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
4  * MIT License [http://www.opensource.org/licenses/mit-license.php]
5  */
7 Pixastic.Actions.fliph = {
8         process : function(params) {
9                 if (Pixastic.Client.hasCanvas()) {
10                         var rect = params.options.rect;
11                         var copyCanvas = document.createElement("canvas");
12                         copyCanvas.width = rect.width;
13                         copyCanvas.height = rect.height;
14                         copyCanvas.getContext("2d").drawImage(params.image, rect.left, rect.top, rect.width, rect.height, 0, 0, rect.width, rect.height);
16                         var ctx = params.canvas.getContext("2d");
17                         ctx.clearRect(rect.left, rect.top, rect.width, rect.height);
18                         ctx.scale(-1,1);
19                         ctx.drawImage(copyCanvas, -rect.left-rect.width, rect.top, rect.width, rect.height)
20                         params.useData = false;
22                         return true;            
24                 } else if (Pixastic.Client.isIE()) {
25                         params.image.style.filter += " fliph";
26                         return true;
27                 }
28         },
29         checkSupport : function() {
30                 return (Pixastic.Client.hasCanvas() || Pixastic.Client.isIE());
31         }