这是我使用kinetic.js的代码 我绘制三条线并使用鼠标移动。
$(document).ready(function(){
var y1=50;
var stage = new Kinetic.Stage({
container: "container",
width: 578,
height: 200
});
var layer = new Kinetic.Layer();
var group=new Kinetic.Group({
draggable: true,
dragConstraint : 'horizontal'
});
var lineme =function(pts){
var line1 = new Kinetic.Line({
points: pts,
stroke: "black",
strokeWidth: 4,
lineCap: 'round',
lineJoin: 'round',
});
group.add(line1);
}
for(a=0;a<=2;a++)
{
var points1 = [{
x: 73,
y: y1
}, {
x: 300,
y: y1
}];
lineme(points1);
y1=y1+50;
}
group.on("mouseover", function(){
document.body.style.cursor = "pointer";
});
group.on("mouseout", function() {
document.body.style.cursor = "default";
});
// add the shape to the layer
layer.add(group);
// add the layer to the stage
stage.add(layer);
});
我想绘制箭头线我尝试了更多时间,但我找不到合适的解决方案。动力学中的任何箭头功能都可以帮助我吗
答案 0 :(得分:1)
您必须创建一个组并将两行添加到该组中。
检查以下示例: http://www.html5canvastutorials.com/kineticjs/html5-canvas-drag-and-drop-a-group-with-kineticjs/
希望它有所帮助!
答案 1 :(得分:0)
var line2 = .....
// add another line to the layer before adding it to the stage
layer.add(line2);
确实