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

Allow using Compose Brush for tint #397

Open
Skaldebane opened this issue Nov 10, 2024 · 2 comments
Open

Allow using Compose Brush for tint #397

Skaldebane opened this issue Nov 10, 2024 · 2 comments

Comments

@Skaldebane
Copy link

Skaldebane commented Nov 10, 2024

Hi there! Thanks for the awesome library.

I'm not sure if there's any technical hurdles, but I think replacing the current tints API where we provide multiple HazeTints with an API where HazeTint itself takes a gradient brush would be pretty awesome.

That'll make it easy to customize the gradient, and make the API feel a lot more natural and easier to use.

This is what I envision the API to look like:

hazeChild(...) {
    // single color overload
    tint = HazeTint(
        color = Color.Blue.copy(alpha = .3f),
        blendMode = ...
    )
    // Brush overload
    tint = HazeTint(
        brush = Brush.verticalGradient(
            Color.Green.copy(alpha = .3f),
            Color.Blue.copy(alpha = .3f)
        ),
        blendMode = ...
    )
}

Because it's tedious to add the .copy(alpha = ...) to every color, I'd suggest adding an opacity parameter (to both versions):

hazeChild(...) {
    // single color overload
    tint = HazeTint(
        color = Color.Blue,
        opacity = .3f,
        blendMode = ...
    )
    // Brush overload
    tint = HazeTint(
        brush = Brush.verticalGradient(Color.Green, Color.Blue),
        opacity = .3f,
        blendMode = ...
    )
}

This design would also enable us to define better fallback tints using the same HazeTint class, e.g. replacing a progressive blur with a translucent gradient, but that's a separate issue (#398).

That's all! Would love to hear your thoughts on this, and thanks for the great work!

@chrisbanes
Copy link
Owner

I think this is better handled at the backward-compatibility layers for mask and/or progressive, which is already covered by #400

@chrisbanes chrisbanes closed this as not planned Won't fix, can't repro, duplicate, stale Nov 10, 2024
@Skaldebane
Copy link
Author

Great to see fallback fixed! However, this was more of a general feature about applying a gradient tint to the blur (not fallback).

@chrisbanes chrisbanes reopened this Nov 10, 2024
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