在.js文件中围绕其底部中心旋转png图像

时间:2012-07-19 23:53:10

标签: javascript image png rotation image-rotation

首先,让我快速解释为什么我提出这个问题,尽管这里有类似的问题: Canvas rotate from bottom center image angle?

到目前为止,我所看到的所有信息都与嵌入在html标记中的javascript有关。我不知道这些信息对于比我更有经验的人来说是否足够,但我知道javascript和html很少。不过,我对很多脚本语言都有一点经验。

我的问题是我有一个带有对象的.js文件,我将i.image设置为来自url的png图像(比如example.com/pic.png)。我想添加几行代码,首先将图像旋转x度或弧度(我不关心哪个,我总是可以转换),然后将其设置为i.image。所以: 图像=“example.com/pic.png”; i.image = MagicRotateFunction(图像,45);

我根本不知道MagicRotateFunction会是什么。

1 个答案:

答案 0 :(得分:0)

如果您对.js文件中的CSS转换感兴趣,请尝试:

i.src = "http://maps.google.com/mapfiles/marker.png";
i.style.WebkitTransform = "rotate(45deg)";
i.style.MozTransform = "rotate(45deg)";
i.style.OTransform = "rotate(45deg)";
i.style.msTransform = "rotate(45deg)";
i.style.transform = "rotate(45deg)";

来源: