所以我想使用CamanJS插件创建一个基于web的图像编辑器,它被证明是非常棒的,但我需要创建一个水平翻转函数,结果发现CamanJS没有这样的方法,我正在考虑将画布翻转到相机外面,并像这样重新加载它
context.translate(imageWidth / 2, imageHeight / 2);
context.scale(-1, 1);
context.drawImage(imageObj, - imageWidth / 2, - imageHeight / 2, imageWidth, imageHeight);
caman.reloadCanvasData();但什么都没发生,有人能帮上忙吗?
发布于 2014-02-04 20:37:06
下面是flip插件可能的样子:
Caman.Plugin.register("flip", function () {
var canvas, ctx;
var width = this.canvas.width;
var height = this.canvas.height;
// Support NodeJS by checking for exports object
if (typeof exports !== "undefined" && exports !== null) {
canvas = new Canvas(width, height);
} else {
canvas = document.createElement('canvas');
canvas.width = width;
canvas.height = height;
}
ctx = canvas.getContext('2d');
ctx.translate(width, 0);
ctx.scale(-1, 1);
ctx.drawImage(this.canvas, 0, 0);
this.replaceCanvas(canvas);
return this;
});
Caman.Filter.register("flip", function () {
return this.processPlugin("flip");
});发布于 2013-07-29 13:22:13
如果要翻转填充画布的图像,请平移到画布的右侧。
context.translate( canvas.width,0 );
context.scale( -1,1 );
context.drawImage( imageObject,0,0 );https://stackoverflow.com/questions/17915838
复制相似问题