Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom DrawableShape (PNG drawable) displays incorrectly #298

Closed
MatthewCallery opened this issue May 16, 2022 · 3 comments
Closed

Custom DrawableShape (PNG drawable) displays incorrectly #298

MatthewCallery opened this issue May 16, 2022 · 3 comments
Milestone

Comments

@MatthewCallery
Copy link

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

konfetti_issue.mp4

PNG drawable

emoji_thumbs_up

@MatthewCallery
Copy link
Author

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

@DanielMartinus
Copy link
Owner

A PR has been merged addressing this issue

@DanielMartinus
Copy link
Owner

Fixes has been released in version 2.0.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants