This took a lot of trial and error to get this working. - First I had to figure out how to copy the terminal output as HTML. I had to configure keybindings for Select All and Copy As HTML in the Ubuntu terminal. - GitHub doesn't support line-height in markdown, so I came up with using an SVG with <foreignObject> to contain the screenshot HTML. - GitHub doesn't support inline SVG, so I had to use <img>, that's fine. An external file is cleaner anyways. - I spent a long time trying to fix the seams between rows of text. `line-height: <font-size>` is not `line-height: 1`! I think I tried `line-height: 1` first, but it wasn't working for some reason so I tried a bajillion things, having mentally discounted it, before circling back to it and trying it again and it actually worked. - I spent a long time futzing about with SVG viewports and units. - The text was staggered due to some of the Unicode characters, so I developed a script to fix that up. I managed to achieve a nice development cycle for this, but only near the end of developing it. Most of the time while working on it I was copying and pasting the updated code into the console after hitting up up enter to re-run grapheme-splitter's JS. The next commit will apply this script. - All in all, getting this screenshot working took basically all day! Compare that to my first day of progress on this project, having never used the Textual framework before, and also having not used Python for a while. In summary, coding is a land of contrasts. - VS Code's markdown rendering isn't working with the ch/lh units.
3.9 KiB
textual-paint
What if MS Paint isn't retro enough? You need Paint in your terminal.
This is a TUI (Text User Interface) image editor, inspired by MS Paint, and built with Textual.
|
Textual Paint terminal screen buffer in HTML in SVG in HTML. This might not render correctly in your browser. |
Features
- Open and save images
- PNG (.png)
- Bitmap (.bmp)
- ANSI (.ans)
- only supports loading files saved by this program; ANSI files can vary a lot and even encode animations
- no save dialog yet, you can only save a file opened via the command line
- Tools
- Free-Form Select
- Rectangular Select
- Eraser
- Color Eraser
- Fill With Color
- Pick Color
- Magnifier
- Pencil
- Brush
- Airbrush
- Text
- Line
- Curve
- Rectangle
- Polygon
- Ellipse
- Rounded Rectangle
- Color palette
- Undo/Redo
- Efficient screen updates and undo/redo history, by tracking regions affected by each action
- You could totally use this program over SSH! Haha, this "what if" project could actually be useful. Of course, it should be mentioned that you can also run graphical programs over SSH, but this might be more responsive, or just fit your vibe better.
- Brush previews
- Menu bar
Development
Install Textual and Stransi:
pip install "textual[dev]" "stransi"
Run supporting live-reloading CSS:
textual run --dev paint.py
Or run normally:
python paint.py
License
Unicode Symbols and Emojis for Paint Tools
The first thing I did in this project was to collect possible characters to represent all the tool icons in MS Paint, to test feasibility. In other words, I wanted to gauge how good of a recreation it would be possible to achieve, starting from looks. Unfortunately, I haven't run into any significant roadblocks, so I'm apparently recreating MS Paint. Again.
These are the symbols I've found so far:
- Free-Form Select: ✂️📐🆓🕸✨⚝🫥🇫/🇸◌⁛⁘ ⢼⠮
- Rectangular Select: ⬚▧🔲 ⣏⣹
- Eraser/Color Eraser: 🧼🧽🧹🚫👋🗑️
- Fill With Color: 🌊💦💧🌈🎉🎊🪣🫗
- Pick Color: 🎨💉💅💧📌📍⤤𝀃🝯🍶
- Magnifier: 🔍🔎👀🔬🔭🧐🕵️♂️🕵️♀️
- Pencil: ✏️✎✍️🖎🖊️🖋️✒️🖆📝🖍️
- Brush: 🖌️🖌👨🎨🧑🎨💅
- Airbrush: 💨ᖜ╔🧴🥤🫠
- Text: 🆎📝📄📃🔤📜AA
- Line: 📏📉📈⟍𝈏╲⧹\⧵∖
- Curve: ↪️🪝🌙〰️◡◠~∼≈∽∿〜〰﹋﹏≈≋~⁓
- Rectangle: ▭▬▮▯🟥🟧🟨🟩🟦🟪🟫⬛⬜◼️◻️◾◽▪️▫️
- Polygon: ▙𝗟𝙇﹄』⬣⬟🔶🔷🔸🔹🔺🔻△▲
- Ellipse: ⬭⭕🔴🟠🟡🟢🔵🟣🟤⚫⚪🫧
- Rounded Rectangle: ▢⬜⬛
The default symbols used may not be the best on your particular system, so I may add some kind of configuration for this in the future.
Cursor
A crosshair cursor could use one of +✜✛✚╋╬
, but whilst that imitates the look, it might be better to show the pixel under the cursor, i.e. character cell, surrounded by dashes, like this:
╻
╺█╸
╹
See Also
- JavE, an advanced Java-based ASCII art editor
- Playscii, a beautiful ASCII/ANSI art editor
- cmdpxl, a pixel art editor for the terminal using the keyboard
- pypixelart, a pixel art editor using vim-like keybindings, inspired by cmdpxl but not terminal-based