Giter Club home page Giter Club logo

cmang / durdraw Goto Github PK

View Code? Open in Web Editor NEW
598.0 6.0 20.0 3.87 MB

Versatile ASCII and ANSI Art text editor for drawing in the Linux/Unix/macOS terminal, with animation, 256 and 16 colors, Unicode and CP437, and customizable themes

Home Page: http://durdraw.org

License: BSD 3-Clause "New" or "Revised" License

Python 99.24% Shell 0.04% Roff 0.68% Dockerfile 0.04%
ascii art animation terminal linux ansi ascii-art ascii-graphics textmode ansi-art

durdraw's Introduction

Durdraw

              __                __
            _|  |__ __ _____ __|  |_____ _____ __ __ __
           / _  |  |  |   __|  _  |   __|  _  |  |  |  |\
          /_____|_____|__|__|_____|__|___\____|________| | 
          \_____________________________________________\|  v 0.26.0

durdraw-0 24 0-example

OVERVIEW

Durdraw is an ASCII, Unicode and ANSI art editor for UNIX-like systems (Linux, macOS, etc). It runs in modern Utf-8 terminals and supports frame-based animation, custom themes, 256 and 16 color modes, terminal mouse input, DOS ANSI art viewing, CP437 and Unicode mixing and conversion, HTML output, mIRC color output, and other interesting features.

Durdraw is heavily inspired by classic ANSI editing software for MS-DOS and Windows, such as TheDraw, Aciddraw and Pablodraw, but with a modern Unix twist.

REQUIREMENTS

  • Python 3 (3.10+ recommended)
  • Linux, macOS, or other Unix-like System

INSTALLATION

You can install from your OS repositories, or follow the instructions below to install from source:

Packaging status

If you just want to run it without instalilng, scroll down to the next section.

1: Download and extract, or use git to download:

   git clone https://github.com/cmang/durdraw.git  
   cd durdraw 

2: Install or upgrade using pip:

    pip install --upgrade .

Or run the installer:

    python3 setup.py install

3: Optionally, install some themes and a sample configuration file for your local user into ~/.durdraw/:

    ./installconf.sh

You should now be able to run durdraw. Press esc-h for help, or try durdraw --help for command-line options.

RUNNING WITHOUT INSTALLING

You may need to install the "PIL" or "pillow" python module first:

    pip3 install pillow

Then you can run Durdraw with:

    ./start-durdraw

