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

[css-color] clarify the value allowed for the gray() function, percentage or number #635

Closed
dmeranda opened this issue Oct 22, 2016 · 7 comments

Comments

@dmeranda
Copy link

In section 9 about the gray() function the syntax says it accepts a <number> as it's first parameter, but then the only example in the descriptive text mentions that "gray(50%)" is a visual mid-gray,which is a percentage value.

Should gray accept either a <number> or <percentage>, similar to alpha-value — where gray(1) should be interpreted the same as gray(100%), which is white?

Or alternatively, if gray is really supposed to be a shortcut for Lab's L value (with a=b=0), then should gray(100) be the same as gray(100%)? And for that matter, if there is an equivalence being made between gray and Lab, should the lab() function itself, and lch(), allow either a number value (0 to 100) as well as a percentage for it's first parameter?

@svgeesus
Copy link
Contributor

Thanks for the comment! Yes, the example is wrong. Gray takes a number, which is the same as L in Lab and LCH - range is 0 to 100.

@Crissov
Copy link
Contributor

Crissov commented Oct 24, 2016

Well, there was still dissent (by @tabatkins at least) regarding L in #278 when it was closed. Requiring gray(50) instead of gray(50%) would be very counter-intuitive, even more so with gray(calc(…)).

@svgeesus
Copy link
Contributor

Percentage of what?

@Crissov
Copy link
Contributor

Crissov commented Oct 25, 2016

Percentage of either “whiteness” or “blackness”, i.e. I bet almost everyone intuitively thinks of gray(0%) and gray(100%) as either pitch black, bright white or, at least for the latter, the grayest gray possible (something like actual gray(50%)).

With gray(100) on the other hand, you’ll have in addition some people assume that this is a decimal 8-bit value as in rgb(100, 100, 100) (for which it would be a shortcut notation in their mental model). With gray(0) you’d even have some thinking it’s the minimum in a 0.0…1.0 range.

Unitless numbers are bad! They’re much worse than percentages that can go outside the 0%…100% range. It would make more sense to standardize X11’s gray0gray100 keywords then.

@dmeranda
Copy link
Author

It's also worth mentioning again that whoever wrote the description for the gray function in the CSS draft also thought, at least momentarily, that gray(50%) was legal and represented a mid-level gray. It may be more than just a typo, but perhaps an indicator there is a mismatch between intuition and the spec.

I suspect if you're using the lab or lch color functions you have some exposure to color theory, or you have at least had to read about them because those terms are not in the general public English vocabulary. You may even know that the L* parameter is just a unitless dimension on an axis that was arbitrarily defined to be within the range 0 to 100. Though even there, was the intent of that decision be that the numbers look like percentages without the %-sign?

But everyone knows "gray"., and people that use gray are probably relying on a more informal intuitive sense. When using rgb with percentage values it's intuitive that 0% should mean the minimum value for that color component and 100% means the maximum value. And I would think a similar intuition would occur for people using gray. Even if they mistakenly thought gray(50%) would be the same as rgb(50% 50% 50%), which it is not, at least they would expect the two to be almost the same, which they are. But certainly gray(50) is wildly different from rgb(50 50 50). And gray(255) is absurd, and one I suspect could be a common error. But the intent of a percentage value is clear.

Which ever way is fine, but it has to be made clear the gray(<x> [/ <y>]) is syntactic sugar for lab(<x> 0 0 [/ <y>]), and what the acceptable values for <x> are; and all three of gray, lab, and lch should accept the same value types.

@tabatkins
Copy link
Member

Yeah, I wrote gray() as % originally, because 0% is black and 100% is white, exactly as you'd expect from hsl() or rgb(). We've recast gray() on top of lch() instead, but the use of a % is still reasonable there.

@svgeesus
Copy link
Contributor

Closed as we dropped the gray() function entirely

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

No branches or pull requests

4 participants