chalk-diagrams / chalk

A declarative drawing API in Python
MIT License
282 stars 13 forks source link

Isometric Example #130

Closed srush closed 8 months ago

srush commented 8 months ago

Was playing around with 3d and thought this was a fun example based on the haskell isometric projection. In theory this could be a transform3d, but probably not worth the effort.

What might be fun is to replace transform with numpy generally... That would allow very fast scaling of trails,.

danoneata commented 8 months ago

Oh, neat! I should play with this sometime! I'll add the NumPy-based transform to the TODO list 🙂

Talking about other directions to investigate, I was thinking about animations. Would that be an useful feature to have? And if so, how difficult would it be to implement?

srush commented 8 months ago

Animations would be really cool... I'm a bit worried it would be really hard though. I have no idea how to render them, or if there is a way to dynamically update only part of the tree. It's also kind of annoying that SVG doesn't really support animations naturally. (I see there are some ideas in haskell though. )

This is Chalk, but I just rendered a lot of images and gif'd them together-> https://twitter.com/i/status/1757031261556629911

danoneata commented 8 months ago

Yes, your Drop7 demo might make a nice motivating example. Although it does look rather nice as it is 🙂

I see that in Haskell the idea for animations is quite simple: an animation is a time-varying diagram, implemented as a function from Time to Diagram (plus information regarding the start and end times). Even simple, this abstraction lends itself to many combinators, in particular, it is an Applicative. I'm not sure about its efficiency though: it doesn't look that there is any explicit sharing done across time. In terms of inspiration, it might also be worth taking a look at 3blue1brown's manim library.

I'm currently caught up with some deadlines, but I might be able to think about this in mid-March or so.