Commit Graph

67 Commits

Author SHA1 Message Date
Isaiah Odhner
0697784d56 Enable toggling tools/colors boxes from the View menu 2023-04-14 01:46:07 -04:00
Isaiah Odhner
16d3b84015 Set up argparse and make --ascii-only-icons an option 2023-04-14 01:15:42 -04:00
Isaiah Odhner
a857845281 Add ascii-only icons mode 2023-04-14 01:10:09 -04:00
Isaiah Odhner
fda94c31f8 Implement brush previews 2023-04-13 23:07:46 -04:00
Isaiah Odhner
44fe270463 Note some alternate selection tool icons using Braille
These are pretty good candidates, paired together.
For the Free-Form Select icon (⢼⠮), I'm specifically imitating the
asymmetrical star shape from MS Paint.
2023-04-13 23:07:46 -04:00
Isaiah Odhner
baaf0ee8e9 Pick color while dragging 2023-04-13 19:02:44 -04:00
Isaiah Odhner
611e7f10c9 Implement Pick Color tool 2023-04-13 18:54:51 -04:00
Isaiah Odhner
b805d9a488 Implement eraser and airbrush tools 2023-04-13 18:48:24 -04:00
Isaiah Odhner
155df6a998 Collect more symbols 2023-04-13 10:02:31 -04:00
Isaiah Odhner
3652b2bd8e Add flood fill support
* Implemented the Fill With Color tool using the algorithm described as
  "combined-scan-and-fill span filler" on Wikipedia.
* I added handling for the affected region being None, which turned
out more complicated than I would like...
  Some cases may be able to be simplified or removed.
* Also, I moved event.stop() to the top so I don't need to call it in
multiple places when there are multiple return points.
2023-04-13 02:48:32 -04:00
Isaiah Odhner
3dbbbc1c5f Refactor away assumption that tools will affect the document at the cursor
You could imagine having a brush with momentum, that swings around the
mouse without always reaching it. But it's just generally clearer to
not have an inadequate initial region that's then extended.
2023-04-13 01:21:33 -04:00
Isaiah Odhner
de47a62833 Implement line, rectangle, and rounded rectangle tools 2023-04-13 00:52:44 -04:00
Isaiah Odhner
50c3278264 Use tool names from MS Paint, consistently 2023-04-13 00:35:49 -04:00
Isaiah Odhner
303d6942f4 Switch out fill tool icon to avoid text row offset artifacts 2023-04-13 00:32:03 -04:00
Isaiah Odhner
5b1c16ddc3 Use wide A character for text tool icon, centering it 2023-04-13 00:32:03 -04:00
Isaiah Odhner
e11cbb0748 Convert keyboard handling to use BINDINGS
https://textual.textualize.io/guide/input/#bindings
2023-04-12 23:57:11 -04:00
Isaiah Odhner
d748c380b4 Rename all keyboard activated functions to action_* 2023-04-12 23:32:30 -04:00
Isaiah Odhner
b779059208 Add non-functional menu bar 2023-04-12 20:54:21 -04:00
Isaiah Odhner
4fa7784651 Toggle dark mode with Ctrl+D 2023-04-12 15:32:16 -04:00
Isaiah Odhner
5796c5c8b3 Give inset appearance to color wells / selected color 2023-04-12 15:31:52 -04:00
Isaiah Odhner
083b169257 Add ellipse tool support 2023-04-11 22:30:46 -04:00
Isaiah Odhner
f31069e3b2 Add type hints for undos/redos lists 2023-04-11 22:30:46 -04:00
Isaiah Odhner
67d256883d Refactor: don't store reference to the live document in Action
It feels in danger of accidental usage there, or preventing GC.
2023-04-11 21:45:00 -04:00
Isaiah Odhner
30cddbbde5 Save and load ANSI files 2023-04-11 21:18:11 -04:00
Isaiah Odhner
3e84ae7e17 Disable region update debug 2023-04-11 15:20:31 -04:00
Isaiah Odhner
6d5430ad2e Fix error due to action regions exceeding canvas bounds 2023-04-11 14:41:58 -04:00
Isaiah Odhner
0aaa9db839 Make region update debug a flag 2023-04-11 14:37:32 -04:00
Isaiah Odhner
15db3f4538 Store only sub-image for undo/redo 2023-04-11 14:31:50 -04:00
Isaiah Odhner
6d17f085f5 Debug: show regions when undoing/redoing (currently the whole canvas) 2023-04-11 13:49:03 -04:00
Isaiah Odhner
4fa7dda9a0 Clarify doc string for on_button_pressed
Disambiguate with on_key.

