-
Notifications
You must be signed in to change notification settings - Fork 1
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
hex() helper function #12
Comments
I would do a pull request but am pretty sure that there is a better way to do this with your setup. I have not had time to familiarize myself with how you setup the code. |
I had considered this at one point but was undecided as to whether a hex helper would be best for converting hex strings to color objects or vice versa... Let me think on this a little more. For now, color objects actually expose a
|
I should have mentioned that I tried that method. But with color that have an alpha channel, it does not return the correct hex value. It appends an |
Oh I see... As of 72ebf7e this package supports rrggbbaa hex notation (caniuse, MDN), so that For better or worse, this was added primarily so that For the moment a (less than ideal) workaround would be to adjust the alpha value manually before calling $color = color('rgba(102, 51, 153, 0.5)');
$hexWithAlpha = $color->toHexString(); // "#66339980"
// ...
$hexWithoutAlpha = $color->with(['alpha' => 1.0])->toHexString(); // "#663399"
// OR
$hexWithoutAlpha = rgba($color, 1.0)->toHexString(); // "#663399" |
What about adding a
hex()
helper function? Something like this...The text was updated successfully, but these errors were encountered: