【问题标题】:Canvas Image editor画布图像编辑器
【发布时间】:2012-02-26 15:22:15
【问题描述】:

我正在尝试使用画布制作图像编辑器,但在调整旋转图像的大小时遇到​​了一些问题。我重新调整大小的锚点和图像似乎没有按应有的方式排列。

http://jsbin.com/isexig/9/edit#source

(点击图片会旋转,只是为了测试调整大小)

任何线索如何解决这个问题?

我发现角度需要除以 pi,但我无法让 bl 工作,并且锚点仍然不能完美匹配 =/

【问题讨论】:

  • 你交换了blbr,虽然它仍然不能完全工作。
  • Index or size is negative or greater than the allowed amount (164 out of range 163) - 只需使用调试器。

标签: javascript math canvas kineticjs


【解决方案1】:

我发现组已经旋转了,包括角手柄,所以你根本不需要任何三角函数:

http://jsbin.com/abejab/5/edit

switch (activeAnchor.name) {
case "tl":
case "br":
    bl.x = tl.x;
    bl.y = br.y;
    tr.x = br.x;
    tr.y = tl.y;
    break;
case "tr":
case "bl":
    br.x = tr.x;
    br.y = bl.y;
    tl.x = bl.x;
    tl.y = tr.y;
    break;
}
image.x = tl.x;
image.y = tl.y;
image.width = tr.x - tl.x;
image.height = bl.y - tl.y;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2023-03-03
    • 2019-01-19
    • 1970-01-01
    • 2015-10-12
    • 1970-01-01
    • 2021-11-27
    • 1970-01-01
    相关资源
    最近更新 更多