繁体   English   中英

在画布上移动两条以上的箭头线

[英]moving more than two arrow lines on canvas

这是我用dynamic.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);

 });

我想画箭头线,但我尝试了更多时间,但找不到合适的解决方案。 是他们在动力学js中的任何箭头功能,有人可以帮助我吗

您必须创建一个组并将两行都添加到该组。

检查以下示例: http : //www.html5canvastutorials.com/kineticjs/html5-canvas-drag-and-drop-a-group-with-kineticjs/

希望能帮助到你!

var line2 = .....
// add another line to the layer before adding it to the stage
layer.add(line2);

一定?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM