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

Gray::toRgb rounding error #184

Open
AntonioDiPassio-AppSys opened this issue Sep 2, 2024 · 1 comment
Open

Gray::toRgb rounding error #184

AntonioDiPassio-AppSys opened this issue Sep 2, 2024 · 1 comment

Comments

@AntonioDiPassio-AppSys
Copy link

line 34:
return new Rgb((int) ($this->gray * 2.55), (int) ($this->gray * 2.55), (int) ($this->gray * 2.55));

If $this->gray is 100, it will return Rgb(254,254,254)

because PHP being weird and: (int) (100 * 2.55) = 254

Can be fixed by changing it to:
return new Rgb((int) ($this->gray * 255 / 100), (int) ($this->gray * 255 / 100), (int) ($this->gray * 255 / 100));

@DASPRiD
Copy link
Member

DASPRiD commented Sep 29, 2024

Feel free to supply a PR with a matching test :)

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

2 participants