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

Support slide animations and transitions #364

Open
orhun opened this issue Sep 9, 2024 · 4 comments
Open

Support slide animations and transitions #364

orhun opened this issue Sep 9, 2024 · 4 comments

Comments

@orhun
Copy link
Contributor

orhun commented Sep 9, 2024

Hello 👋🏼 First of all thanks a lot for the great presentation tool, I'm currently using it for my upcoming EuroRust talk :)

One thing that I felt missing (after switching to presenterm from Google Slides (ugh)) is the slide transitions such as fade in/out. I know this possible to do in the terminal thanks to the tachyonfx project. I'm not aware of any other library.

However, tachyonfx is built for Ratatui applications and I see that presenterm only depends on crossterm. But I believe it still should be implementable. I'm interested in working on this, so let me know what you think!

Inviting @junkdog to the discussion as the author of tachyonfx.

@mfontanini
Copy link
Owner

Hey, thanks! Love to hear people are using presenterm on conference presentations ❤️.

Adding transition effects sounds good to me! I wouldn't go far out and support lots of them though, just some simple fade in/out or a sort of "swipe horizontally to next/previous slide" would make sense. I'm not sure how this works around images though. I can imagine a swipe animation would work but a fade in/out one may not work / may only work under the kitty graphics protocol.

@orhun
Copy link
Contributor Author

orhun commented Sep 9, 2024

Thanks for the reply :)

I totally agree, adding simple transitions would be more than enough. Have you had time to look at how tachyonfx works? I wonder if we can use it (or re-use some parts) from there. 🤔

@junkdog
Copy link

junkdog commented Sep 11, 2024

Hi 👋🏼,

Neat project! I looked around for something similar a couple of years ago but came up empty.

I originally envisioned tachyonfx as having multiple backends, but the existing code (extracted from glim) was already tightly coupled with ratatui, and going straight for multiple backends felt a bit premature. Maybe it could be worth revisiting, but in any event - feel free to take whatever holds up to scrutiny or looks useful.

tachyonfx is pretty simple: it mostly works as a "post-processing" step, i.e. the effects are applied after the widgets have been rendered. As such it expects a shared intermediate screen buffer to read from and write to.

While effects can run "standalone", they are typically composed of multiple effects, usually employing a sequence or parallel effect as the root. This is maybe not necessary if you're going for simpler transitions, but I find that many transitions tend to look better when they combine multiple effects.

Effects are applied to a given area. CellFilters can be used to further refine which cells within the given area the effect is applied to:

let margin = Margin::new(1, 1);
let border_text        = AllOf(vec![Outer(margin), Text]);
let border_decorations = AllOf(vec![Outer(margin), Not(Text.into())]);

parallel(&[
    sequence(&[
        with_duration(short_duration, never_complete(fx::dissolve(0))),
        fx::coalesce((duration, BounceOut)),
    ]),
    fx::fade_from(Dark0, Dark0, duration)
]).with_cell_selection(border_decorations)

I'm quite happy with how CellFilters worked out. They bring a lot of flexibility without much complexity.

The only "optimization" tachyonfx performs is that some effects memoizes the previous cell's color transformation. This speeds up e.g. fade effects, avoiding many identical RGB->HSL->RGB translations.

@orhun
Copy link
Contributor Author

orhun commented Sep 23, 2024

Hey again @junkdog, thanks for the reply. Things are more clear after diving into the code a bit (hint: #10) and your explanation!

As such it expects a shared intermediate screen buffer to read from and write to.

Very interesting, is it a generic buffer or something like Ratatui's Buffer type? 👀

I'm wondering if it would be somehow possible to use tachyonfx core rendering capabilities (along with CellFilters) in presenterm to create basic fade animations. Do you think it would be possible?

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

No branches or pull requests

3 participants