partofthething / infopanel

Show live data, animations, pictures, or anything on simple displays like RGB matrices
https://partofthething.com/infopanel/
GNU General Public License v3.0
31 stars 12 forks source link

Advanced scrolling text #7

Open fedus opened 6 years ago

fedus commented 6 years ago

Hello,

first of all thanks for having created such an awesome project! I have actually forked the project locally and heavily modified it to have additional features (animated transitions between scenes, ability to specify whether a sprite should loop or not, whether it should autostart playing or not, and much more "under the hood" stuff). I hope to publish it at some point, or even add pull requests to this project. Again, thanks for the amazing base!

Now to my actual question: I was wondering how to properly implement advanced scrolling text sprites. What I mean is that one could define a textbox area, for simplicity let's say we want our text be 20px wide. Then, if the actual text we want to display is shorter than 20px, it will display statically, without no animation. If it is longer, it will scroll, but WITHIN the designated 20px. This is thus opposed to a normal FancyText which is not bound to any specifc box but takes the whole screen.

Is that something that you might include in future releases? Or do you have any ideas on how to implement it 'cleanly'? I was thinking of creating individual PIL canvases that match the desired textbox size and animate the text on those canvases. Finally, the canvas will be pasted onto the "main" image/canvas. Any thoughts?

Cheers!

partofthething commented 6 years ago

Hey, thanks! Glad to hear you've taken this and run. If you can package up a PR or two that'd be awesome.

Regarding the bounded text request, yeah that sounds totally reasonable to include. It's something I could work on for sure but I'm not sure what timeframe that would be. In terms of best way to implement, that's hard to say. I'd probably just start out with a new sprite that has the config needed (define the box) and then just get it working.

Likely a composite design pattern is the most correct way to do this kind of thing so we can arbitrarily nest things but at these resolutions I think that's something we can start worrying about when it becomes a problem ;)

fedus commented 6 years ago

Thanks for your answer!

I will have more time from next week on to work on this, and will try to suggest corresponding pull requests for the size-limited scrolling text and a couple other things.

Also, as an FYI, as far as the animated transitions between scenes are concerned, this required some "substantial" changes. One of these is the fact that everything is now Pillow based in order to facilitate drawing frames from two scenes at the same time and merging them in one final buffer for the LED panel (think of a swipe-up animation). For example, text is now not drawn using the Matrix library anymore, but with Pillow's ImageFont module, and so on (which also required some changes to the helpers etc.). Of course thanks to the composite design pattern, sprites and scenes did not have to be changed. The impact on CPU and FPS on a Raspberry 3 was not significant (as you said, at these resolutions there's some leeway;) ) Regarding the transitions, I'd also be more than happy to share my work if people are interested.

Cheers! And thanks again for the great project. :)