DanielMartinus / Konfetti

Celebrate more with this lightweight confetti particle system 🎊
ISC License
3.13k stars 299 forks source link

Add support for Emoji/Text confetti Shapes #299

Closed jasonctoms closed 9 months ago

jasonctoms commented 2 years ago

It would be nice to have the ability add emojis to the confetti.

These updates only update the "engine" to support adding emojis. I have found that they look better without the 3D rotation, so in my own project I have changed that part of the rotation code to look like so:

particles.forEach { particle ->
                withTransform({
                    if (particle.shape is Shape.Text) {
                        rotate(
                            degrees = particle.rotation,
                            pivot = Offset(
                                x = particle.x,
                                y = particle.y
                            )
                        )
                    } else {
                        rotate(
                            degrees = particle.rotation,
                            pivot = Offset(
                                x = particle.x + (particle.width / 2),
                                y = particle.y + (particle.height / 2)
                            )
                        )
                        scale(
                            scaleX = particle.scaleX,
                            scaleY = 1f,
                            pivot = Offset(particle.x + (particle.width / 2), particle.y)
                        )
                    }
                }) {
                    particle.shape.draw(this, particle)
                }
            }

But I do not know if you want this part of the composable to be configurable or not. I am open to suggestions (if you even want to add emoji support).

I could not add anything to the samples since they use the pre built dependency, but here is a video of what it looks like from my own project:

https://user-images.githubusercontent.com/17356172/173049943-b30fe915-b789-453c-8402-6a295eb5b4bd.mp4

DanielMartinus commented 1 year ago

This sounds like a great idea. I would have to dive deeper into this and do some tests!

Sorry for replying a year later