簡體   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