Comments (8)
I suppose we should show that on all of the toString methods. toRgbString is addressed in setAlpha: https://github.com/bgrins/TinyColor#setalpha, but it would probably help to document what all of the methods do (including things like toHex).
from tinycolor.
Yes, you are right. But also toRgbString seems that only outputs rgb. I think toRgbaString would be a good method to add.
from tinycolor.
I think toRgbaString would be a good method to add.
I've thought about adding this, but then you get into weird cases where you have an alpha set, call toRgbString()
, and get incorrect data back. I think it's easier to always return the 'right' data and allow the user to get around that (via setAlpha(1)
or toHexString()
). We just need to make sure it's better documented.
Any chance you could file a PR with the updated docs?
from tinycolor.
I've thought about adding this, but then you get into weird cases where you have an alpha set, call toRgbString(), and get incorrect data back. I think it's easier to always return the 'right' data and allow the user to get around that (via setAlpha(1) or toHexString()). We just need to make sure it's better documented.
You can add only for consistency.
Any chance you could file a PR with the updated docs?
Yes. Comment something after so I get a notification (:
from tinycolor.
Cool, thanks :). I think ideally we would have something documented like this for each of the toString functions (toHsvString
, toHslString
, toHexString
, toHex8String
, toRgbString
, toPercentageRgbString
, toName
)
var color = tinycolor("red");
color.toRgbString(); // "rgb(255, 0, 0)"
color.setAlpha(0.5);
color.toRgbString(); // "rgba(255, 0, 0, 0.5)"
from tinycolor.
What about the toRgb
, toHsv
, toHsl
methods?
It seems from the docs that they return an object with an a
property, without touching the alpha:
var color = tinycolor("red");
color.toHsl(); // { h: 0, s: 1, l: 0.5, a: 1 }
which seems to be an unexpected behaviour
from tinycolor.
It seems from the docs that they return an object with an a property, without touching the alpha
which seems to be an unexpected behaviour
Yes, in general we return the a
without a special request. Adding a special request for each would increase the surface area of the API and also be harder to guess. The theory is that a user could always just ignore the a
if they don't care about it. We could add a note to the docs about this, though
from tinycolor.
Fixed by #75
from tinycolor.
Related Issues (20)
- In built way to automatically Darken or Lighten by amount depending on the color luminance
- Is toFloatString() implemented?
- React 18 types mismatch
- Feature: include alpha in Hex HOT 2
- Is there a way to reverse a colour, like a negative image?
- Support for LCH?
- Octal literal in strict mode
- tinycolor.mix(color1, color2, amount = 50) not working in React native HOT 1
- Doesn't work with calc HOT 1
- tinycolor is not a function HOT 39
- remove `engines` field from package.json
- Task: Publish 1.6.0 to npm
- Remove tinycolor.js and dist/tinycolor-min.js once we confirm they aren't used HOT 1
- Include a Changelog HOT 4
- asset files includes ES6 syntax HOT 2
- Task: Publish 1.6.1
- [Question] Overlay Colors
- why tinycolor({h: 0, s: 100,v: 0}).toHsv() result {h: 0, s: 0, v: 0} ? HOT 2
- [Question] OKLCH support?
- RGBA fails to parse if alpha is missing
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 tinycolor.