-
Notifications
You must be signed in to change notification settings - Fork 20
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
rgba()->toHexa and hlsa()->toHexa not working as expected when alpha opacity #37
Comments
Did you have any repository on how to reproduce this bug? <?php
use OzdemirBurak\Iris\Color\Hexa;
$hex = new Hex('#b2b2b2');
$hexa = $hex->toHexa()->alpha(0.5);
?>
<div style="width: 100px; height: 100px; padding: 16px; word-wrap: break-word; background-color: <?= $hexa ?>;">
<?= $hexa ?>
</div>
<br/>
<div style="width: 100px; height: 100px; padding: 16px; word-wrap: break-word; background-color: <?= $hexa->toRgba() ?>;">
<?= $hexa->toRgba() ?>
</div>
<br/>
<div style="width: 100px; height: 100px; padding: 16px; word-wrap: break-word; background-color: <?= $hexa->toHsla() ?>;">
<?= $hexa->toHsla() ?>
</div>
<br/> |
You didn't reproduce the issue as the issued was described, however, even in your example, the colors are wrong, hover over them with a color picker, the difference is very slight, but it's there. Anyway, here's the issue more clearly, and the steps to reproduce it: For example, the correct HSLA equivalent for RGBA should have been: Here's the code for it:
|
Hi, thanks for the reproducing steps, I'll try to fix the issue today. |
Hmmm, this bug is interesting. |
Due to the presence of the alpha channel, division should be as precise as possible if you want to create such a feat. That is the best approach I could think of for now. |
If a 1:1 conversion is not possible, then I guess it's alright (at least for my use case this is good enough). The issue can be closed if you consider so. Thank you for the fix. |
I really need a color expert opinion on this, I will have a chat with my fellow designers to confirm whether this case is achievable or not. Thanks for your guidance on reproducing the issue! |
I think I've found out why it doesn't properly convert back to HLS.
|
It might took an extra work to the PR, let me try to figure it out. |
I've added the decimal parts, and I think it is working now. Could you please check @pricop? @NikarashiHatsu, I'm going to close #47 because I think there is no need to clone the colors, but I am still not sure. We can reimplement it if this one is not working. |
Sorry for the delay @ozdemirburak , I missed the notification. The issue is almost resolved, it's just HEXA that's still not working as expected. |
When converting an
rgba
orhlsa
color with alpha opacity value tohexa
, the result is not as expected (see attachment).The text was updated successfully, but these errors were encountered: