Login  Register

Re: draw line center and save line size

Posted by Wayne Rasband on Jul 16, 2008; 9:07pm
URL: http://imagej.273.s1.nabble.com/draw-line-center-and-save-line-size-tp3695578p3695579.html

On Jul 16, 2008, at 7:56 AM, anairc wrote:

> Hello.
>
> I would like to know if there is any macro that can help me on the
> following
> task:
>
> I would like to have the measure of a line, each time I draw one, as
> well as
> some kind of marker of its center drawn .

Here is a macro tool that does this.

  macro "Line Length Tool -C00bL1de0L1ee1" {
         getCursorLoc(x, y, z, flags);
         xstart = x; ystart = y;
         x2=x; y2=y;
         while (true) {
             getCursorLoc(x, y, z, flags);
             if (flags&16==0) {
                 dx=x2-xstart; dy=y2-ystart;
                 if (selectionType==5) {
                    run("Measure");
                    run("Label");
                    run("Select None");
                 }
                 exit;
             }
             if (x!=x2 || y!=y2)
                 makeLine(xstart, ystart, x, y);
             x2=x; y2=y;
             wait(10);
         };
     }
  }

-wayne