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

Wrong behavior when using an alpha color #18

Open
Jhiertz opened this issue Apr 27, 2023 · 2 comments
Open

Wrong behavior when using an alpha color #18

Jhiertz opened this issue Apr 27, 2023 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@Jhiertz
Copy link

Jhiertz commented Apr 27, 2023

Hi, thank you for this compose library

I've got an issue when using a colour with an alpha in waveformBrush, the alpha is also carried over to the progressBrush.

A small example to reproduce:

var waveformProgress by remember { mutableStateOf(0F) }

AudioWaveform(
    amplitudes = amplitude,
    waveformBrush = SolidColor(Color.White.copy(alpha = .5f)),
    progressBrush = SolidColor(Color.Red),
    amplitudeType = AmplitudeType.Max,
    progress = waveformProgress,
    onProgressChange = { waveformProgress = it }
)

And here is the actual rendering, the red does not match, it also has the alpha channel

image

@lincollincol lincollincol self-assigned this Aug 6, 2023
@lincollincol lincollincol added the bug Something isn't working label Aug 6, 2023
@IbrahimEzzatSaad
Copy link

is there any updates on those bugs?

@antweb
Copy link

antweb commented Sep 25, 2024

If you are just using the alpha value to get a specific color and don't actually need the transparency, you can work around this by creating a solid color with compositeOver:

// The color behind the waveform
val background = MaterialTheme.colorScheme.background

AudioWaveform(
    amplitudes = amplitude,
    waveformBrush = SolidColor(Color.White.copy(alpha = .5f).compositeOver(background)),
    progressBrush = SolidColor(Color.Red),
    amplitudeType = AmplitudeType.Max,
    progress = waveformProgress,
    onProgressChange = { waveformProgress = it }
)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants