@palett/presets
Advanced tools
Comparing version 0.2.11 to 0.2.12
@@ -6,2 +6,5 @@ 'use strict'; | ||
var cards = require('@palett/cards'); | ||
var rand = require('@aryth/rand'); | ||
var convert = require('@palett/convert'); | ||
var tonerHsl = require('@palett/toner-hsl'); | ||
@@ -116,2 +119,23 @@ const AQUA = { | ||
const reverseHue = hue => { | ||
hue += 180; | ||
return hue > 360 ? hue - 360 : hue < 0 ? hue + 360 : hue; | ||
}; | ||
const constraint = (x, min, max) => x > max ? max : x < min ? min : x; | ||
const randPreset = hex => { | ||
var _min, _toner, _ref; | ||
const min = hex; | ||
const hsl = (_min = min, convert.hexToHsl(_min)); | ||
const max = (_toner = tonerHsl.toner(hsl.slice(), rand.randIntBetw(-12, 12), rand.randIntBetw(-5, 10), rand.randIntBetw(6, 18)), convert.hslToHex(_toner)); | ||
const na = (_ref = [reverseHue(hsl[0]), constraint(hsl[1] - 32, 5, 90), constraint(hsl[2] + 24, 40, 96)], convert.hslToHex(_ref)); | ||
return { | ||
min, | ||
max, | ||
na | ||
}; | ||
}; | ||
exports.AQUA = AQUA; | ||
@@ -130,1 +154,2 @@ exports.ATLAS = ATLAS; | ||
exports.SUBTLE = SUBTLE; | ||
exports.randPreset = randPreset; |
import { Palett } from '@palett/cards'; | ||
import { randIntBetw } from '@aryth/rand'; | ||
import { hexToHsl, hslToHex } from '@palett/convert'; | ||
import { toner } from '@palett/toner-hsl'; | ||
@@ -111,2 +114,23 @@ const AQUA = { | ||
export { AQUA, ATLAS, AURORA, FRESH, INSTA, JUNGLE, LAVA, METRO, OCEAN, PLANET, POME, Presets, SUBTLE }; | ||
const reverseHue = hue => { | ||
hue += 180; | ||
return hue > 360 ? hue - 360 : hue < 0 ? hue + 360 : hue; | ||
}; | ||
const constraint = (x, min, max) => x > max ? max : x < min ? min : x; | ||
const randPreset = hex => { | ||
var _min, _toner, _ref; | ||
const min = hex; | ||
const hsl = (_min = min, hexToHsl(_min)); | ||
const max = (_toner = toner(hsl.slice(), randIntBetw(-12, 12), randIntBetw(-5, 10), randIntBetw(6, 18)), hslToHex(_toner)); | ||
const na = (_ref = [reverseHue(hsl[0]), constraint(hsl[1] - 32, 5, 90), constraint(hsl[2] + 24, 40, 96)], hslToHex(_ref)); | ||
return { | ||
min, | ||
max, | ||
na | ||
}; | ||
}; | ||
export { AQUA, ATLAS, AURORA, FRESH, INSTA, JUNGLE, LAVA, METRO, OCEAN, PLANET, POME, Presets, SUBTLE, randPreset }; |
{ | ||
"name": "@palett/presets", | ||
"version": "0.2.11", | ||
"version": "0.2.12", | ||
"description": "A color converter", | ||
@@ -18,3 +18,6 @@ "main": "dist/index.cjs.js", | ||
"dependencies": { | ||
"@palett/cards": "^0.2.11" | ||
"@aryth/rand": "^0.2.5", | ||
"@palett/cards": "^0.2.12", | ||
"@palett/convert": "^0.2.12", | ||
"@palett/toner-hsl": "^0.2.12" | ||
}, | ||
@@ -42,3 +45,3 @@ "repository": { | ||
"homepage": "https://github.com/hoyeungw/palett/presets#readme", | ||
"gitHead": "bc5829f824fe916225e028f985a3a7ed9d364ff2" | ||
"gitHead": "40671704dd995d641148d4ce9e9ae2de0f93e013" | ||
} |
9038
243
4
+ Added@aryth/rand@^0.2.5
+ Added@palett/convert@^0.2.12
+ Added@palett/toner-hsl@^0.2.12
+ Added@aryth/comparer@0.2.14(transitive)
+ Added@aryth/math@0.2.14(transitive)
+ Added@aryth/rand@0.2.14(transitive)
+ Added@palett/convert@0.2.16(transitive)
+ Added@palett/toner-hsl@0.2.16(transitive)
+ Added@vect/swap@0.2.13(transitive)
Updated@palett/cards@^0.2.12