-
-
Notifications
You must be signed in to change notification settings - Fork 150
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(color): add Hue enum, closestHue*() fns, namedHueRgba()
- Loading branch information
1 parent
172f507
commit e7bb46b
Showing
3 changed files
with
44 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { Hue } from "./api"; | ||
import { ensureHue } from "./internal/ensure-hue"; | ||
|
||
/** | ||
* Returns the `Hue` constant of the closest of 12 defined hues. | ||
* | ||
* @param h hue | ||
*/ | ||
export const closestHue = | ||
(h: number): Hue => | ||
Math.round(ensureHue(h) * 12) % 12; | ||
|
||
/** | ||
* Returns the `Hue` constant of the closest primary or secondary hue. | ||
* | ||
* @param h | ||
*/ | ||
export const closestPrimaryHue = | ||
(h: number): Hue => | ||
(Math.round(ensureHue(h) * 12) % 12) & 0xe; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters