如何使用javascript在智能面,io IDE中旋转此图像



我需要这个图像在按下按钮时向左旋转 90 度,并在另一个按钮上向右旋转 90 度。 这是我的代码。任何帮助将不胜感激!

var pinWheel = new SMF.UI.Image({
    name :"Pin Wheel",
    image : "assets://pin_wheel.png",
    positionBackgroundImage : "CENTER",
    top : "60%",
    imageFillType: SMF.UI.ImageFillType.ASPECTFIT
});

SMF.Bitmap具有用于图像处理的静态函数。 rotate功能将帮助您解决问题。

下面是一个示例代码:

var img = new SMF.UI.Image({
  name: "img",
  image: "smartface.png",
  left: "15%",
  top: "20%",
  width: "70%",
  height: "10%",
  imageFillType: SMF.UI.ImageFillType.ASPECTFIT
});
var btn = new SMF.UI.TextButton({
  name: "btn",
  text: "Rotate!",
  onPressed: function() {
    var myImageUri = "smartface.png";
    var im = new SMF.Bitmap({
      imageUri: myImageUri,
      onSuccess: function(e) {
        im.rotate({
          angle: 90,
          format: SMF.ImageFormat.PNG,
          compressionRate: 0.7,
          onSuccess: function(e) {
            img.image = e.image;
          },
          onError: function(e) {
            alert("Error: " + e.message);
          }
        });
      },
      onError: function(e) {
        alert("Error: " + e.message);
      }
    });
  },
  left: "15%",
  top: "70%",
  width: "70%",
  height: "10%"
});

最新更新