DanielMartinus / Konfetti

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

Custom DrawableShape (PNG drawable) displays incorrectly #298

Closed MatthewCallery closed 1 year ago

MatthewCallery commented 2 years ago

Using a PNG drawable to create a custom DrawableShape with tint = false results in the drawable being displayed as though a white tint has been applied (see video below along with the PNG file I'm using).

Environment

Device: moto g31(w) Android version: 11 Konfetti: nl.dionsegijn:konfetti-compose:2.0.2

Code

@Composable
fun EmojiRain(
    @DrawableRes drawables: List<Int>,
    onEnd: (() -> Unit)?,
    modifier: Modifier = Modifier
) {
    val shapes = drawables.mapNotNull {
        ContextCompat.getDrawable(LocalContext.current, it)?.let { drawable ->
            Shape.DrawableShape(drawable = drawable, tint = false)
        }
    }

    KonfettiView(
        parties = listOf(
            Party(
                angle = Angle.BOTTOM,
                spread = 1,
                rotation = Rotation(
                    enabled = true,
                    multiplier2D = 1f,
                    multiplier3D = 0f,
                ),
                speed = 1f,
                maxSpeed = 6f,
                damping = 1f,
                timeToLive = 2000L,
                size = (12..42 step 6).map { Size(it) },
                shapes = shapes,
                emitter = Emitter(duration = 2, TimeUnit.SECONDS).perSecond(10),
                position = Position
                    .Relative(0.0, 0.0)
                    .between(Position.Relative(1.0, 0.0)),
            )
        ),
        updateListener = object : OnParticleSystemUpdateListener {
            override fun onParticleSystemEnded(system: PartySystem, activeSystems: Int) {
                onEnd?.invoke()
            }
        },
        modifier = modifier,
    )
}

Video of issue

https://user-images.githubusercontent.com/13498475/168575719-75eff0e2-d48d-44ef-a386-55f7ee898a92.mp4

PNG drawable

emoji_thumbs_up

MatthewCallery commented 2 years ago

I have a fix for this. I'll submit a PR

DanielMartinus commented 1 year ago

A PR has been merged addressing this issue

DanielMartinus commented 1 year ago

Fixes has been released in version 2.0.3