1 Reply Latest reply on Nov 16, 2015 8:44 PM by BSKTCreation

    How to draw cross line?

    K159 Level 1

        <- Cross Line

       

      Hi.

       

      I want to draw cross line using JavaScript.

       

       

       

       

      I can draw this line.

      app.activeDocument.graphicLines.add(undefined, undefined, undefined,{geometricBounds:[100,100,300,300]})

       

       

       

      but I can't draw this line.

      I tried to "geometricBounds:[300,100,100,300] and [100,300,100,300]" but it was not drawn.

       

       

       

      I tried to apply the transform option but line has moved.

       

      It is moving again, but I want to simply left and right reversal .

       

      Any ideas?

       

      Thanks.

        • 1. Re: How to draw cross line?
          BSKTCreation Level 2

          Hi there,

           

          Try this out.

           

          var myLine = [];
          
          
          for (var j = 1; j <= 2; j++) {
                  myLine[j] = app.activeDocument.graphicLines.add();
                  myLine[j].strokeColor = app.activeDocument.colors.item("Black");
                  myLine[j].strokeWeight = 0.75;
                  }
          
          
          plotStraightLine(myLine[1], 100, 100, 200, 200);
          plotStraightLine(myLine[2], 200, 100, 100, 200);
          
          
          function plotStraightLine(obj, x1, y1, x2, y2) {
              obj.paths.item(0).pathPoints.item(0).anchor = [x1, y1];
              obj.paths.item(0).pathPoints.item(1).anchor = [x2, y2];
              }