To look at some included example animations:

    ./start-durdraw -p examples/*.dur

To edit 16-color PC Scene (MS-DOS/CP437) ANSI art files in a Utf-8 terminal, use the --16color option:

    ./start-durdraw --16color

GALLERY

Watch the Tutorial Part 1

Watch another video

durdraw-xmas-example

dopetrans3 durdraw-screenshot durdraw-linux-unicode-ansi eye cm-doge bsd-color-new

COMMAND LINE USAGE

You can play a .dur file or series of .dur files with:

    $ durdraw -p filename.dur
    $ durdraw -p file1.dur file2.dur file3.dur ...

Other command-line options:

usage: start-durdraw [-h] [-p PLAY [PLAY ...]] [-q | -w | -x TIMES] [--256color | --16color] [-b]
                     [-W WIDTH] [-H HEIGHT] [-m] [--nomouse] [-A] [-u UNDOSIZE] [-V] [--debug]
                     [filename]

positional arguments:
  filename              .dur or ascii file to load

optional arguments:
  -h, --help            show this help message and exit
  -p PLAY [PLAY ...], --play PLAY [PLAY ...]
                        Just play .dur file or files, then exit
  -q, --quick           Skip startup screen
  -w, --wait            Pause at startup screen
  -x TIMES, --times TIMES
                        Play X number of times (requires -p)
  --256color            Try 256 color mode
  --16color             Try 16 color mode
  -b, --blackbg         Use a black background color instead of terminal default
  -W WIDTH, --width WIDTH
                        Set canvas width
  -H HEIGHT, --height HEIGHT
                        Set canvas height
  -m, --max             Maximum canvas size for terminal (overrides -W and -H)
  --nomouse             Disable mouse support
  --cursor CURSOR       Cursor mode (block, underscore, or pipe)
  --notheme             Disable theme support
  --theme THEME         Load a custom theme file
  --cp437               Encode extended characters using Code Page 437 (IBM-PC/MS-DOS) encoding
                        instead of Utf-8. (Needs CP437 capable terminal and font)
  --export-ansi         Export loaded art to an ANSI file and exit
  -u UNDOSIZE, --undosize UNDOSIZE
                        Set the number of undo history states - default is 100. More requires more
                        RAM, less saves RAM.
  -V, --version         Show version number and exit

INTERACTIVE USAGE/EDITING

Use the arrow keys (or mouse) and other keys to edit, much like a text editor. You can use the "Esc" (or "Meta") key to access commands:

  .. Art Editing .....................   
  : F1-F10 - insert character        :   
  : esc-up - next fg color           :   
  : esc-down - prev fg color         :   
  : esc-right - next bg color (16c)  :   
  : esc-left - prev bg color         :
  : esc-/ - insert line              :   .. Animation .......................
  : esc-' - delete line              :   : esc-k - next frame               :
  : esc-. - insert column            :   : esc-j - previous frame           :
  : esc-, - delete column            :   : esc-p - start/stop payback       :
  : esc-] - next character group     :   : esc-n - clone frame              :
  : esc-[ - previous character group :   : esc-N - append empty frame       :
  : esc-S - change character set     :   : esc-d - delete frame             :
  : esc-y - eyedrop (pick up color)  :   : esc-D - set frame delay          :
  : esc-l - color character          :   : esc-+/esc-- - faster/slower      :
  : esc-c - color picker             :   : esc-R - set playback/edit range  :
  : shift-arrows - select for copy   :   : esc-g - go to frame #            :
  : esc-K - mark selection           :   : esc-M - move frame               :
  : esc-v - paste                    :   :..................................:
  :..................................:
                                         .. UI/Misc .........................
  .. File Operations .................   : esc-m - main menu                :
  : esc-C - new/clear canvas         :   : esc-t - mouse tools              :
  : esc-o - open                     :   : esc-z - undo                     :
  : esc-s - save                     :   : esc-r - redo                     :
  :..................................:   : esc-V - view mode                :
                                         : esc-i - file/canvas info         :
  .. Canvas Size .....................   : esc-I - character inspector      :
  : esc-" - insert line              :   : tab - focus canvas or colors     :
  : esc-: - delete line              :   : ctrl-l - redraw screen           :
  : esc-> - insert column            :   : esc-h - help                     :
  : esc-< - delete column            :   : esc-q - quit                     :
  :..................................:   :..................................:

                                                            Prev   Next
                                                            Frame  Frame
                                                            |      |
Main   Frame     Speed     Frame   Play/Edit  Mouse   First | Play |  Last
Menu   Number      |       Delay   Range      Tools   Frame | Pause|  Frame
 |     |           |        |       |          |         |  |  |   |  |
[Menu] F: 1/8    <FPS>: 8   D: 0.00 R: 1/8   [Move]      |< << |> >> >|  

CONFIGURATION

You can create a custom startup file where you can set a theme.

If you did not already do so during installation, you can install a sample configuration and some themes into ~/.durdraw/ with the command:

    ./installconf.sh

This will place durdraw.ini into ~/.durdraw/ and the themes into ~/.durdraw/themes/.

Here is an example durdraw.ini file:

; Durdraw 0.20 Configuration File
[Theme]
theme-16: ~/.durdraw/themes/purpledrank-16.dtheme.ini
theme-256: ~/.durdraw/themes/mutedform-256.dtheme.ini

The option 'theme-16' sets the path to the theme file used in 16-color mode, and 'theme-256' sets the theme file used for 256-color mode.

Note that you can also load a custom theme file using the --theme command-line argument and passing it the path to a theme file, or disable themes entirely with the --notheme command line option.

Here is an example 16-color theme:

[Theme-16]
name: 'Purple Drank'
mainColor: 6
clickColor: 3
borderColor: 6
clickHighlightColor: 5
notificationColor: 4
promptColor: 4

and a 256-color theme:

[Theme-256]
name: 'Muted Form'
mainColor: 104
clickColor: 37
borderColor: 236
clickHighlightColor: 15
notificationColor: 87
promptColor: 189
menuItemColor: 189
menuTitleColor: 159
menuBorderColor: 24

The colors and theme options are as follows:

colors for 16-color mode: 1 black 2 blue 3 green 4 cyan 5 red 6 magenta 7 yellow 8 white

color codes numbers for 256-color mode can be found in Durdraw's 256-color selector.

mainColor: the color of most text
clickColor: the color of buttons (clickable items)
clickHighlightColor: the color the button changes to for a moment when clicked
borderColor: the color of the border around a drawing
notificationColor: the color of notification messages
promptColor: the color of user prompt messages
menuItemColor: the color of menu items
menuTitleColor: the color of menu titles
menuBorderColor: the color of the border around menus

OTHER TIPS

* To use themes, copy durdraw.ini to ~/.durdraw/ and edit it. Durdraw
  will also check in the current directory for durdraw.ini.

* The mouse can be used for moving the cursor (even over SSH) and
  clicking buttons, if your terminal supports Xterm mouse reporting.
  In iTerm2 this is under Profiles, Terminal and Terminal Emulation.

OPTIONAL INSTALLATION

For PNG and animated GIF export, install Ansilove (https://ansilove.org/) and make sure it is is in your path. PNG and GIF export only work in 16-color mode for now.

FAQ

Q: Don't TheDraw and some other programs already do ANSI animation?

A: Yes, but traditional ANSI animation does not provide any control over timing, instead relying on terminal baud rate to govern the playback speed. This does not work well on modern systems without baud rate emulation. Durdraw gives the artist fine control over frame rate, and delays per frame. Traditional ANSI animation also updates the animation one character at a time, while Durdraw updates the animation a full frame at a time. This makes it less vulnerable to visual corruption from things like errant terminal characters, resized windows, line noise, etc. Finally, unlike TheDraw, which requires MS-DOS, Durdraw runs in modern Unicode terminals.

Q: Can I run Durdraw in Windows?

A: Short answer: It's not supported, but it seems to work fine in the Windows Subsystem for Linux (WSL). Long answer: Some versions run fine in Windows Command Prompt, Windows Terminal, etc, without WSL, but it's not tested or supported. If you want to help make Durdraw work better in Windows, please help by testing, submitting bug reports and submitting patches.

Q: Can I run Durdraw on Amiga, MS-DOS, Classic MacOS, iOS, Android, etc?

A: Probably not easily. Durdraw requires Python 3 and Ncurses. If your platform can support these, it will probably run. However, the file format for Durdraw movies is a plain text JSON format. It should be possible to support this format in different operating systems and in different applications.

Q: Does Durdraw support IBM-PC ANSI art?

A: Yes! IBM-PC ANSI art popular in the "ANSI Art Scene" uses Code Page 437 character encoding, which usually needs to be translated to work with modern terminals. When Durdraw encounters these files, it will convert them to Unicode and carry on. When you save ANSI files, it will ask if you want to use CP437 or Utf-8 encoding.

CREDITS

Developer: Sam Foster

Home page: http://durdraw.org

Development: https://github.com/cmang/durdraw

ANSI and ASCII artists: cmang, H7, LDA

LEGAL

Durdraw is Copyright (c) 2009-2024 Sam Foster [email protected]. All rights reserved.

This software is distributed under the BSD 3-Clause License. See LICENSE file for details.

durdraw's People

Contributors

alexmyczko avatar cmang avatar eyooooo avatar fcambus avatar sigurdo avatar yumpyy avatar zhenrong-wang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

durdraw's Issues

first run issue

following default install instructions - cloning repo and installing via pip or setup.py, durdraw doesnt start. no issues on install, both methods report install good.

username@My-MacBook-Pro durdraw % durdraw
Traceback (most recent call last):
  File "/opt/homebrew/bin/durdraw", line 33, in <module>
    sys.exit(load_entry_point('durdraw==0.17.2', 'console_scripts', 'durdraw')())
  File "/opt/homebrew/lib/python3.10/site-packages/durdraw-0.17.2-py3.10.egg/durdraw/main.py", line 72, in main
    app = AppState()    # to store run-time preferences from CLI, environment stuff, etc.
  File "/opt/homebrew/lib/python3.10/site-packages/durdraw-0.17.2-py3.10.egg/durdraw/durdraw_appstate.py", line 31, in __init__
    if curses.has_extended_color_support(): # Requires Ncures 6
NameError: name 'curses' is not defined

macos, python 3.10.9, pip 22.3.1

i confirmed curses does exist. is it because durdraw_appstate.py does not import curses? my python kind of sucks - sorry.

hi again

sorry for the big QA push here xD

you accidentally introduced a bug for linux users. on install i get

FileNotFoundError: [Errno 2] No such file or directory: 'README.md'

just need to rename readme.md to README.md :)

thanks

Draw/Color/Erase: Mouse button can get stuck held down

There is an annoying bug with the mouse button getting stuck.

To reproduce:
1: Go into a mode where you can click and hold down to do something, like Draw, Erase or Color.
2: Click down on the mouse somewhere in the canvas, and drag the mouse cursor outside of your terminal window.
3: Let go of the mouse button while the cursor is outside of the terminal.
4: Move the mouse cursor back into the terminal window.

Durdraw will still think the mouse button is held down. You can reset this with a single click or double click, usually, and avoid the issue completely by avoiding dragging the cursor outside of the window with the mouse button held down.

This has to do with the (probably dumb) way that Durdraw interacts with Ncurses' mouse functions in /durdraw/durdraw_ui_curses.py, and stores the mouse state.

Here is a link to the appropriate section in a commit, in the monster mainLoop() method:
https://github.com/cmang/durdraw/blob/32e601901477cf6ba25accb7cb09b3dffa5348ba/durdraw/durdraw_ui_curses.py#L1917C37-L1917C37

Any help would be appreciated!

durformat spec reverses x/y

I'm trying to write a converter from .dur to .ddw (DarkDraw), and it looks like the specification for colorMap has the x/y coordinates reversed from the actual format.

From durformat.md:

Each element of the colorMap should coordinate with a corresponding line and column in the contents. For example, colorMap[2][3] should describe the foreground and background color for the character at contents[2][3], which is the character at Line 2, Column 3 of the given frame.

This makes sense to me and is what I expected, but looking at e.g. indyz-linuxfire.dur, there are 80 elements in colorMap, which corresponds to the width instead of the height.

Crashes in Windows 10: curses.panel.move() returns ERR

Durdraw 0.15 actually worked alright in Windows (in Command Prompt, Windows Terminal, etc) with windows-ncurses installed, but the latest build (0.17.2) has issues.

The issue seems to have started when I started using curses panels. Curses.panel.move() returns ERR. I haven't investigated too deeply, but some possible theories are that the Windows curses clone does not fully implement panels, or maybe that it needs a bit more care with the order things are done in. It would be nice if someone would help track down and fix the Windows issues.

AttributeError: module 'curses' has no attribute 'BUTTON5_PRESSED'

On macOS Sonoma, MacBook Pro, M1, in iTerm2 Build 3.4.23, clicking anywhere within the iTerm window results in the following exception:

Traceback (most recent call last):
File "durdraw/./start-durdraw", line 11, in <module> main.main()
File "durdraw/durdraw/main.py", line 242, in main ui.mainLoop()
File "durdraw/durdraw/durdraw_ui_curses.py", line 2032, in mainLoop
  elif mouseState & curses.BUTTON1_PRESSED or mouseState & curses.BUTTON4_PRESSED or mouseState & curses.BUTTON5_PRESSED:
AttributeError: module 'curses' has no attribute 'BUTTON5_PRESSED'

Other potentially useful details. I'm using the trackpad, doing nothing particularly fancy.

This project is really cool though! I hope to see the project continue to progress, and awesome work so far. Thanks for your contributions. ๐Ÿ™Œ

macos terminal.app issues with extended ansi

ive been struggling to get the extended ansi chars to work on a 2021 mbp terminal.app. ive tweaked all the dials and buttons in the profile but no luck yet. hoping someone else maybe has a tip?

thanks

image

Request: Homebrew package maintainer

I would like for someone who has experience maintaining Homebrew packages, to maintain one for Durdraw.

I can pay you in ASCII Art and compliments.

Thank you.

docker run

Using the tool with docker run to avoid installing python locally would be welcome.

Could be also OS independent in that way.

Convenient for terminal environment.

Unable to use any F1-F12 keys

Is there any option to remap these keys? They just don't work whatsoever. Or maybe there is an option to pick a character and use it as a draw character?

Im using Kitty 0.31.0-1 (xterm-kitty) on Arch Linux. None of the F1-F12 keys work and the draw/erase/color modes dont register click up or down, it instead just draws/erases/colors wherever the mouse is dragged regardless of whether the mouse is clicked or not. Really cool project btw!

Crash opening durdraw file created from 0.11

burt.zip

when i run durdraw burt (the file attached above), durdraw crashes with the following traceback:

Traceback (most recent call last):
  File "/usr/bin/durdraw", line 33, in <module>
    sys.exit(load_entry_point('durdraw==0.21.1', 'console_scripts', 'durdraw')())
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/site-packages/durdraw/main.py", line 220, in main
    ui.refresh()
  File "/usr/lib/python3.11/site-packages/durdraw/durdraw_ui_curses.py", line 2822, in refresh
    self.addstr(linenum, colnum, str(line[colnum]), curses.color_pair(cursesColorPair))
  File "/usr/lib/python3.11/site-packages/durdraw/durdraw_ui_curses.py", line 359, in addstr
    self.stdscr.addstr(y, x, str, attr)
ValueError: embedded null character
durdraw --version
0.21.1

durdraw 0.11 opens it okay.

Crashes in MacOS 14.1.1 - curses has no attribute BUTTON5_PRESSED

Hi, love durdraw! This is fantastic. However, I am noticing an issue when I try running the example durdraw -p examples/*.dur.

After the initial doge ascii loads and the animation plays for a bit, if I press any keyboard button or mouse button or try to scroll the mouse, I get the following error:

Traceback (most recent call last):
File "/Users/<me>/Library/Python/3.9/bin/durdraw", line 8, in <module>
   sys.exit(main))
File "/Users/<me>/Library/Python/3.9/lib/python/site-packages/durdraw/main.py", line 220, in main
  ui.startPlaying()
File "/Users/<me>/Library/Python/3.9/lib/python/site-packages/durdraw/durdraw_ui_curses.py", line 944, in startPlaying
  elif mouseState & curses.BUTTON5_PRESSED:    # wheel down
AttributeError: module 'curses' has no attribute BUTTON5_PRESSED'

Thanks!

License change?

I am considering changing Durdraw's licensing to a more widely used license, with the goal of simplifying any potential license considerations during redistribution (for distro packages, bundling, etc), or any other usage.

Currently Durdraw uses the ISC license. I am considering changing Durdraw to use one of the following licenses:

BSD, possibly the 3-clause License
MIT License - Everyone loves it. I know I do.

Any thoughts or considerations, from users or packagers, contributors, etc? Is this even an issue at all?

There is an interesting discussion on ISC vs MIT here.

Thanks!

request: tutorial/manual

Hi

I would like to request tutorial/manual
I'm a beginner and have no idea how to use it. I use windows 10

Background Colors in 256 color mode

Background colors only work in 16 color mode, and do not work in 256 color mode. This is because Python curses is unable to set color pairs past 256 pairs. This is enough pairs for all of the 16 FG and 16 BG color combinations, but not 256 FG and 256 BG color combinations.

Python has a method, curses.has_extended_color_support(), which is supposed to return True if more than 256 color pairs are supported. In this case, using Python 3.10, 3.11, and (I think) 3.12, the method returns True in macOS and the Linux systems I've tried. Even if the Python builds are compiled against Ncurses 5... which is a problem, because extended color pairs only work with the Ncurses 6 ABI.

So, when you try to set or use color pairs past 256, they do not work. No errors are returned. But they seem to wrap back around to write or read from color pair 1. For example, trying to read color pair 257 instead reads pair 1, pair 258 instead reads pair 2, etc. Writing pair 257 either overwrites pair 1, or seems to disappear into /dev/null. I think this is a bug in Python's extended color support.

I have seen this behavior in macOS and Linux systems. Python bug report #91132 seems to hint at the cause, which is that Python for macOS is compiled against Ncurses 5.9. This implies that it's using the Ncuress 5 ABI, which means that curses.has_extended_color_support() should be False, even though it isn't. (Python bug?)

I can think of 3 possible ways to fix this:

1: Only generate the color pairs that are needed, and hope the user never needs more than 256 pairs. This is not great, though, because Durdraw displays the entire 256 color palette on the screen at once. This means that all 256 color pairs are already in use. As an artist, I like seeing the entire palette at once and don't want to trade away that feature. So I am not crazy about this idea. (It might work nicely for RGB colors, though.)

2: Use a Python build that actually works with extended color pairs. I have not been able to get my hands on one yet, but this is the direction I have been leaning. We can wait for OS vendors and Python core developers to dsitribute Python binaries compiled correctly against the Ncurses 6 ABI, and fix the bugs with extended color pair reporting. This would be nice, but we don't seem to be there yet.

3: Steer away from using Ncurses all together for generating color escape codes. They might be able to be injected with puts() or something, but this breaks ncurses convention and may break across different ncurses versions. Or, ncurses might be replaced with another library completely. This would be a lot of work with refactoring and rewriting Durdraw code. It might also break some portability. I don't like this option, either. :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.