Skip to content

Commit

Permalink
Change "Raw" hue adjustment to "Specified"
Browse files Browse the repository at this point in the history
  • Loading branch information
Blupo committed Apr 6, 2022
1 parent 0a424c4 commit 65a754e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion docs/api/color.md
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ Color.mix(startColor: Color, endColor: Color, ratio: number, mode: string? = "RG

Interpolates the start and end Colors in various color spaces. `ratio` should be in the range [0, 1]. Supported spaces are: `RGB` (default), `CMYK`, `HSB` (or `HSV`), `HWB`, `HSL`, `Lab`, `Luv`, `LChab` (or `LCh`), `LChuv`, `xyY`, and `XYZ` (`XYZ` interpolation can be used for linear RGB interpolation).

For color spaces with a hue component (e.g. HSB/L or LCh), there are different ways to interpolate the hue, and you can specify how it should be done by passing `hueAdjustment`: `Shorter` (default), `Longer`, `Increasing`, `Decreasing`, or `Raw`. These adjustments correspond to those specified in [CSS Color Module Level 4](https://www.w3.org/TR/css-color-4/#hue-interpolation).
For color spaces with a hue component (e.g. HSB/L or LCh), there are different ways to interpolate the hue, and you can specify how it should be done by passing `hueAdjustment`: `Shorter` (default), `Longer`, `Increasing`, `Decreasing`, or `Specified`. These adjustments correspond to those specified in [CSS Color Module Level 4](https://www.w3.org/TR/css-color-4/#hue-interpolation).

Here are images of what the various interpolations look like, using red and aqua as example colors (with the default hue adjustment):

Expand Down
5 changes: 5 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## [0.2.2] - 2022-04-06

### Changed
- Replaced the `Raw` hue adjustment option with `Specified` to match spec, however `Raw` will still work

## [0.2.1] - 2022-01-06

### Changed
Expand Down
2 changes: 1 addition & 1 deletion src/Utils/HueLerp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ return function(h1: number, h2: number, t: number, optionalAdjustment: string?):
if (h1 < h2) then
h1 = h1 + 360
end
elseif (adjustment == "Raw") then
elseif ((adjustment == "Raw") or (adjustment == "Specified")) then
h1, h2 = h1, h2
else
error("invalid hue adjustment")
Expand Down
3 changes: 2 additions & 1 deletion tests/Color.spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,8 @@ return function()

expect(red:mix(blue, 0.5, "HSB", "Shorter"):to("Hex")).never.to.equal(red:mix(blue, 0.5, "HSB", "Longer"))
expect(red:mix(blue, 0.5, "HSB", "Increasing"):to("Hex")).never.to.equal(red:mix(blue, 0.5, "HSB", "Decreasing"))
expect(red:mix(blue, 0.5, "HSB", "Raw")).to.be.ok()
expect(red:mix(blue, 0.5, "HSB", "Specified")).to.be.ok()
expect(red:mix(blue, 0.5, "HSB", "Specified")).to.equal(red:mix(blue, 0.5, "HSB", "Raw"))

expect(red:mix(blue, 0.5, "HSV")).to.equal(red:mix(blue, 0.5, "HSB"))
expect(red:mix(blue, 0.5, "LCh")).to.equal(red:mix(blue, 0.5, "LChab"))
Expand Down

0 comments on commit 65a754e

Please sign in to comment.