Celebrate more with this lightweight confetti particle system 🎊
streamFor
by using StreamEmitter.INDEFINITEstopGracefully()
on KonfettiView or a RenderSystemopen
.setRotationEnabled(false)
Minor API change, old ones still work due to backwards compatibility.
Before | Becomes |
---|---|
Shape.RECT | Shape.Square |
Shape.CIRCLE | Shape.Circle |
Add a custom drawable like this:
val drawable = ContextCompat.getDrawable(context, R.drawable.star)
val star = Shape.DrawableShape(drawable)
viewKonfetti.build()
...
.addShapes(star)
.streamFor(300, 5000L)
If you want to keep the original colours of the drawable set tinting to false. This is by default set to true.
val drawable = ContextCompat.getDrawable(context, R.drawable.gradientDrawable)
Shape.DrawableShape(drawable, false)
Minor improvements in this release.
New contribution from @jurriaan
This update removes the following warning:
2.1/org.jetbrains.kotlin/kotlin-stdlib-jre7/1.2.0/ec8b969e26fbcf2265a4d1a1539c4d1d4c5af380/kotlin-stdlib-jre7-1.2.0.jar: kotlin-stdlib-jre7 is deprecated. Please use kotlin-stdlib-jdk7 instead
Small release with a couple of enhancements
stream
functions, replaced by: streamFor
and streamMaxParticles
as suggested by @PaulWoitaschek here: https://github.com/DanielMartinus/Konfetti/issues/32
direction
to degrees
as suggested by @PaulWoitaschek here: https://github.com/DanielMartinus/Konfetti/issues/33
allowBackup="true"
and android:supportsRtl="true"
issue reported by: @foxware00.stream(particlesPerSecond: Int, emittingTime: Long)
or .stream(particlesPerSecond: Int, maxParticles: Int)
I want to thank everyone who took the time to submit a pull request or reported an issue. Really appreciated 👏
With this pull request you're able to add your own custom emitter to Konfetti.
/**
* Created by dionsegijn on 9/03/17.
*
* An abstract class for creating a custom emitter
* The only goal of the emitter is to tell when and how many particles to create
*/
abstract class Emitter {
/**
* Call this function to tell the RenderSystem to render a particle
*/
var addConfettiFunc: (() -> Unit)? = null
/**
* This function is called on each update when the [RenderSystem] is active
* Keep this function as light as possible otherwise you'll slow down the render system
*/
abstract fun createConfetti(deltaTime: Float)
/**
* Tell the [RenderSystem] when the emitter is done creating particles
* @return true if the renderSystem is not longer creating any particles
* false if the renderSystem is still busy
*/
abstract fun isFinished(): Boolean
}
See BurstEmitter or StreamEmitter for examples
To start using your custom Emitter, call the following function in ParticleSystem
and supply it with your custom emitter:
/**
* Add your own custom Emitter. Create your own class and extend from [Emitter]
* See [BurstEmitter] and [StreamEmitter] as example classes on how to create your own emitter
* By calling this function the system wil start rendering the confetti according to your custom
* implementation
* @param [emitter] Custom implementation of the Emitter class
*/
fun emitter(emitter: Emitter) {
startRenderSystem(emitter)
}
Calling your custom emitter will look something like this:
viewKonfetti.build()
.addColors(Color.YELLOW, Color.GREEN, Color.MAGENTA)
... // other properties
.emitter(CustomEmitter())
Size.SMALL, Size.MEDIUM, Size.LARGE
add Size(12) for the size in dip or Size(12, 5f) to specify a mass and add as many sizes as you want.OnParticleSystemUpdateListener
Initial release 🎉 🎊