@palett/convert
Advanced tools
Comparing version 0.8.18 to 0.9.0
@@ -16,3 +16,3 @@ 'use strict'; | ||
function dil2(hex) { | ||
const hi = hex == null ? void 0 : hex.length; | ||
const hi = hex === null || hex === void 0 ? void 0 : hex.length; | ||
if (hi >= 2) return hex; | ||
@@ -23,3 +23,3 @@ if (hi === 1) return '0' + hex; | ||
function dil3(hex) { | ||
const hi = hex == null ? void 0 : hex.length; | ||
const hi = hex === null || hex === void 0 ? void 0 : hex.length; | ||
if (hi >= 3) return hex; | ||
@@ -31,3 +31,3 @@ if (hi === 2) return '0' + hex; | ||
function dil6(hex) { | ||
const hi = hex == null ? void 0 : hex.length; | ||
const hi = hex === null || hex === void 0 ? void 0 : hex.length; | ||
if (hi >= 6) return hex; | ||
@@ -67,2 +67,20 @@ if (hi === 5) return '0' + hex; | ||
}; | ||
const bd = (r, g, b) => { | ||
let ma = r, | ||
mi = r; | ||
if (g > r) { | ||
ma = g; | ||
} else { | ||
mi = g; | ||
} | ||
if (b > ma) ma = b; | ||
if (b < mi) mi = b; | ||
return { | ||
max: ma, | ||
sum: ma + mi, | ||
dif: ma - mi | ||
}; | ||
}; | ||
const hue = (r, g, b, max, dif) => { | ||
@@ -100,3 +118,3 @@ if (dif === 0) return 0; | ||
dif | ||
} = bound([r, g, b]); | ||
} = bd(r, g, b); | ||
let h = hue(r, g, b, max, dif) * 60, | ||
@@ -115,3 +133,3 @@ s = !dif ? 0 : sum > 1 ? dif / (2 - sum) : dif / sum, | ||
let lo = 0, | ||
hi = hex == null ? void 0 : hex.length; | ||
hi = hex === null || hex === void 0 ? void 0 : hex.length; | ||
if (hi === 7) lo++, hi--; | ||
@@ -164,3 +182,3 @@ | ||
dif | ||
} = bound([r, g, b]); | ||
} = bd(r, g, b); | ||
let h = hue(r, g, b, max, dif) * 60, | ||
@@ -185,3 +203,3 @@ s = !dif ? 0 : sum > 1 ? dif / (2 - sum) : dif / sum, | ||
let lo = 0, | ||
hi = hex == null ? void 0 : hex.length; | ||
hi = hex === null || hex === void 0 ? void 0 : hex.length; | ||
if (hi === 7) lo++, hi--; | ||
@@ -253,10 +271,32 @@ if (hi === 6) return hexAt(hex, lo) << 8 | hexAt(hex, lo += 2) << 4 | hexAt(hex, lo + 2); | ||
var _class, _temp, _class2, _temp2, _class3, _temp3, _class4, _temp4; | ||
class Conv {} | ||
Conv.rgb = (_temp = _class = class Rgb {}, _class.rgb = oneself.oneself, _class.hex = rgbToHex, _class.hsl = rgbToHsl, _class.int = rgbToInt, _temp); | ||
Conv.hex = (_temp2 = _class2 = class Rgb {}, _class2.rgb = hexToRgb, _class2.hex = oneself.oneself, _class2.hsl = hexToHsl, _class2.int = hexToInt, _temp2); | ||
Conv.hsl = (_temp3 = _class3 = class Rgb {}, _class3.rgb = hslToRgb, _class3.hex = hslToHex, _class3.hsl = oneself.oneself, _class3.int = hslToInt, _temp3); | ||
Conv.int = (_temp4 = _class4 = class Rgb {}, _class4.rgb = intToRgb, _class4.hex = intToHex, _class4.hsl = intToHsl, _class4.int = oneself.oneself, _temp4); | ||
class Conv { | ||
static rgb = class Rgb { | ||
static rgb = oneself.oneself; | ||
static hex = rgbToHex; | ||
static hsl = rgbToHsl; | ||
static int = rgbToInt; | ||
}; | ||
static hex = class Rgb { | ||
static rgb = hexToRgb; | ||
static hex = oneself.oneself; | ||
static hsl = hexToHsl; | ||
static int = hexToInt; | ||
}; | ||
static hsl = class Rgb { | ||
static rgb = hslToRgb; | ||
static hex = hslToHex; | ||
static hsl = oneself.oneself; | ||
static int = hslToInt; | ||
}; | ||
static int = class Rgb { | ||
static rgb = intToRgb; | ||
static hex = intToHex; | ||
static hsl = intToHsl; | ||
static int = oneself.oneself; | ||
}; | ||
} | ||
exports.Conv = Conv; | ||
exports.bd = bd; | ||
exports.bound = bound; | ||
exports.dil2 = dil2; | ||
@@ -270,10 +310,13 @@ exports.dil3 = dil3; | ||
exports.hexToShort = hexToShort; | ||
exports.hf = hf; | ||
exports.hslToHex = hslToHex; | ||
exports.hslToInt = hslToInt; | ||
exports.hslToRgb = hslToRgb; | ||
exports.hue = hue; | ||
exports.intToHex = intToHex; | ||
exports.intToHsl = intToHsl; | ||
exports.intToRgb = intToRgb; | ||
exports.prolif = prolif; | ||
exports.rgbToHex = rgbToHex; | ||
exports.rgbToHsl = rgbToHsl; | ||
exports.rgbToInt = rgbToInt; |
@@ -12,3 +12,3 @@ import { round } from '@aryth/math'; | ||
function dil2(hex) { | ||
const hi = hex == null ? void 0 : hex.length; | ||
const hi = hex === null || hex === void 0 ? void 0 : hex.length; | ||
if (hi >= 2) return hex; | ||
@@ -19,3 +19,3 @@ if (hi === 1) return '0' + hex; | ||
function dil3(hex) { | ||
const hi = hex == null ? void 0 : hex.length; | ||
const hi = hex === null || hex === void 0 ? void 0 : hex.length; | ||
if (hi >= 3) return hex; | ||
@@ -27,3 +27,3 @@ if (hi === 2) return '0' + hex; | ||
function dil6(hex) { | ||
const hi = hex == null ? void 0 : hex.length; | ||
const hi = hex === null || hex === void 0 ? void 0 : hex.length; | ||
if (hi >= 6) return hex; | ||
@@ -63,2 +63,20 @@ if (hi === 5) return '0' + hex; | ||
}; | ||
const bd = (r, g, b) => { | ||
let ma = r, | ||
mi = r; | ||
if (g > r) { | ||
ma = g; | ||
} else { | ||
mi = g; | ||
} | ||
if (b > ma) ma = b; | ||
if (b < mi) mi = b; | ||
return { | ||
max: ma, | ||
sum: ma + mi, | ||
dif: ma - mi | ||
}; | ||
}; | ||
const hue = (r, g, b, max, dif) => { | ||
@@ -96,3 +114,3 @@ if (dif === 0) return 0; | ||
dif | ||
} = bound([r, g, b]); | ||
} = bd(r, g, b); | ||
let h = hue(r, g, b, max, dif) * 60, | ||
@@ -111,3 +129,3 @@ s = !dif ? 0 : sum > 1 ? dif / (2 - sum) : dif / sum, | ||
let lo = 0, | ||
hi = hex == null ? void 0 : hex.length; | ||
hi = hex === null || hex === void 0 ? void 0 : hex.length; | ||
if (hi === 7) lo++, hi--; | ||
@@ -160,3 +178,3 @@ | ||
dif | ||
} = bound([r, g, b]); | ||
} = bd(r, g, b); | ||
let h = hue(r, g, b, max, dif) * 60, | ||
@@ -181,3 +199,3 @@ s = !dif ? 0 : sum > 1 ? dif / (2 - sum) : dif / sum, | ||
let lo = 0, | ||
hi = hex == null ? void 0 : hex.length; | ||
hi = hex === null || hex === void 0 ? void 0 : hex.length; | ||
if (hi === 7) lo++, hi--; | ||
@@ -249,9 +267,29 @@ if (hi === 6) return hexAt(hex, lo) << 8 | hexAt(hex, lo += 2) << 4 | hexAt(hex, lo + 2); | ||
var _class, _temp, _class2, _temp2, _class3, _temp3, _class4, _temp4; | ||
class Conv {} | ||
Conv.rgb = (_temp = _class = class Rgb {}, _class.rgb = oneself, _class.hex = rgbToHex, _class.hsl = rgbToHsl, _class.int = rgbToInt, _temp); | ||
Conv.hex = (_temp2 = _class2 = class Rgb {}, _class2.rgb = hexToRgb, _class2.hex = oneself, _class2.hsl = hexToHsl, _class2.int = hexToInt, _temp2); | ||
Conv.hsl = (_temp3 = _class3 = class Rgb {}, _class3.rgb = hslToRgb, _class3.hex = hslToHex, _class3.hsl = oneself, _class3.int = hslToInt, _temp3); | ||
Conv.int = (_temp4 = _class4 = class Rgb {}, _class4.rgb = intToRgb, _class4.hex = intToHex, _class4.hsl = intToHsl, _class4.int = oneself, _temp4); | ||
class Conv { | ||
static rgb = class Rgb { | ||
static rgb = oneself; | ||
static hex = rgbToHex; | ||
static hsl = rgbToHsl; | ||
static int = rgbToInt; | ||
}; | ||
static hex = class Rgb { | ||
static rgb = hexToRgb; | ||
static hex = oneself; | ||
static hsl = hexToHsl; | ||
static int = hexToInt; | ||
}; | ||
static hsl = class Rgb { | ||
static rgb = hslToRgb; | ||
static hex = hslToHex; | ||
static hsl = oneself; | ||
static int = hslToInt; | ||
}; | ||
static int = class Rgb { | ||
static rgb = intToRgb; | ||
static hex = intToHex; | ||
static hsl = intToHsl; | ||
static int = oneself; | ||
}; | ||
} | ||
export { Conv, dil2, dil3, dil6, hexAt, hexToHsl, hexToInt, hexToRgb, hexToShort, hslToHex, hslToInt, hslToRgb, intToHex, intToHsl, intToRgb, rgbToHex, rgbToHsl, rgbToInt }; | ||
export { Conv, bd, bound, dil2, dil3, dil6, hexAt, hexToHsl, hexToInt, hexToRgb, hexToShort, hf, hslToHex, hslToInt, hslToRgb, hue, intToHex, intToHsl, intToRgb, prolif, rgbToHex, rgbToHsl, rgbToInt }; |
{ | ||
"name": "@palett/convert", | ||
"version": "0.8.18", | ||
"version": "0.9.0", | ||
"description": "A color converter among RGB, HEX and HSL.", | ||
"main": "dist/index.cjs.js", | ||
"module": "dist/index.esm.js", | ||
"main": "dist/index.cjs", | ||
"exports": { | ||
"import": "./dist/index.mjs", | ||
"require": "./dist/index.cjs" | ||
}, | ||
"files": [ | ||
@@ -18,3 +21,3 @@ "dist" | ||
"dependencies": { | ||
"@aryth/math": "^0.3.23", | ||
"@aryth/math": "^0.4.10", | ||
"@ject/oneself": "^0.0.16" | ||
@@ -45,3 +48,3 @@ }, | ||
"homepage": "https://github.com/hoyeungw/palett/rgb#readme", | ||
"gitHead": "adf5812e323bc29bdaea384c59716e8c7ba39330" | ||
"gitHead": "edabce66a91b4f0b6ded1274071a2711d0857475" | ||
} |
28943
7
1036
+ Added@aryth/math@0.4.10(transitive)
- Removed@aryth/math@0.3.26(transitive)
Updated@aryth/math@^0.4.10