Login  Register

Re: Using setColor without an open image

Posted by Wayne Rasband-2 on Mar 31, 2019; 4:25pm
URL: http://imagej.273.s1.nabble.com/Re-Using-setColor-without-an-open-image-tp5021956.html

> On Mar 30, 2019, at 2:56 PM, Stein Rørvik <[hidden email]> wrote:
>
> In a macro, you can use the functions
>  
>                 setFont(...
>                 setJustification(...
>                 setForegroundColor(...
>                 setBackgroundColor(...
>  
> among others without an open image.
>  
> But the
>  
>                 setColor(...
>  
> function gives an error message without an open image.
>  
> Same applies to
>  
>                 setLineWidth(...
>  
> Can these two restrictions be removed

I would prefer to not remove these restrictions. The color set by setColor() and line width set by setLineWidth() are associated with an image, so they are reset when you open a new image. Making them global would likely break some existing macros.

-wayne


>  It often makes sense to put such initialization functions at the start of a macro when no image might have been opened or created yet.
>  
> Besides, setColor and setLineWidth are not specific to the active image but a global setting as far as I can see.
>  
> I tested the other set.. functions without images and they work as expected by giving missing image error message only when needed; when the settings are specific to one image.
>  
> Stein

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html