Comments (3)
HSL support has been added in #33 :)
from color.
For other color systems: PR's welcome!
from color.
Hex: #530005ff not support
ff = round(hexdec(substr($hex, 6, 2)) / 255, 2)
my convert alpha hex code:
$color = "#530005ff";
if (strpos($color, '#') !== false) {
$hex = str_replace('#', '', $color);
$length = strlen($hex);
$r = 255;
$g = 255;
$b = 255;
$a = 1;
if ($length === 3) {
$r = hexdec(substr($color, 0, 2));
$g = hexdec(substr($color, 2, 2));
$b = hexdec(substr($color, 4, 2));
} else if ($length >= 6) {
$r = hexdec($length >= 6 ? substr($hex, 0, 2) : ($length == 3 ? str_repeat(substr($hex, 0, 1), 2) : 0));
$g = hexdec($length >= 6 ? substr($hex, 2, 2) : ($length == 3 ? str_repeat(substr($hex, 1, 1), 2) : 0));
$b = hexdec($length >= 6 ? substr($hex, 4, 2) : ($length == 3 ? str_repeat(substr($hex, 2, 1), 2) : 0));
}
if ($length == 8) {
$a = round(hexdec(substr($hex, 6, 2)) / 255, 2);
}
return 'rgba(' . $r . ',' . $g . ',' . $b . ',' . $a . ')';
}
Hope to help your
from color.
Related Issues (20)
- BUG : Hex color to HSL HOT 3
- I have list of hex colors when want a unique HOT 1
- Converting Hex to Hsl for #000 & #fff gets division by zero HOT 1
- Support alpha channel for HEX colors
- Support 3 digit hex values
- Error in CIELab regexp
- Incorrect conversion from HEX to HSL* with this color. HOT 4
- Support opacity in all color types
- Idea: Add opacity support to Hex colors HOT 1
- Wrong version in `composer.json` (1.3.0 instead of 1.4.0) HOT 1
- Could not find package spatie/color in a version matching "1.4.0" HOT 1
- Convert to CMYK HOT 1
- Problem with opacity in rgba color HOT 1
- HSLA -> RGBA looses transparency value HOT 2
- RGB and RGBA should accept % values HOT 1
- Constructive bound checking on RGB/RGBA values HOT 1
- Define a common 'opacity' value for each color instance HOT 1
- Add LCH support
- Bug Division by Zero Rgb to Cmyk HOT 1
- toHSL Uppercase letters Bug? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from color.