Skip to content

Commit

Permalink
[Angle Units] Mark the proposal as accepted
Browse files Browse the repository at this point in the history
See #2904
  • Loading branch information
nex3 committed Dec 18, 2020
1 parent f1c32a8 commit 9f67360
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 10 deletions.
File renamed without changes.
22 changes: 15 additions & 7 deletions spec/built_in_modules/color.md
Expand Up @@ -92,6 +92,13 @@ This function is also available as a global function named `adjust-color()`.

* If `$hue` isn't a number or null, throw an error.

* If `$hue` is a number and it has units that aren't [compatible] with `deg`,
throw an error.

> Unitless numbers are allowed.
[compatible]: ../types/number.md#compatible-units

* If any of `$red`, `$green`, or `$blue` aren't null:

* If any of `$hue`, `$saturation`, `$lightness`, `$whiteness`, or `$blackness`
Expand All @@ -115,19 +122,19 @@ This function is also available as a global function named `adjust-color()`.

* If either `$whiteness` or `$blackness` aren't null, throw an error.

* If either `$saturation` or `$lightness` aren't either null or numbers
between -100 and 100 (inclusive), throw an error.
* If either `$saturation` or `$lightness` aren't either null or numbers with
unit `%` between -100% and 100% (inclusive), throw an error.

* Let `hue`, `saturation`, and `lightness` be the result of calling
`hue($color)`, `saturation($color)`, and `lightness($color)` respectively.

* If `$hue` isn't null, set `hue` to `hue + $hue`.

* If `$saturation` isn't null, set `saturation` to `saturation + $saturation`
clamped between 0 and 100.
clamped between 0% and 100%.

* If `$lightness` isn't null, set `lightness` to `lightness + $lightness`
clamped between 0 and 100.
clamped between 0% and 100%.

* Return the result of calling [`hsl()`][] with `hue`, `saturation`,
`lightness`, and `alpha`.
Expand Down Expand Up @@ -393,13 +400,13 @@ This function is also available as a global function named `hue()`.
* If any of `$hue`, `$whiteness`, `$blackness`, or `$alpha` aren't numbers,
throw an error.

* If `$hue` has any units other than `deg`, throw an error.
* Let `hue` be the result of [converting] `$hue` to `deg` allowing unitless.

* Set `hue` to `(hue % 360deg) / 60deg`.

* If either of `$whiteness` or `$blackness` don't have unit `%` or aren't
between `0%` and `100%` (inclusive), throw an error.

* Let `hue` be `($hue % 360) / 60` without units.

* Let `whiteness` be `$whiteness / 100%`.

* Let `blackness` be `$blackness / 100%`.
Expand All @@ -420,6 +427,7 @@ This function is also available as a global function named `hue()`.

* Return a color with the given `red`, `green`, `blue`, and `alpha` channels.

[converting]: ../types/number.md#converting-a-number-to-a-unit
[percent-converting]: #percent-converting-a-number
[to RGB]: https://www.w3.org/TR/css-color-4/#hwb-to-rgb

Expand Down
33 changes: 30 additions & 3 deletions spec/functions.md
Expand Up @@ -8,6 +8,7 @@
* [Syntax](#syntax)
* [Semantics](#semantics)
* [Global Functions](#global-functions)
* [`adjust-hue()`](#adjust-hue)
* [`alpha()`](#alpha)
* [`rgb()` and `rgba()`](#rgb-and-rgba)
* [`hsl()` and `hsla()`](#hsl-and-hsla)
Expand Down Expand Up @@ -93,6 +94,27 @@ To evaluate a `FunctionCall` `call`:
> introduced. These global aliases should be avoided by stylesheet authors if
> possible.
### `adjust-hue()`

```
adjust-hue($color, $degrees)
```

* If `$color` isn't a color or `$degrees` isn't a number, throw an error.

* Let `degrees` be the result of [converting] `$degrees` to `deg` allowing
unitless.

* Let `saturation` and `lightness` be the result of calling
[`color.saturation($color)`] and [`color.lightness($color)`], respectively.

* Return the result of calling [`hsl()`] with `degree`, `saturation`,
`lightness`, and `$color`'s alpha channel.

[`hsl()`]: #hsl-and-hsla
[`color.saturation($color)`]: built_in_modules/color.md#saturation
[`color.lightness($color)`]: built_in_modules/color.md#lightness

### `alpha()`

* ```
Expand Down Expand Up @@ -233,11 +255,15 @@ plain CSS function named `"hsl"` that function is named `"hsla"` instead.
* If any of `$hue`, `$saturation`, `$lightness`, or `$alpha` aren't numbers,
throw an error.

* Let `hue` be `($hue % 360) / 60` without units.
* Let `hue` be the result of [converting] `$hue` to `deg` allowing unitless.

* Set `hue` to `(hue % 360deg) / 60deg`.

* If `$saturation` and `$lightness` don't have unit `%`, throw an error.

* Let `saturation` and `lightness` be the result of clamping `$saturation` and
`$lightness`, respectively, between 0 and 100 and dividing by 100.
`$lightness`, respectively, between `0%` and `100%` and dividing by `100%`.

* Let `red`, `green`, and `blue` be the result of converting `hue`,
`saturation`, and `lightness` [to RGB][].

Expand All @@ -248,6 +274,7 @@ plain CSS function named `"hsl"` that function is named `"hsla"` instead.

* Return a color with the given `red`, `green`, `blue`, and `alpha` channels.

[converting]: types/number.md#converting-a-number-to-a-unit
[to RGB]: https://www.w3.org/TR/css-color-4/#hsl-to-rgb

* ```
Expand Down

0 comments on commit 9f67360

Please sign in to comment.