Skip to content

Instantly share code, notes, and snippets.

@mutterer
Last active December 25, 2015 01:58

Revisions

  1. mutterer revised this gist Oct 12, 2013. 1 changed file with 13 additions and 5 deletions.
    18 changes: 13 additions & 5 deletions LineAndProfileTool.txt
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    // This tool draws a line, and overlays its profile.

    // This tool draws a line, and overlays its profile and some infos
     
    macro "Line and Profile Tool -C00bL1de0L1ee1" {
    getCursorLoc(x, y, z, flags);
    xstart = x; ystart = y;
    @@ -15,15 +15,22 @@
    overlayProfile(xstart, ystart, x, y);
    }
    x2=x; y2=y;
    wait(50);
    wait(10);
    };
    }
    }

     
    function overlayProfile(xa,ya,xb,yb) {
    Overlay.remove;
    p = getProfile();
    Array.getStatistics(p, min, max, mean, stdDev);
    List.setMeasurements;
    text = 'Length:'+d2s(List.getValue('Length'),2)+'\nmin:'+d2s(min,2)+'\nmax:'+d2s(max,2);
    setFont('SanSerif', 14, 'bold antialiased');
    setColor('black');
    Overlay.drawString(text, 10-1, 20-1);
    setColor('cyan');
    Overlay.drawString(text, 10, 20);
    Overlay.moveTo(xa, ya);
    setColor('green');
    setLineWidth(2);
    @@ -36,4 +43,5 @@ function overlayProfile(xa,ya,xb,yb) {
    }
    Overlay.lineTo(xb, yb);
    Overlay.show;
    }

    }
  2. mutterer revised this gist Oct 9, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion LineAndProfileTool.txt
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    // This tool draws a line, and overlays it's profile.
    // This tool draws a line, and overlays its profile.

    macro "Line and Profile Tool -C00bL1de0L1ee1" {
    getCursorLoc(x, y, z, flags);
  3. mutterer renamed this gist Oct 9, 2013. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  4. mutterer created this gist Oct 9, 2013.
    39 changes: 39 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,39 @@
    // This tool draws a line, and overlays it's profile.

    macro "Line and Profile 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;
    exit;
    }
    if (x!=x2 || y!=y2) {
    makeLine(xstart, ystart, x, y);
    overlayProfile(xstart, ystart, x, y);
    }
    x2=x; y2=y;
    wait(50);
    };
    }
    }

    function overlayProfile(xa,ya,xb,yb) {
    Overlay.remove;
    p = getProfile();
    Array.getStatistics(p, min, max, mean, stdDev);
    Overlay.moveTo(xa, ya);
    setColor('green');
    setLineWidth(2);
    for (i=0;i<p.length;i++) {
    xs = (xb-xa)/p.length;
    ys = (ya-yb)/p.length;
    d = 100-100*p[i]/max;
    a = atan ((yb-ya)/(xb-xa));
    Overlay.lineTo(xa+i*xs-d*sin(a), ya-i*ys+d*cos(a));
    }
    Overlay.lineTo(xb, yb);
    Overlay.show;
    }