Re: [csswg-drafts] [css-color-5] When mixing hue, there are two ways round the hue range (#4735)

I've added an [interactive visualization of the various hue fixup methods](https://observablehq.com/@danburzo/hue-interpolation-fixup), and changed the fixup algorithms to work with any number of hues. Here are the formulas I use currently; they need to be tested more thoroughly, but at first blush they seem correct.

```js
// shorter: 
θ₂ = Math.abs(θ₂ - θ₁) <= 180 ? θ₂ : θ₂ - 360 * Math.sign(θ₂ - θ₁);

// longer: 
θ₂ = Math.abs(θ₂ - θ₁) >= 180 ? θ₂ : θ₂ - 360 * Math.sign(θ₂ - θ₁);

// increasing:
θ₂ = θ₂ >= θ₁ ? θ₂ : θ₂ + 360 * (1 + Math.floor(Math.abs(θ₂ - θ₁) / 360));

// decreasing:
θ₂ = θ₂ <= θ₁ ? θ₂ : θ₂ - 360 * (1 + Math.floor(Math.abs(θ₂ - θ₁) / 360));
```

-- 
GitHub Notification of comment by danburzo
Please view or discuss this issue at https://github.com/w3c/csswg-drafts/issues/4735#issuecomment-653899931 using your GitHub account

Received on Sunday, 5 July 2020 15:05:39 UTC