Comments (7)
What hue would you suggest gray has? The reason why you get an undefined hue (none
) is because the color is achromatic and has no hue.
from color.js.
I suggest use 0
instead none
when color stringify. So, I expect hsl(0 0% 50.196%)
but not a hsl(none 0% 50.196%)
Because converting color with none
to other format is another issue:
(new Color("hsl(none 0% 50.196%)")).to("srgb").toString()
>>> 'rgb(none none none)'
but with 0
instead none
it works corretly:
(new Color("hsl(0 0% 50.196%)")).to("srgb").toString()
>>> 'rgb(50.196% 50.196% 50.196%)'
from color.js.
none
is now supported in the CSS spec and has been implemented in a number of browsers. Gray doesn't actually have a red (0deg) hue, but regardless of technicalities of what is more correct, I can imagine some people desiring a way to serialize without none
. There was an option to do so for some amount of time, but it was removed in e28cd6a.
Below does look like a bug to me though. Undefined values should be handled before conversion, but that does not appear to be happening currently.
new Color("hsl(none 0% 50.196%)").to("srgb").toString()
>>> 'rgb(none none none)'
from color.js.
I just fixed problem for a while with a .toString().replaceAll("none", "0")
after any stringify.
from color.js.
I personally think an option to allow omitting none
in serialization seems reasonable, but thenone
conversion issue should definitely get fixed.
from color.js.
I've created a PR (#476) to adjust the bad "none" handling across the library.
@svgeesus and @LeaVerou would need to make a decision on whether it is desired to expose conditional "none" serialization. If they decided that they wanted to move forward with this, I'd be happy to make the PR.
from color.js.
Related Issues (20)
- [apps/picker] App is broken HOT 2
- Discord server for Color.js HOT 4
- [chore] Add core maintainers to footer
- Add error codes to all throws clauses
- [chore] Use typedoc for API docs HOT 1
- Avoid needless two-step color conversion at the start of gamut mapping HOT 2
- Ensure HSL is spec compliant HOT 3
- Live editing broken in docs HOT 16
- Should gamut mapping be done in the gamutSpace of a color space?
- (Some) nonstandard color spaces error when round-tripping HOT 4
- [chore] Separate website from library HOT 1
- New method: `deltas()` HOT 3
- How should angle coordinates be handled in nonstandard color spaces HOT 9
- Support `rec2100-linear`? HOT 1
- Docs: getAll(), setAll() HOT 2
- Docs: mapping of color space names - CSS space ids/function names, Color.js serialized, and Color.js space ids HOT 6
- Document `getAll()` and `setAll()` HOT 1
- Carrying forward analogous components in color interpolation HOT 5
- New API to normalize color values without NaN. 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.js.