The actual name is Confetti, but one of my friends thinks that parfetti is a much more clever name.
In between intensely working on Robinhood Gold (in case anyone is wondering, that picture isn’t me, I wish that I signed up to be tattooed) and waiting on design/copy/everything to be finalized, I had some time on my hands to work on my second open-source project that will be used at Robinhood. I am happy to say that I released it today for all of you guys to try it out!
Eh, what is it?
In it’s simplest form, Confetti is a particle system/emitter library that can be configured to emit arbitrary confetti anywhere, any time. It’s easily customizable and very powerful. For example, you can specify any arbitrary emission source (a point or a line), any initial physics constraints (velocity, acceleration, rotation, etc.), and any implementation of the Confetto (yes, it’s actually a real word, and it’s the singular form of confetti), and the library will emit, display, and animate your specified confetti onto the screen!
Here’s a sample configuration for an explosion:
new ConfettiManager(context, generator, confettiSource, container)
And here’s the result:
You should read the Github README for more detailed documentation.
The primary way to customize this library for your use-case is to set the various configuration variables on the ConfettiManager to suit your animation needs. You can use a bitmap for your confetto, or provide a custom implementation of the Confetto class (see BitmapConfetto for an example implementation).
Some supported attributes include a fade-out behavior as the confetto reaches its bounds or TTL (time to live) and touch & drag. Here’s an example of the custom touch and drag behavior:
You can essentially use this library to power some of the cool popular features such as the flying hearts on Periscope or the falling money animation on Facebook Messenger.
We always care about performance at Robinhood. The confetti manager internally recycles confetto objects so that an infinite stream of confetti won’t wreck the device’s memory. Furthermore, since each confetto only needs to know how to draw the bitmap, you only need to allocate each bitmap (in the case of bitmap confetti) once. Finally, we pre-compute many required animation parameters (e.g. time to reach bound) so that the calculation for each animation update is super straightforward. All in all, you shouldn’t have to worry about dropped frames unless you have many many pieces of confetti on your screen at once.
Well, that’s all for now. Submit issues here if you have any feature requests or find bugs in the library. Happy Android-ing!