Comments (7)
- What happens if opacity is outside [0..1]? Should the hex value be clamped to [0..255]?
- How should the float value be coerced? Via round() or floor()?
Edit: The answers are "yes" and "round".
Lines 279 to 282 in 7d61bbe
from d3-color.
I believe formatHex()
is supposed to be a widely-compatible string representation of the color. 8-char hex notation does not benefit from the same support (e.g. Edge only gained it after switching to Chromium), so maybe a formatHex8()
is more suitable?
from d3-color.
Nice catch!
from d3-color.
Agree with @danburzo that we should add formatHex8 and not change formatHex which is documented as "in RGB space".
from d3-color.
shameless bump
from d3-color.
Another usecase for formatHex()
to maintain its current implementation is that the HTML <input type='color'>
only accepts 6-digit hex as a color format.
from d3-color.
Another usecase for
formatHex()
to maintain its current implementation is that the HTML<input type='color'>
only accepts 6-digit hex as a color format.
That’s fine, but an API that can do alpha would be useful, formatHex8
or something. I’m not too bothered if it can’t be this API as long as it’s supported somewhere.
maybe this issue should be changed to a feature request for that instead?
from d3-color.
Related Issues (20)
- d3.rgb doesn't parse HSL hues with `deg` units HOT 1
- Changing color.s changes luminosity and color.l saturation.
- Security vulnerability fix for d3-color required in version 2.x HOT 7
- Security vulnerability fix for d3-color nice-to-have in version 1.x HOT 4
- Unexpected token 'export' while update from 2.x.x to 3.x.x HOT 2
- Why d3 uses illuminant D50 instead of D65? HOT 1
- d3.hsl doesnt seem to work with grey scale values HOT 2
- Alpha value of 0 breaks rgb HOT 1
- Brightening black in RGB HOT 3
- bug: hue is NaN when convert hsl HOT 2
- Unexpected conversion to HSL
- Incorrect conversion from HCL / LCH to hex or rgb HOT 2
- oklab / oklch? HOT 8
- More exports. HOT 9
- Doesn't work - color is not defined HOT 1
- Does the Common JS version of the module work? HOT 1
- Supporting CSS color level 4 HOT 3
- Avoid catastrophic backtracking when parsing HOT 11
- formatHex with alpha channel 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 d3-color.