Introducing PALE (Picture & Animation Library for Emacs)

I have been trying to push the limits of #Emacs to do real-time graphics since I started working on Emacs Reader (~1 year).

Emacs Reader has to do a lot of hacks to be efficient in performance, and in doing so we encountered memory leaks of horrible kinds (in Emacs itself), GC overloading of strings and other issues.

Finally over the last month or so, I decided to build a graphics library called PALE for Emacs which will leverage dynamic modules for efficiency. And here's the result, the animation below is hardware-accelerated, i.e the textures are rendered on GPU and then displayed on Emacs.

There are jitters here and there, but I still have a lot of room for optimization (I think!). The library will provide an API similar to svg.el, on top of that I will provide a C API so that dynamic module packages like Reader can directly provide image data from C and use it.

Right now it lives inside Emacs Reader's git, but it will eventually be separated:

https://codeberg.org/divyaranjan/emacs-reader/src/branch/partial-rendering/pale

Note: I haven't yet pushed code that integrates with EGL and OpenGL which is used in the demo, I'm still cleaning it up.
Some trippy gradient animation:
And a new screensaver, circa 2007:

Okay another serious breakthrough. After declaring PALE yesterday I stupidly wondered if I can hook this to ffmpeg to decode a video in realtime and play it.

Bloody hell it worked. #Emacs is actually rendering a full video in your ordinary text buffer, no xwidgets nothing.

I cannot still believe my eyes.

The library has been separated from Reader:

https://codeberg.org/pale/pale

pale

Picture and Animation Library for Emacs

Codeberg.org
I fixed a whole chunk of flickering and now it is 30FPS smooth!
@divyaranjan Amazing!
@tiang Right?! I am still not sure if this is a dream even though my commits tell me it is not!

@tusharhero @divyaranjan

Wth are you guys doing.
People on the other side (IDEs) will laugh at us

@lens_r I've seen this a couple other places, but I just don't understand why it hasn't generated more excitement.

@tusharhero @divyaranjan

@jameshowell @lens_r @divyaranjan Are you talking about Bad Apple? Or PALE? Or the emacs-reader demos we have been sharing?

@tusharhero I was referring to my surprise that the video-in-text-buffer stuff hasn't made more buzz.

But I am also on record admiring emacs-reader, where my noting the lack of attention was, I hope, implicit.

@lens_r @divyaranjan

@jameshowell @tusharhero @divyaranjan maybe someone from #orgmode #emacs would get a kick out of directly embedding gifs/videos into educational documents, or even displaying manim animations written in an org babel block 👀
@lens_r @jameshowell @divyaranjan I was thinking an Emacs client for GNU Octave
@tusharhero @jameshowell @divyaranjan I just played with octave and I would absolutely love an Emacs client for it
@jameshowell @lens_r @tusharhero Maybe because it feels too good to be true? :)
@divyaranjan Ooh! Can we use it to add arbitrary text decoration in standard text buffers, or does it have to live in a PALE specific buffer?
@pdcawley Arbitrary text buffers! You can ask Pale to only take a certain region of the buffer and you can continue doing other stuff in the same buffer. Pale has no notion of a special buffer.