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

fix random color on minimal values #2273

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

godlatro
Copy link

Summary

Fix for color generation function to not create colors from 5 characters for indicators

@@ -1,3 +1,3 @@
export default function () {
return `#${((Math.random() * 0xffffff) << 0).toString(16)}`;
return `#${(Math.floor(Math.random() * (0xFFFFFF - 0x100000 + 1)) + 0x100000).toString(16)}`;
Copy link
Member

@xmatthias xmatthias Jan 27, 2025

Choose a reason for hiding this comment

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

What's the exact bug you're trying to fix?
are you sure this still allows for the full range of colors?

unless i'm mistaking (and based on my testing) - this won't allow for any 0x0..... codes anymore.

if it's for "too short" values (which seem to be possible with very low values - and is my assumption for what this aims to fix) - maybe
Math.floor(Math.random() * 0xffffff).toString(16).padStart(6, '0') is a better solution?

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.

2 participants