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

Fixed invisible label view in label constructor #5041

Merged
merged 3 commits into from
Oct 5, 2022

Conversation

bsekachev
Copy link
Member

@bsekachev bsekachev commented Oct 4, 2022

Motivation and context

Related #5031

Before:
image

After:
image

How has this been tested?

Checklist

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

@bsekachev bsekachev changed the title [WIP] Fixed invisible label view in label constructor Fixed invisible label view in label constructor Oct 4, 2022
@bsekachev bsekachev requested a review from klakhov October 4, 2022 20:14
@bsekachev
Copy link
Member Author

/check

@github-actions
Copy link
Contributor

github-actions bot commented Oct 4, 2022

❌ Some checks failed
📄 See logs here

@bsekachev
Copy link
Member Author

/check

@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2022

❌ Some checks failed
📄 See logs here

@nmanovic
Copy link
Contributor

nmanovic commented Oct 5, 2022

/check

@github-actions
Copy link
Contributor

github-actions bot commented Oct 5, 2022

✔️ All checks completed successfully
📄 See logs here

Copy link
Contributor

@klakhov klakhov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good job, bright labels are visible now 😃

Comment on lines +31 to +32
const grayscale = (parseInt(r, 16) + parseInt(g, 16) + parseInt(b, 16)) / 3;
if (grayscale - 128 >= 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you think about using something like HSL?

let [r, g, b] = [backgroundColor.slice(1, 3), backgroundColor.slice(3, 5), backgroundColor.slice(5, 7)];
r = parseInt(r, 16) / 255;
g = parseInt(g, 16) / 255;
b = parseInt(b, 16) / 255;
const CMax = Math.max(r, g, b);
const CMin = Math.min(r, g, b);
const lightness = (CMax + CMin) / 2;
if (lightness - 0.85 >= 0) {
      textColor = '#000000';
}

HSL:
image
RGB variant:
image

Personally I liked first variant more.

@bsekachev bsekachev merged commit e7c1606 into develop Oct 5, 2022
@bsekachev bsekachev deleted the bs/fixed_issue_with_lbl_color branch October 5, 2022 13:53
@nmanovic nmanovic mentioned this pull request Dec 12, 2022
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.

3 participants