Releases: DanielMartinus/Konfetti
v1.2.2 & v1.2.3
This release adds the option to control the acceleration of the particles
Pull request: #158
Issue: #48
Turn off acceleration
Only turning off the acceleration will result the particles having the same velocity they begin with. This can be done with:
konfettiView.build()
...
.setAccelerationEnabled(false)
Set max acceleration
If you don't want the particles to keep the speed they begin with but have a slight change in velocity for a more natural feeling, you can use setMaxAccelaration.
konfettiView.build()
...
.setMaxAcceleration(1.5f)
A maxAcceleration between 1.0 - 3.0 is visible in the lifetime of a particle
v1.2.1
Added
- ae8ca95 Stream for an indefinite amount of time when using
streamFor
by using StreamEmitter.INDEFINITE - a8cf9d1 Stop all particles from rendering gracefully and live out their lifetime by calling
stopGracefully()
on KonfettiView or a RenderSystem - 3f04a65 KonfettiView can now be extended since it's made
open
- 7f7e8c7 Disable 3D rotations of the confetti particles by calling
.setRotationEnabled(false)
Fixes
- caf8992 Fix streamMaxParticles isFinished check
v1.2.0
Added
- (#129) Add custom drawables as confetti thanks to @mattprecious
Changes
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)
v1.1.3
v1.1.2 Update dependencies
New contribution from @jurriaan
Enhancements
- (#50) Update build-tools, kotlin version and dependencies
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
v1.1.1
Small release with a couple of enhancements
Added
- (#44) Add another way of setting colors to the ParticleSystem by @simon1573
Enhancements
- (#45) Deprecate
stream
functions, replaced by:streamFor
andstreamMaxParticles
as suggested by @PaulWoitaschek here: #32 - (#46) Changed
direction
todegrees
as suggested by @PaulWoitaschek here: #33
v1.1.0
Added
Fixed issue
- (#20) setting amount for particles per second didn't work. Issue reported by: @anpez
- (#18) Remove
allowBackup="true"
andandroid:supportsRtl="true"
issue reported by: @foxware00 - (#13) object allocation in onDraw. Move RectF creation outside of the rendering block. Issue reported by: @nekocode
Removed
- (#23) Single parameter, particles per second. This function was useless until a stop function is build in the particle system.
- (#22) Three parameters, particles per second, emiting time, max particles. You are able to achieve the same results with either
.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 👏
Custom emiter
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())
1.0.2
Added
- (#12) Implement new size system.
Instead ofSize.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. - (5d8d4f6) Remove support library from konfetti library fixing the need of a resolutionStrategy to forcefully set the support library to the same version as the one using in your app.
1.0.1
1.0
Initial release 🎉 🎊