devottys / darkdraw

unicode art and animation in the terminal
Other
63 stars 4 forks source link

How to import data? #11

Open bryce-carson opened 2 years ago

bryce-carson commented 2 years ago

Dark Draw is nice, but it can be challenging to get a drawing started. It would be helpful to import existing drawings made in other tools. Is there any facility for this in Visidata with the Dark Draw plugin?

saulpw commented 2 years ago

What formats would you like to support? We can write a loader or converter for them specifically.

bryce-carson commented 2 years ago

It would be nice to get REXPaint's binary file format (.xp) imported directly, or one or two of its other supported export formats:

  • Export .ANS files for ANSI art
  • Other exportable formats: TXT, CSV, XML, XPM, BBCode, C:DDA
    From `REXPaint-README.txt` for version v1.60

There are a number of other utilitites for converting to or from XP format, such as png2rex.

As an example, I used png2rex to convert the Spacemacs logo into XP format, and it has come out quite nicely. Extending the "base" ASCII art with Unicode (a wonderful feature of Dark Draw 2!), and then animating it would be great.

Screenshot from 2022-05-17 18-07-11

saulpw commented 2 years ago

What does the exported csv from rexpaint look like? Can you paste the first few lines from that here?

I think loading/saving .ANS is reasonable. And did you know that you can save .png from DarkDraw (it renders using the unifont) already?

bryce-carson commented 2 years ago

Here's the first ten lines of an exported CSV. It's quite simple! :)

X,Y,ASCII,Foreground,Background
0,0,219,#000000,#000000
1,0,219,#000000,#000000
2,0,219,#000000,#000000
3,0,219,#000000,#000000
4,0,219,#000000,#000000
5,0,219,#000000,#000000
6,0,219,#000000,#000000
7,0,219,#000000,#000000
8,0,219,#000000,#000000

I didn't know DarkDraw could export to PNG! That's nice. I see myself using it in the terminal, however. Emacs renders drawings 1:1, I believe, when used in the terminal and my experimental lisp file to import DarkDraw-ings.

Screenshot from 2022-05-13 15-30-03

My goal is to prettify the ASCII art that's displayed in Spacemacs' home buffer when used in the Terminal.

saulpw commented 2 years ago

Thanks @bryce-carson. This format would be really easy to convert in VisiData. We just need a function to convert #RRGGBB hex values into terminal colors, and then we can make a little .vdj script to convert to .ddw.

bryce-carson commented 2 years ago

@saulpw I should note that by default, REXPaint uses Code Page 437! I'm struggling with a conversion from cp437 to UTF-8 in Emacs Lisp at the moment, so I thought to make sure you were aware of this default of REXPaint.