// This macro converts an overlay or selection in a 16x16 image into // a tool icon. Type "1" to create a 16x16 image. Type "b" to add a // selection to the overlay. Type "y" to display the Properties dialog, // where you can set the selection's outline or fill colors. Press "2" // to convert the overlay or selection into a tool icon. Press "3" to // remove the overlay. convertOverlayToIcon(); exit; macro "New Image [1]" { newImage("Untitled", "8-bit black", 16, 16, 1); run("In [+]"); run("In [+]"); run("In [+]"); run("In [+]"); run("In [+]"); run("In [+]"); run("In [+]"); run("In [+]"); run("In [+]"); } macro "Convert [2]" { convertOverlayToIcon(); } macro "Remove Overlay [3]" { run("Remove Overlay"); } function convertOverlayToIcon() { requires("1.48j"); if (getWidth>17 || getHeight>17) exit("Image cannot be larger then 17x17"); if (Overlay.size==0 && selectionType==-1) exit("Overlay or selection required"); icon = ""; if (Overlay.size>0) { for (i=0; imax) n=max; c = "0"; if (n<16) c = toHex(n); else if (n==16) c = "g"; else if (n==17) c = "h"; String.append(c); } function color(c) { r = call("ij.plugin.Colors.getRed", c); g = call("ij.plugin.Colors.getGreen", c); b = call("ij.plugin.Colors.getBlue", c); r=parseInt(r); g=parseInt(g); b=parseInt(b); String.append("C"); hex(floor(r/16)); hex(floor(g/16)); hex(floor(b/16)); }