-
-
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.
- Loading branch information
Showing
16 changed files
with
86 additions
and
84 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
const presets = [ | ||
'@babel/preset-env' | ||
] | ||
const presets = ['@babel/preset-env'] | ||
|
||
module.exports = { | ||
presets | ||
|
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 |
---|---|---|
@@ -1,9 +1,7 @@ | ||
// Forumula source: https://stackoverflow.com/a/29321264/680394 | ||
|
||
// blend :: (Integer, Integer, Number) -> Integer | ||
const blend = (x, y, n=0) => | ||
Math.round( | ||
Math.sqrt((1 - n) * Math.pow(x, 2) + n * Math.pow(y, 2)) | ||
) | ||
const blend = (x, y, n = 0) => | ||
Math.round(Math.sqrt((1 - n) * Math.pow(x, 2) + n * Math.pow(y, 2))) | ||
|
||
export default blend |
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 |
---|---|---|
@@ -1,7 +1,6 @@ | ||
// Formula source: https://stackoverflow.com/a/29321264/680394 | ||
|
||
// blendAlpha :: (Integer, Integer, Number) -> Integer | ||
const blendAlpha = (x, y, n=0) => | ||
Number(((1 - n) * x + n * y).toFixed(2)) | ||
const blendAlpha = (x, y, n = 0) => Number(((1 - n) * x + n * y).toFixed(2)) | ||
|
||
export default blendAlpha |
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 |
---|---|---|
@@ -1,20 +1,14 @@ | ||
import parse from './parse' | ||
|
||
const getAlpha = x => | ||
x ? parseFloat((parseInt(x, 16) / 0xff).toFixed(2)) : 1 | ||
const getAlpha = x => (x ? parseFloat((parseInt(x, 16) / 0xff).toFixed(2)) : 1) | ||
|
||
// hexToRgba :: String -> [ Integer, Integer, Integer, Number ] | ||
const hexToRgba = x => { | ||
const hex = parse(x) | ||
const head = hex.slice(0, 6) | ||
const tail = hex.slice(6) | ||
const n = parseInt(head, 16) | ||
return [ | ||
n >> 16 & 0xff, | ||
n >> 8 & 0xff, | ||
n >> 0 & 0xff, | ||
getAlpha(tail) | ||
] | ||
return [(n >> 16) & 0xff, (n >> 8) & 0xff, (n >> 0) & 0xff, getAlpha(tail)] | ||
} | ||
|
||
export default hexToRgba |
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 |
---|---|---|
@@ -1,14 +1,9 @@ | ||
const regex = /[0-9.]+/gi | ||
|
||
// parseRgba :: String Rgba -> [ Integer, Integer, Integer, Number ] | ||
const parseRgba = (x='') => { | ||
const [ r=0, g=0, b=0, a=1 ] = x.match(regex) || [] | ||
return [ | ||
parseInt(r, 10), | ||
parseInt(g, 10), | ||
parseInt(b, 10), | ||
parseFloat(a) | ||
] | ||
const parseRgba = (x = '') => { | ||
const [r = 0, g = 0, b = 0, a = 1] = x.match(regex) || [] | ||
return [parseInt(r, 10), parseInt(g, 10), parseInt(b, 10), parseFloat(a)] | ||
} | ||
|
||
export default parseRgba |
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 |
---|---|---|
@@ -1,5 +1,5 @@ | ||
// rgbaToRgbaCss :: [ Integer, Integer, Integer, Number ] -> String Rgba | ||
const rgbaToRgbaCss = ([ r=0, g=0, b=0, a=1 ]=[]) => | ||
const rgbaToRgbaCss = ([r = 0, g = 0, b = 0, a = 1] = []) => | ||
`rgba(${r},${g},${b},${a})` | ||
|
||
export default rgbaToRgbaCss |
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