Skip to content
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

Support #rrggbbaa and #rgba #36

Merged
merged 4 commits into from Nov 29, 2022
Merged

Support #rrggbbaa and #rgba #36

merged 4 commits into from Nov 29, 2022

Conversation

papandreou
Copy link
Collaborator

No description provided.

@Munter
Copy link
Collaborator

Munter commented Sep 18, 2016

This will present a problem for us. The current color.hexa()-method returns #AARRGGBB, so the alpha channel in the first position.
Android uses this notation.

I remember us having discussions about supporting a 4 channel hex in the parser, but ultimately dropped it because there are conflicting standards on whether the alpha channel goes first or last.

Locking it in one position potentially excludes the opposite user group :(

What to do?

@Munter
Copy link
Collaborator

Munter commented Sep 18, 2016

The discussion in the "added threejs format" PR adds a bit more depth to this. We actually decided back then to remove support for formats that might be ambiguous.

Is it time to revisit that decision?

@Munter
Copy link
Collaborator

Munter commented Sep 18, 2016

The biggest annoyance I have is that anyone can add a plugin for whatever output they desire. But the parser doesn't really allow for extensions at the moment, so there is no way an outsider who just wants a specific format can add it to the parser

@papandreou
Copy link
Collaborator Author

Ah, I had totally forgotten about that Android thing. This just seemed like 15 minutes of fun coding. Didn't check whether that new color spec was a candidate recommendation or whatever yet, but yeah, I think it's time to revisit the decision.

@jpdevries
Copy link

Oh the joys of cross browser incompatibilities and bleeding edge technology.

I've got a situation where a fill could come in as a normal hex or an alpha hex and here is how I am working around this for now

const hexToRgba = require('hex-and-rgba').hexToRgba;
const rgbaToHex = require('hex-and-rgba').rgbaToHex;

try {
  fill = hex = color(fill.toString().replace('0x','#')).cssa();
} catch(e) {
  fill = hexToRgba(fill.replace('0x','#'));
  opacity = fill[3];
  fill = `rgba(${fill[0]},${fill[1]},${fill[2]},${fill[3]})`;
}

@Munter Munter self-requested a review April 7, 2017 07:49
Copy link
Collaborator

@Munter Munter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See discussion in comments. The only thing that has changed is that now Github has this functionality to show status better :)

@papandreou
Copy link
Collaborator Author

I just noticed this on my list of open pull requests. CSS Color Module Level 4 is still a working draft, so I guess we can't really move it forward still. Standards are slow :)

@cakeinpanic
Copy link

Browsers you notation where Alhpa comes as last 2 symbols. Can't use this lib because of it :(

* master: (26 commits)
  Fix output quoting.
  Rework the README to allow the examples to be validated.
  New build
  Fix rollup config
  Switch from rollup-plugin-commonjs to @rollup/plugin-commonjs
  Replace uglify-js with rollup-plugin-terser, update rollup, simplify build setup
  Test on more node.js versions, lint and build on 14.
  Avoid no-prototype-builtins error
  eslint --fix . && prettier --write '**/*.js'
  Replace jshint with eslint
  prettier --write '**/*.{js,md}'
  Add prettier setup
  Try building on node.js 12 always, and only run the tests on the Travis-provided one
  Rename travis script to ci
  Drop package-lock.json, disable save-exact in .npmrc
  Bump lodash from 4.17.11 to 4.17.19
  Make npm build script possible to run on windows. refs #42 (comment)
  3.1.0
  Add luminance, contrast and darkness values
  Update author's email
  ...
@papandreou
Copy link
Collaborator Author

Browsers you notation where Alhpa comes as last 2 symbols. Can't use this lib because of it :(

😢

I've brought this branch back to life and changed .hexa() to return #rrggbbaa. I think we should get it merged and do a new major release. Any objections, @Munter? 🤗

Copy link
Collaborator

@Munter Munter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. I think the CSS color module is what we want to follow.

Major version bump it is

@papandreou papandreou merged commit 7ed619b into master Nov 29, 2022
@papandreou papandreou deleted the feature/rrggbbaa branch November 29, 2022 10:30
@papandreou
Copy link
Collaborator Author

Released in 4.0.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants