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

colordiff not work with all colors? #437

Closed
cormullion opened this issue Aug 23, 2020 · 5 comments · Fixed by #439
Closed

colordiff not work with all colors? #437

cormullion opened this issue Aug 23, 2020 · 5 comments · Fixed by #439

Comments

@cormullion
Copy link
Member

Just wondering why colordiff doesn't work with all colors?

julia> using Colors
julia> colordiff(RGBA(0.35, 0.18, 0.90, 1), RGBA(0.34, 0.18, 0.90, 1))
ERROR: MethodError: no method matching colordiff(::RGBA{Float64}, ::RGBA{Float64})
Stacktrace:
 [1] top-level scope at none:1

There's probably a good reason, but I'm interested to know what it is.

Colors v0.12.3, Julia 1.5.0

@kimikage
Copy link
Collaborator

cf. #250

@cormullion
Copy link
Member Author

Yes, I kind of see. Although the alpha values are 1 here.

@kimikage
Copy link
Collaborator

kimikage commented Aug 23, 2020

It is possible to provide special treatments for transparent colors when the alpha values are 1, but I don't see the need to do that. If the users know that the alpha values are always 1, they can use color().

I think what we need to do is to improve the error message.

@cormullion
Copy link
Member Author

I suppose you could do something like:

function colordiff(ai::RGBA, bi::RGBA;
        metric::DifferenceMetric=DE_2000()) 
    if ai.alpha != 1 || bi.alpha != 1
        @warn "Ignoring alpha value of transparent colors..."
    end
    _colordiff(convert(RGB, ai), convert(RGB, bi), metric)
end

just to help people keep working. The warnings could prompt them to change their code... :)

@johnnychen94
Copy link
Member

This could print thousands of warnings if it's an image...

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 a pull request may close this issue.

3 participants