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

feat: take into account threshold for gradient calc #46

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

voidpls
Copy link

@voidpls voidpls commented Mar 11, 2022

When threshold is >1, gradient calculation doesn't take threshold into account. The "minimum" color of a gradient is often not the defined start of the gradient, depending on starboard config.

Fix works well in preliminary testing, but haven't extensively tested.

Also switches from Math.floor to bitwise flooring (~~), due to Math.floor not working properly with negatives

@SimonLeclere
Copy link
Owner

image

< hahaha

@SimonLeclere
Copy link
Owner

Why using +1 -1 ?

@voidpls
Copy link
Author

voidpls commented Mar 12, 2022

After order of operations, it's:
Math.max(Math.min(~~((stars - threshold +1) - ((1 / color.max )* color.colors.length)), color.colors.length - 1), 0);
Which is based off the original code. From testing, the logic appears to work correctly, but you should test yourself as well

@SimonLeclere
Copy link
Owner

My bad

@SimonLeclere
Copy link
Owner

I'm currently updating (and repairing the module), i'll merge your pr after that :)
Sorry for the delay lol

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