// This example uses the Toolbar.setIcon(toolName,icon) method // added in v1.53h, to dynamically update icons that track mouse // movement. To use, click on "Install" to add three tools to the // toolbar and then click and drag on the active image with the // "G" tool. // Author: Jerome Mutterer. macro "Left Eye Action Tool - N44 C48f o46ff C000 o8c55 O00nn" { setTool("Googly Eyes Tool"); } macro "Right Eye Action Tool - N44 C48f o46ff C000 o8c55 O00nn" { setTool("Googly Eyes Tool"); } macro "Googly Eyes Tool - C000T0f16G" { x0=0; y0=0; getCursorLoc(x, y, z, modifiers); while (modifiers&16>0) { getCursorLoc(x, y, z, modifiers); if (x!=x0 || y!=y0) { call("ij.gui.Toolbar.setIcon", "Left Eye Action Tool", getIcon(x)); call("ij.gui.Toolbar.setIcon", "Right Eye Action Tool", getIcon(x)); x0=x; y0=y; } wait(50); } } function getIcon(x) { blue = map(x,0,getWidth(),2,8); black = map(x,0,getWidth(),2,17); icon ="N44 C000 o00nn B11 Cfff o00ll C48f o"+h(blue)+"6ff C000 o"+h(black)+"c55"; return icon; } function map(a,in_min,in_max,out_min,out_max) { return (a - in_min) * (out_max - out_min) / (in_max - in_min) + out_min; } function h(a) { return ""+toExtHex(constrain(a,0,23)); } function toExtHex(n) { if (n>15) return fromCharCode(0x66+n-15); else return toHex(n); } function constrain(a,min,max) { if (amax) a=max; return a; }