HTML5 Konva Class reposition
我试图拖动一个圆圈并重新定位一条线
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | var circle = new Konva.Circle({ x : xx, y : yy, radius : radius, fill :"#F49342", stroke :"#ED6347", draggable :"true" }); var line = new Konva.Line({ points: [23,23,35,35], stroke: 'black', strokeWidth: 2, lineCap: 'round', lineJoin: 'round' }); |
如何通过拖动圆圈来改变线的位置?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | circle.on('dragmove', () => { // copy old points const points = line.points().concat(); // move points points[0] = circle.x(); points[1] = circle.y(); line.points(points); // OR you can change line position: line.position(circle.position()); line.getLayer().batchDraw(); }) |