maoschanz / maoschanz/drawing

Finally fixing the paint bucket tool

Open
#616 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug enhancement selection tools
Dominant language
Python
Stars
869
Forks
106
PR merge metrics
No merged PRs in 30d

Description

## Use case

using the paint bucket tool without crashes

## Suggested solution

- replace the very "beta" menu (with verbiage to select an algorithm) by a checkbox corresponding to user-oriented needs
- fill with the request alpha channel (erase & replace) or not (outline & fill)
- replace the current unreliable "magic path" algorithm with yet another idea that came to me in a dream:
- from the point where the user clicked,
- go in 8 directions until reaching the edge of the contiguously colored area.
- incrementally refine each segment of the irregular octagon:
- from the middle of each given segment,
- go in ~~the 3 possible directions~~ *only 2 directions for the first iteration, and then only the diagonal one (to avoid crossings)* until reaching an edge

this would work despite the way cairo handles the matter

the "outline & fill" method can have cleaner edges if all points of the shape go "one pixel further" than needed, which is possible because that incremental building technique from an octagon mean we easily know which side of the edge is which at any given point

### Possible drawbacks

- what would happen to "select by color"?
- could i keep the "entire image" option?

### Possible alternatives

- what about a "only contiguous pixels" checkbox option? when unchecked, replace a color across the entire image instead of running those idiotic costly python pathfinding algorithms

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by examining the paint bucket tool and its current magic path algorithm, then compare the proposed contiguous-area and alpha-channel behaviors. Done means the tool no longer crashes or relies on the unreliable algorithm, with the requested user-oriented option and existing select-by-color and entire-image behavior resolved.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
desktop
Issue type
Bug
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
20/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.