Login  Register

Re: custom cursor?

Posted by Marcel on May 13, 2016; 9:51am
URL: http://imagej.273.s1.nabble.com/custom-cursor-tp5016417p5016421.html

Dear Kenneth,

here is my suggestion as a macro using overlays and hiding the cursor. The space key exits the painting of a ellipse which you can resize with the Shift (+) and Alt key (-). Of course this is a rough draft but maybee fits your needs. A custom cursor could also be set:

isDown=false;
width=50;
height=50;
eval("script","ImageCanvas.setCursor(Toolkit.getDefaultToolkit().createCustomCursor(new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB), new Point(0, 0), \"blank cursor\"),1)");
while(isDown==false) {
isDown=isKeyDown("space");
if(isKeyDown("shift")){
        width++;
        height++;
}
if(isKeyDown("alt")){
        if(width>1&&height>1){
        width--;
        height--;
        }
}
getCursorLoc(x, y, z, flags);
Overlay.drawEllipse(x-(width/2), y-(height/2), width, height);
Overlay.show;
wait(30);
Overlay.remove;
}
eval("script","ImageCanvas.setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR),1)");

For scaled coordinates, see:

http://rsb.info.nih.gov/ij/developer/macro/functions.html#toScaled

Best,

Marcel