Bo *_* Hu 7 javascript html5-canvas kineticjs konvajs
我想使用Konvajs来执行以下任务:
像这样的东西:
是否有任何本机方法支持形状之间的连接?有人能告诉我一些例子吗?
我已连接Konva.Circles。但是图像的逻辑也将相同。请找到笨蛋
var width = window.innerWidth;
var height = window.innerHeight;
var stage = new Konva.Stage({
container: 'container',
width: width,
height: height
});
var layer = new Konva.Layer();
var circle = new Konva.Circle({
x: stage.getWidth() / 2,
y: stage.getHeight() / 2,
radius: 40,
fill: 'green',
stroke: 'black',
strokeWidth: 2,
draggable: true
});
var circleA = new Konva.Circle({
x: stage.getWidth() / 5,
y: stage.getHeight() / 5,
radius: 30,
fill: 'red',
stroke: 'black',
strokeWidth: 2,
draggable: true
});
var arrow = new Konva.Arrow({
points: [circle.getX(), circle.getY(), circleA.getX(), circleA.getY()],
pointerLength: 10,
pointerWidth: 10,
fill: 'black',
stroke: 'black',
strokeWidth: 4
});
function adjustPoint(e){
var p=[circle.getX(), circle.getY(), circleA.getX(), circleA.getY()];
arrow.setPoints(p);
layer.draw();
}
circle.on('dragmove', adjustPoint);
circleA.on('dragmove', adjustPoint);
layer.add(circleA);
// add the shape to the layer
layer.add(circle);
layer.add(arrow);
// add the layer to the stage
stage.add(layer);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3932 次 |
| 最近记录: |