Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

acii art renderer #2353

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

acii art renderer #2353

wants to merge 11 commits into from

Conversation

DrSensor
Copy link

@DrSensor DrSensor commented Feb 14, 2025

/claim #924
close #924

see docs/**.txt for the examples output

```fish
for f in docs/**.d2
  set -l dir (dirname $f)
  set -l name (basename $f .d2)
  if [ $name = "in" ]
      set name out
  end
  if [ $name = "input" ]
      set name output
  end
  go run main.go $f $dir/$name.txt
end
```
@DrSensor
Copy link
Author

DrSensor commented Feb 14, 2025

still quite big though 😅
maybe caused by default padding 🤔

let me know if you have some request

Copy link
Collaborator

@alixander alixander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah these are too large. I'm looking for diagrams that can be inlined into code. There should be no padding too.

I'm not quite sure how that can be achieved, because the layout engine gives a certain layout with those long lengths of edges. Shortening those edges would lead to overlaps of objects/text. The bounty placed on the issue is reward for solving that problem.

@DrSensor
Copy link
Author

DrSensor commented Feb 17, 2025

apparently treating it as image processing problem works!
so just resize it like you resize an image.

However,

  • It will miss some details when encountering diagonal lines but it should be possible to reconstruct those diagonal lines.
    (TODO: should try other layout engine that doesn't produce diagonal lines).
  • Unlike image, text/label in ASCII Art can't be resized. Some option to solve this:
    1. Truncate the text/label.
      example: d2exporter -> d2..ter.
    2. Move text/label to the top or bottom as long as it doesn't collide with the line/edge/connection.
    3. Use ID and Legend.
      example: a shape with text/label (a), then at the bottom of diagram explain that (a) is d2exporter.

@DrSensor
Copy link
Author

@alixander does the size looks reasonable to you?

(ignore the missing text/label, it's bug on my side 😂)

@alixander
Copy link
Collaborator

The size looks reasonable!

  1. ELK only uses orthogonal lines (no diagonals). If you can get it working with ELK only and ignore dagre (the layout engine you've been using), that's totally okay.
  2. Can you resize only to the point where labels would overflow?

@DrSensor
Copy link
Author

  1. Can you resize only to the point where labels would overflow?

It has the caveat that some diagram might get too wide, but sure.
I've been thinking to detect the smallest shape/rect and use it as the resize factor but using the longest label string.length would be much simpler.

@alixander
Copy link
Collaborator

also reasonable to add further constraints as you see fit, e.g. only rectangles

@alixander
Copy link
Collaborator

random inspiration

https://diagon.arthursonzogni.com/#GraphDAG

Screenshot 2025-02-16 at 10 13 49 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ascii art renderer
2 participants