Alternately I could say "Called when a button widget is pressed."
2023-04-11 13:47:50 -04:00
Isaiah Odhner
e3e04c59a8 Implement redo
Ctrl+Shift+Z isn't working but Ctrl+Y and F4 are.
2023-04-11 13:40:31 -04:00
Isaiah Odhner
af6bfb4e45 Implement undo 2023-04-11 13:21:19 -04:00
Isaiah Odhner
4c2fc00e45 Select pencil when trying to draw with unimplemented tool 2023-04-11 12:30:47 -04:00
Isaiah Odhner
470e6e119e Make brush tool draw with a diameter 2023-04-11 12:24:25 -04:00
Isaiah Odhner
1f3809999e Remove some garbage unrelated symbols
I mean, let's be honest, most of these symbols are garbage candidates.
But these ones I accidentally left from trying to get ChatGPT to find
emoji for me.
More helpful were https://emojidb.org/ and http://shapecatcher.com/
2023-04-11 12:13:50 -04:00
Isaiah Odhner
5340539133 Refactor bresenham_walk into a generator 2023-04-11 12:01:40 -04:00
Isaiah Odhner
a66df997bb Toggle the color palette with Ctrl+W
Doesn't work in VS Code's terminal, but that's OK.
It works in Ubuntu's Terminal app.
2023-04-11 11:48:08 -04:00
Isaiah Odhner
4d2b667ecb Toggle the tools box with Ctrl+T 2023-04-11 11:40:47 -04:00
Isaiah Odhner
d64a011bb8 Remove extraneous refresh on mount 2023-04-11 11:08:12 -04:00
Isaiah Odhner
ab76aacff3 Stop bubbling of canvas tool events 2023-04-11 11:02:09 -04:00
Isaiah Odhner
c7e27bc3cb Cache canvas widget reference 2023-04-11 11:02:09 -04:00
Isaiah Odhner
ad111e5d6c Refactor: extract tool handling from Canvas
I wanted to avoid duplicating tool-related state between PaintApp and
Canvas, and prepare for adding different tools with more state and which
will want to live in a separate file.

This makes it slower, when running with `textual run --dev paint.py`;
when running with `python3 paint.py`, it's fine.
When running in dev mode with `textual console` devtool connected, it's
extremely much slower. But if it was faster, you'd have more messages
to scroll through, ha. So it's a tradeoff.*
*Ideally you want it to be fast and for the logs to be compacted.

In the future, I could bypass the message system for performance, but
for now I think it's better to stay idiomatic.
2023-04-11 11:02:09 -04:00
Isaiah Odhner
cb37f50564 Fix mouse move event coordinates 2023-04-11 08:48:02 -04:00
Isaiah Odhner
e2c9b4b66c Improve layout 2023-04-11 08:47:47 -04:00
Isaiah Odhner
7d1afed296 Define dimensions for Canvas widget 2023-04-11 08:46:57 -04:00
Isaiah Odhner
abd6468ce8 Refactor related image data into a class 2023-04-11 08:07:02 -04:00
Isaiah Odhner
e19cdff5e7 Exit with Ctrl+Q, in preparation for overriding Ctrl+C 2023-04-11 07:52:26 -04:00
Isaiah Odhner
3844667ff7 Hide characters, use only colors on canvas 2023-04-11 00:48:29 -04:00
Isaiah Odhner
32ac1bd92c Make drawing responsive! 2023-04-11 00:46:07 -04:00
Isaiah Odhner
c3035d171f Fix up the app layout scrollbar situation
- Remove scrollbar from root
- Fix extra height below color palette due to vertical layout giving even heights
- Add container around canvas to make canvas scrollable
2023-04-11 00:19:07 -04:00