Transform (Move/Scale/Rotate) shapes with KineticJS

后端 未结 3 2177
眼角桃花
眼角桃花 2021-01-01 00:43

I\'m trying to build a transform manager for KineticJS that would build a bounding box and allow users to scale, move, and rotate an image on their canvas. I\'m getting trip

3条回答
  •  南笙
    南笙 (楼主)
    2021-01-01 01:11

    Here is a proof of concept of a rotational control I've made: http://codepen.io/ArtemGr/pen/ociAD

    While the control is dragged around, the dragBoundFunc is used to rotate the content alongside it:

    controlGroup.setDragBoundFunc (function (pos) {
      var groupPos = group.getPosition()
      var rotation = degrees (angle (groupPos.x, groupPos.y, pos.x, pos.y))
      status.setText ('x: ' + pos.x + '; y: ' + pos.y + '; rotation: ' + rotation); layer.draw()
      group.setRotationDeg (rotation); layer.draw()
      return pos
    })
    

提交回复
热议问题