Skip to content

Canvas: Undo & Clear hotkey, brush scales by area, consistent max brush size #34

Description

@flagman9040

Description

  • add Undo hotkey to canvas
    • default Z key
  • add Clear hotkey to canvas
    • default C key
2024-11-20.06_59_08_899.chrome.mp4

  • Brush size adjustment mode, Area and Radius (new commit removed Radius mode)
    • currently the brush size increase or decrease by 5% (hardcoded) of the maximum allowed Radius of the brush
      • I'm not sure how gradio determines the maximum brush size

      • this poses some usability issues especially when dealing with small brush sizes
    • to solve this issue I implemented a new scaling method based on the Area
      • with the Area method the brush size is increase or decrease by 10% (configurable) in Area allowing for finer adjustment

in my opinion Area mode it's much more usable than Radius mode
as such I have made the Area mode the Default changing old behavior
users who prefer the old method can configure it in settings

I have been testing with Area mode for a while locally and it feels quite natural

Radius

2024-11-20.07_00_34_898.chrome.mp4

Area

2024-11-20.07_01_34_712.chrome.mp4

notice that the Area mode brush size step is much more smoother then Radius


Brush size is set to 1/2 diagonal image, beyond the gradio default after the usere uses either the hotkeys or scroll wheel to change the brush size


Considering there's no timeline for Gradio 4 or 5
I think implement this relatively trivial function is worth it


future potential improvements / discussion

  • add hotkey for removeing the image?

    • what key should it use
  • in the PR only the factor / step for Area mode is configurable, while the 5% step in Radius model is hardcoded

  • should it be made configurable, if so should it share the same setting key as the factor used for Area mode

    • if so it's going to be hard to set a default value
    • or should it use a different setting key

Checklist:

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions