简体   繁体   中英

moving more than two arrow lines on canvas

This is my code using kinetic.js I draw three lines and move using mouse.

$(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);

 });

I want to draw arrow line I tried more time but I cant find out the proper solution. Is their any arrow function in kinetic js can anyone help me

You have to create a group and add both lines to the group.

Check the following example: http://www.html5canvastutorials.com/kineticjs/html5-canvas-drag-and-drop-a-group-with-kineticjs/

Hope it helps!

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

surely?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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