/* This is the second draft of the macro. Needs a lot more documentation. */ macro "return selection type:" { print(selectionType() ); print(toHex(1)); print(toHex(255)); h = ""; for (i=0; i<3; i++) h = h + toHex(round(16+(random()*239))); print (h); selectWindow("Log"); } //setTool("multipoint"); macro "count and mark [q]" { if (selectionType != 10) exit("requires a few points clicked"); startcount = nResults(); run("Measure"); endcount = nResults(); counted = endcount - startcount; run("Convex Hull"); run("Fit Spline"); // optional color = ""; a = newArray(3); for (i=0; i<3; i++) { a[i] = round (128+(random()*128)); color = color + toHex(a[i]); } setColor(a[0], a[1], a[2]); Overlay.addSelection(color); run("Set Measurements...", "centroid redirect=None decimal=0"); run("Measure"); x = getResult("X", nResults()-1); y = getResult("Y", nResults()-1); toUnscaled(x, y); fontSize = 20; // Border on number setFont("SansSerif", fontSize+3); setColor(0,0,0); Overlay.drawString(counted, x-1, y+3); // number same color as ROI setColor(a[0], a[1], a[2]); setFont("SansSerif", fontSize); Overlay.drawString(counted, x, y); //Overlay.addSelection(color); run("Select None"); }