[英]how to pull Line/Polygon by one of the points in kineticjs?
Some part of my code here : 我的代码的一部分在这里 :
var stage = new Kinetic.Stage({
container: "canvas",
width: 300,
height: 200
});
var layer = new Kinetic.Layer({
});
var line = new Kinetic.Polygon({
id: 'wall',
points: [50, 50, 100, 50, 100, 100, 50, 100],
stroke: "black",
strokeWidth: 4,
draggable: true
});
line.on('dragmove', function(mouseEvent) {
line.getPoints()[2] = {x:mouseEvent.x, y:mouseEvent.y};
layer.draw();
});
stage.add(layer);
layer.add(line);
layer.draw();
The task is to drag polygon by one of the corners (in example by right-bottom). 任务是通过其中一个角(例如右下角)拖动多边形。 But actually result is not that I expected. 但实际上结果并不是我所期待的。 What is wrong in my code? 我的代码有什么问题? or what is correct way of moving elemten by one of the points? 或者通过其中一个点移动elemten的正确方法是什么?
Check out this post iOS6 pull/drag border on circle 看看这篇帖子iOS6拉/拖边界
The effects are similar, I think, to what you're looking for. 我认为,效果与您正在寻找的相似。 You could animate the drag on any of your corners by detecting the click/touch location. 您可以通过检测单击/触摸位置为任何角上的拖动设置动画。
Let me know if you need another example. 如果您需要另一个例子,请告诉我。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.