generated from techmmunity/base-project-packages
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Deprecate @techmmunity/easy-check (#15)
- Loading branch information
1 parent
5e59890
commit b0dc07c
Showing
83 changed files
with
5,305 additions
and
28 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
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
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
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,40 @@ | ||
/* eslint-disable @typescript-eslint/no-magic-numbers */ | ||
|
||
import { isHexColor } from "../is-hex-color"; | ||
|
||
const getColorWithCorrectLength = (color: string) => { | ||
if (color.length === 3) { | ||
const colorSplitted = color.split(""); | ||
|
||
const [r, g, b] = colorSplitted; | ||
|
||
/** | ||
* Duplicate the values, to make the code have length of six | ||
*/ | ||
const colorWithLengthSix = [r, r, g, g, b, b]; | ||
|
||
return colorWithLengthSix.join(""); | ||
} | ||
|
||
return color; | ||
}; | ||
|
||
export const getHexColorLuma = (color: string) => { | ||
if (!isHexColor(color)) return; | ||
|
||
const colorWithOutHashtag = color.substring(1); | ||
|
||
const colorWithLengthSix = getColorWithCorrectLength(colorWithOutHashtag); | ||
|
||
const rgb = parseInt(colorWithLengthSix, 16); | ||
|
||
const r = (rgb >> 16) & 0xff; | ||
const g = (rgb >> 8) & 0xff; | ||
const b = (rgb >> 0) & 0xff; | ||
|
||
const rLuma = 0.2126 * r; | ||
const gLuma = 0.7152 * g; | ||
const bLuma = 0.0722 * b; | ||
|
||
return rLuma + gLuma + bLuma; | ||
}; |
Oops, something went wrong.