// This is a set of tools similar to the pencil, paintbrush and // eraser tools in NIH Image. The pencil and paintbrush draw // in the current foreground color and the eraser draws in the // current background color. Hold down the alt key to have the // pencil and paintbrush draw in the background color. The // foreground and background colors can be set by double- // clicking on the eye dropper tool. Double-click on a tool icon // to set the drawing width. // // Rename as "StartupMacros.txt" and move to the macros folder // to have these tools automatically loaded when ImageJ starts. // // The icons were contributed by Tony Collins. var pencilWidth=1, brushWidth=10, eraserWidth=10, leftClick=16, alt=8; var sprayWidth = 50; var dotSize = 1; macro "Unused Tool-1 - " {} // leave slot between text tool and magnifying glass unused macro "Unused Tool-2 - " {} // leave slot between dropper and pencil unused macro "Pencil Tool - C059L494fL4990L90b0Lc1c3L82a4Lb58bL7c4fDb4L5a5dL6b6cD7b" { getCursorLoc(x, y, z, flags); if (flags&alt!=0) setColorToBackgound(); draw(pencilWidth); } macro "Paintbrush Tool - C037F6036F3699CfffD71F4771D5eD7eD9e" { getCursorLoc(x, y, z, flags); if (flags&alt!=0) setColorToBackgound(); draw(brushWidth); } macro "Eraser Tool - C037R0aa4 P0a61f1aa0Pbef5f1" { setColorToBackgound(); draw(eraserWidth); } function draw(width) { requires("1.32g"); setupUndo(); // requires 1.32g getCursorLoc(x, y, z, flags); setLineWidth(width); moveTo(x,y); x2=-1; y2=-1; while (true) { getCursorLoc(x, y, z, flags); if (flags&leftClick==0) exit(); if (x!=x2 || y!=y2) lineTo(x,y); x2=x; y2 =y; wait(10); } } function setColorToBackgound() { save = getPixel(0, 0); makeRectangle(0, 0, 1, 1); run("Clear"); background = getPixel(0, 0); run("Select None"); setPixel(0, 0, save); setColor( background); } // ImageJ runs this macro when user double-clicks on the pencil tool icon macro 'Pencil Tool Options' { pencilWidth = getNumber("Pencil Width:", pencilWidth); } // ImageJ runs this macro when user double-clicks on the paint brush tool icon macro 'Paintbrush Tool Options' { brushWidth = getNumber("Brush Width:", brushWidth); } // ImageJ runs this macro when user double-clicks on the eraser tool icon macro 'Eraser Tool Options' { eraserWidth = getNumber("Eraser Width:", eraserWidth); } // This is a tool macro similar to the spray can tool in NIH Image. // Double-click on the tool icon to set the spray width and dot size. macro 'Spray Can Tool-Cb00Fad33F2233Fa133F2a33Fe733F8733' { requires("1.30k"); setLineWidth(dotSize); radius=sprayWidth/2; radius2=radius*radius; start = getTime(); autoUpdate(false); while (true) { getCursorLoc(x, y, z, flags); if (flags&16==0) exit(); x2 = (random()-0.5)*sprayWidth; y2 = (random()-0.5)*sprayWidth; if (x2*x2+y2*y2start+50) { updateDisplay(); start = getTime(); } } wait(1); } } // ImageJ runs this macro when user double-clicks on the tool icon macro 'Spray Can Tool Options' { sprayWidth = getNumber("Spray Width:", sprayWidth); dotSize = getNumber("Dot Size:", dotSize); }