// This is a macro version of the polygon tool. // Click in the box at the starting point, or // right-click, to finalize the polygon; // This macro requires ImageJ 1.45n or later. macro "Polygon Tool -C00bB12P51f1f2b6b7eafb1b151451" { requires("1.45n"); toolName = IJ.getToolName(); size = 6/getZoom; x = newArray(2000); y = newArray(2000); getCursorLoc(x2, y2, z2, flags); x[0] = x2; y[0] = y2; x[1] = x2; y[1] = y2; n = 2; setOption("DisablePopupMenu", true); Overlay.drawRect(x[0]-size, y[0]-size, size*2, size*2); Overlay.show; while (flags&20!=0) // left and right click getCursorLoc(x2, y2, z2, flags); while (true) { getCursorLoc(x2, y2, z2, flags); if (flags&20!=0) { modKey = flags&14!=0; //right-click, control or alt while (flags&16!=0) getCursorLoc(x2, y2, z2, flags); inBox = x2>x[0]-size&&xy[0]-size&&y2