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

fix alpha on DrawableShape, on compose: add parameter to apply alpha or not #309

Conversation

laurentyhuel
Copy link
Contributor

Alpha on DrawableShape not had same behavior between Compose and XML View.

I used same parameter:

Party(
                    speed = 0f,
                    maxSpeed = 10f,
                    damping = 1f,
                    spread = 360,
                    size = listOf(Size(sizeInDp = 20, mass = 8f)),
                    shapes = listOf(
                        Shape.DrawableShape(AppCompatResources.getDrawable(context,R.drawable.img_conf_yellow_2)!!, false),
                        Shape.DrawableShape(AppCompatResources.getDrawable(context,R.drawable.img_conf_purple_1)!!, false),
                        Shape.DrawableShape(AppCompatResources.getDrawable(context,R.drawable.img_conf_purple_3)!!, false),
                        Shape.DrawableShape(AppCompatResources.getDrawable(context,R.drawable.img_conf_green_1)!!, false),
                        Shape.DrawableShape(AppCompatResources.getDrawable(context,R.drawable.img_conf_blue_1)!!, false),
                        Shape.DrawableShape(AppCompatResources.getDrawable(context,R.drawable.img_conf_red_2)!!, false),
                        Shape.DrawableShape(AppCompatResources.getDrawable(context,R.drawable.img_conf_purple_4)!!, false),
                        Shape.DrawableShape(AppCompatResources.getDrawable(context,R.drawable.img_conf_blue_2)!!, false),
                        Shape.DrawableShape(AppCompatResources.getDrawable(context,R.drawable.img_conf_red_1)!!, false),
                        Shape.DrawableShape(AppCompatResources.getDrawable(context,R.drawable.img_conf_yellow_1)!!, false),
                        Shape.DrawableShape(AppCompatResources.getDrawable(context,R.drawable.img_conf_purple_2)!!, false),
                        Shape.DrawableShape(AppCompatResources.getDrawable(context,R.drawable.img_conf_green_2)!!, false),

                        ),
                    emitter = Emitter(duration = 100, TimeUnit.MILLISECONDS).max(100),
                    position = Position.Relative(0.5, 0.3)
                )

And here the result:
confetti-xml-kotlin.webm
confetti-compose.webm

I think is same issue as #298

I could use a sealed interface instead of new boolean parameter but it break compatibility with older version:

data class DrawableShape(
        val drawable: Drawable,
        val transformation: DrawableShapeTransformation = DrawableShapeTransformation.Tint,
    ) : Shape {
        ...
    }


sealed interface DrawableShapeTransformation {
    object Tint : DrawableShapeTransformation
    object Alpha : DrawableShapeTransformation
    object None : DrawableShapeTransformation
}

@DanielMartinus
Copy link
Owner

DanielMartinus commented Jul 10, 2023

@laurentyhuel thanks for the fix, Appreciated! I did some testing and decided to merge the PR as it indeed solves the issue

@DanielMartinus DanielMartinus merged commit 575740e into DanielMartinus:main Jul 10, 2023
1 check passed
@laurentyhuel
Copy link
Contributor Author

@laurentyhuel thanks for the fix, Appreciated! I did some testing and decided to merge the PR as it indeed solves the issue

Oh great, do you plan a new release soon ?

@DanielMartinus
Copy link
Owner

@laurentyhuel yes, definitely! Working on it

@DanielMartinus
Copy link
Owner

New version is released: https://github.com/DanielMartinus/Konfetti/releases/tag/v2.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

Successfully merging this pull request may close these issues.

None yet

2 participants