topical media & game development
graphic-canvas-util-pixastic-actions-flipv.js / js
/*
* Pixastic Lib - Vertical flip - v0.1.0
* Copyright (c) 2008 Jacob Seidelin, jseidelin@nihilogic.dk, http://blog.nihilogic.dk/
* MIT License [http://www.opensource.org/licenses/mit-license.php]
*/
Pixastic.Actions.flipv = {
process : function(params) {
if (Pixastic.Client.hasCanvas()) {
var rect = params.options.rect;
var copyCanvas = document.createElement("canvas");
copyCanvas.width = rect.width;
copyCanvas.height = rect.height;
copyCanvas.getContext("2d").drawImage(params.image, rect.left, rect.top, rect.width, rect.height, 0, 0, rect.width, rect.height);
var ctx = params.canvas.getContext("2d");
ctx.clearRect(rect.left, rect.top, rect.width, rect.height);
ctx.scale(1,-1);
ctx.drawImage(copyCanvas, rect.left, -rect.top-rect.height, rect.width, rect.height)
params.useData = false;
return true;
} else if (Pixastic.Client.isIE()) {
params.image.style.filter += " flipv";
return true;
}
},
checkSupport : function() {
return (Pixastic.Client.hasCanvas() || Pixastic.Client.isIE());
}
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.