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

isDark() returns true regardless of color passed #3

Open
stam66 opened this issue Mar 6, 2022 · 1 comment
Open

isDark() returns true regardless of color passed #3

stam66 opened this issue Mar 6, 2022 · 1 comment

Comments

@stam66
Copy link
Contributor

stam66 commented Mar 6, 2022

using isDark() or isLight() fails to discern light or dark colours.

These are based on getBrightness()

getBrightness calls private function _fixRGB pRGB

private function _fixRGB pRGB returns text triplet

getBrigthness pRGB expects an array but calls _fixRGB which returns a triplet!

So then in getBrightness fails because tRBG is a text triplet, but getBrightness uses this as an array:
return (tRGB["r"]* 299 + tRGB["g"]* 587 + tRGB["b"]* 114) / 1000

@stam66 stam66 changed the title isDark returns true regardless of color passed isDark() returns true regardless of color passed Mar 6, 2022
@stam66
Copy link
Contributor Author

stam66 commented Mar 6, 2022

in addition to the above issue which is easily solvable, the other issue is that isDark() takes a parameter but does not pass this parameter to getBrightness(), which itself can either take a parameter or this can be empty, in which case the sColor provides the RBG values.

This means that whatever value isDark(pRGB) is called with is irrelevant, it will always return a result for getBrightness(sColor). isLight() is defined as not isDark() and doesn't even take a parameter to pass.

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

1 participant