// "StartupMacros" // The macros and macro tools in this file ("StartupMacros.txt") // are automatically installed in the Plugins>Macros submenu // and in the tool bar when ImageJ starts up. // The drawing tools are similar to the pencil, paintbrush, // flood fill (paint bucket) and spray can tools in NIH Image. The // pencil and paintbrush draw in the current foreground. The // flood fill tool fills the selected area using the foreground color. // Hold down the alt key to have the pencil and paintbrush draw // using the background color or to have the flood fill tool fill // using the background color. Set the foreground and background // colors by double-clicking on the flood fill tool or on the eye // dropper tool. Double-click on the pencil, paintbrush or spray // can tool to set the drawing width for that tool. // // Icons contributed by Tony Collins and Gabriel Landini. // Global variables var pencilWidth=1, eraserWidth=10, leftClick=16, alt=8; var brushWidth = 10; //call("ij.Prefs.get", "startup.brush", "10"); var floodType = "8-connected"; //call("ij.Prefs.get", "startup.flood", "8-connected"); // The macro named "AutoRun" runs when ImageJ starts. //macro "AutoRun" { // open("http://imagej.nih.gov/ij/images/ct.dcm.zip"); //} // The macro named "AutoRunAndHide" runs when ImageJ starts // and the file containing it is not displayed when ImageJ opens it. // macro "AutoRunAndHide" {} macro "Unused Tool-" {} var dCmds = newMenu("Developer Menu Tool", newArray("ImageJ Website","News", "ImageJ Wiki", "Resources", "Macro Language", "Macros", "Macro Functions", "Startup Macros...", "Plugins", "Source Code", "List Archives", "-", "Record...", "Capture Screen ", "Monitor Memory...", "List Commands...", "Control Panel...", "Search...", "Debug Mode")); macro "Developer Menu Tool - C037T0b11DT7b09eTcb09v" { cmd = getArgument(); if (cmd=="ImageJ Website") run("URL...", "url=http://rsbweb.nih.gov/ij/"); else if (cmd=="News") run("URL...", "url=http://rsbweb.nih.gov/ij/notes.html"); else if (cmd=="ImageJ Wiki") run("URL...", "url=http://imagejdocu.tudor.lu/imagej-documentation-wiki/"); else if (cmd=="Resources") run("URL...", "url=http://rsbweb.nih.gov/ij/developer/"); else if (cmd=="Macro Language") run("URL...", "url=http://rsbweb.nih.gov/ij/developer/macro/macros.html"); else if (cmd=="Macros") run("URL...", "url=http://rsbweb.nih.gov/ij/macros/"); else if (cmd=="Macro Functions") run("URL...", "url=http://rsbweb.nih.gov/ij/developer/macro/functions.html"); else if (cmd=="Plugins") run("URL...", "url=http://rsbweb.nih.gov/ij/plugins/"); else if (cmd=="Source Code") run("URL...", "url=http://rsbweb.nih.gov/ij/developer/source/"); else if (cmd=="List Archives") run("URL...", "url=https://list.nih.gov/archives/imagej.html"); else if (cmd=="Debug Mode") setOption("DebugMode", true); else if (cmd!="-") run(cmd); } macro "Pencil Tool - C025L494fL4990L90b0Lc1c3L82a3Db3Lb58bL7c4fLb4b4L5a5dL6b6cL7b7bCc00L5f9eL9ebbLbbfa" { getCursorLoc(x, y, z, flags); if (flags&alt!=0) setColorToBackgound(); draw(pencilWidth); } macro "Paintbrush Tool - C037La077Ld098L6859L4a2fL2f4fL3f99L5e9bL9b98L6888L5e8dL888c" { getCursorLoc(x, y, z, flags); if (flags&alt!=0) setColorToBackgound(); draw(brushWidth); } macro "Flood Fill Tool -C025B21P085373b75d0L4d1aL3135L4050L6166D57D77D68D09D94Cc00La5adLb6bc" { requires("1.34j"); setupUndo(); getCursorLoc(x, y, z, flags); if (flags&alt!=0) setColorToBackgound(); floodFill(x, y, floodType); } function draw(width) { requires("1.32g"); setupUndo(); 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() { savep = getPixel(0, 0); makeRectangle(0, 0, 1, 1); run("Clear"); background = getPixel(0, 0); run("Select None"); setPixel(0, 0, savep); setColor(background); } // Runs when the user double-clicks on the pencil tool icon macro 'Pencil Tool Options...' { pencilWidth = getNumber("Pencil Width (pixels):", pencilWidth); } // Runs when the user double-clicks on the paint brush tool icon macro 'Paintbrush Tool Options...' { brushWidth = getNumber("Brush Width (pixels):", brushWidth); call("ij.Prefs.set", "startup.brush", brushWidth); } // Runs when the user double-clicks on the flood fill tool icon macro 'Flood Fill Tool Options...' { Dialog.create("Flood Fill Tool"); Dialog.addChoice("Flood Type:", newArray("4-connected", "8-connected"), floodType); Dialog.show(); floodType = Dialog.getChoice(); call("ij.Prefs.set", "startup.flood", floodType); } // 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, dot size // and flow rate. var sprayCanWidth=75, sprayCanDotSize=1, sprayCanRate=6; macro 'Spray Can Tool-Cc00D20D22D24D41D43D62D82Da2C037L93b3D84Dc4L75d5L757f Ld5dfLa7d7LabdbLa9d9LacdcLa7ac' { setLineWidth(sprayCanDotSize); radius=sprayCanWidth/2; radius2=radius*radius; start = getTime(); autoUpdate(false); n = 5*exp(0.9*(10-sprayCanRate)); if (n<=5) n = 0; while (true) { getCursorLoc(x, y, z, flags); if (flags&16==0) exit(); x2 = (random()-0.5)*sprayCanWidth; y2 = (random()-0.5)*sprayCanWidth; if (x2*x2+y2*y2start+50) { updateDisplay(); start = getTime(); } } for (i=0; i10) sprayCanRate = 10; } macro "About ImageJ Action Tool - C037T3e16?" { run("About ImageJ..."); } macro "-" {} //menu divider macro "About Startup Macros..." { print("Macros, such as this one, contained in a file named"); print(" \"StartupMacros.txt\", located in ImageJ/macros, are"); print("installed in the Plugins>Macros menu when ImageJ starts."); print(""); print("More information is available at:"); print(""); }