What parameters does MaskByColor take?

I’m working on code for a Multiple Color Range Selection tool that would function similarly to the built-in Select → Color Range. I could code this without reference to the MaskByColor command but in the interest of using what is already available, I’m searching for information on how to use MaskByColor.

I’ve been trying to follow the guide at the bottom of the app_command page to find the parameters of app.command.MaskByColor. So far, I’m hitting a roadblock.

(aseprite/gui.xml at main · aseprite/aseprite · GitHub)
The gui says:

    <menu text="@.select_modify" group="select_complex">
      <item command="ModifySelection" text="@.select_modify_border">
        <param name="modifier" value="border" />
      </item>
      <item command="ModifySelection" text="@.select_modify_expand">
        <param name="modifier" value="expand" />
      </item>
      <item command="ModifySelection" text="@.select_modify_contract">
        <param name="modifier" value="contract" />
      </item>

If I understood the guide correctly, that should translate to something such as app.command.MaskByColor {modifier=“expand”}

(I’m confused because I expected color or at least tolerance to be parameters.

(aseprite/cmd_mask_by_color.cpp at main · aseprite/aseprite · GitHub)
and I found the following in the cmd_mask_by_color.cpp:

Mask* MaskByColorCommand::generateMask(const Mask& origMask,
                                       const Sprite* sprite,
                                       const Image* image,
                                       int xpos, int ypos,
                                       gen::SelectionMode mode)

and also

 mask->byColor(image, color, tolerance);

from this I would guess that MaskByColor has params: image, color, tolerance, SelectionMode (since xpos and ypos make no sense to me)

Any help would be massively appreciated! Even just a tip on how to read the gui and cmd_…cpp files.

hmm… it seems like there aren’t any params. you’re looking in the right direction, but that part of gui.xml is actually for select → modify and in source file there aren’t any lines with params.get.
so, it looks like the script can just open the window and select whatever is current foreground colour.

Thank you so much!

1 Like