diginext-utils 1.1.8 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,56 +3,32 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.default = void 0;
6
+ exports.random = exports.pSBC = exports.hexToRgb = exports.hexLighten = exports.hexDarken = exports.RGBToHex = void 0;
7
7
 
8
- require("core-js/modules/es.regexp.exec.js");
8
+ require("core-js/modules/es.regexp.to-string.js");
9
9
 
10
10
  require("core-js/modules/es.parse-int.js");
11
11
 
12
- require("core-js/modules/es.regexp.to-string.js");
13
-
14
12
  require("core-js/modules/web.dom-collections.iterator.js");
15
13
 
14
+ require("core-js/modules/es.regexp.exec.js");
15
+
16
16
  require("core-js/modules/es.string.split.js");
17
17
 
18
18
  require("core-js/modules/es.parse-float.js");
19
19
 
20
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
-
22
- class Color {
23
- // This function (pSBC) will take a HEX or RGB web color.
24
- // pSBC can shade it darker or lighter, or blend it with a second color, and can also pass it right thru but convert from Hex to RGB (Hex2RGB) or RGB to Hex (RGB2Hex).
25
- // All without you even knowing what color format you are using.
26
- // Version 4.0 (pref: https://github.com/PimpTrizkit/PJs/wiki/12.-Shade,-Blend-and-Convert-a-Web-Color-(pSBC.js));
27
- static hexToRgb(hex) {
28
- var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
29
- return result ? {
30
- r: parseInt(result[1], 16),
31
- g: parseInt(result[2], 16),
32
- b: parseInt(result[3], 16)
33
- } : null;
34
- }
35
-
36
- static hexDarken(hex, amount) {
37
- return Color.pSBC(-amount, hex);
38
- }
39
-
40
- static hexLighten(hex, amount) {
41
- return Color.pSBC(amount, hex);
42
- }
43
-
44
- static RGBToHex(rgb) {
45
- return Color.pSBC(0, rgb, "c", true);
46
- }
47
-
48
- }
49
-
50
- _defineProperty(Color, "random", function () {
20
+ const random = function random() {
51
21
  let hex = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
52
22
  return (hex ? "#" : "") + Math.floor(Math.random() * 16777215).toString(16);
53
- });
23
+ }; // This function (pSBC) will take a HEX or RGB web color.
24
+ // pSBC can shade it darker or lighter, or blend it with a second color, and can also pass it right thru but convert from Hex to RGB (Hex2RGB) or RGB to Hex (RGB2Hex).
25
+ // All without you even knowing what color format you are using.
26
+ // Version 4.0 (pref: https://github.com/PimpTrizkit/PJs/wiki/12.-Shade,-Blend-and-Convert-a-Web-Color-(pSBC.js));
27
+
28
+
29
+ exports.random = random;
54
30
 
55
- _defineProperty(Color, "pSBC", (p, c0, c1, l) => {
31
+ const pSBC = (p, c0, c1, l) => {
56
32
  let r,
57
33
  g,
58
34
  b,
@@ -64,7 +40,7 @@ _defineProperty(Color, "pSBC", (p, c0, c1, l) => {
64
40
  m = Math.round,
65
41
  a = typeof c1 == "string";
66
42
  if (typeof p != "number" || p < -1 || p > 1 || typeof c0 != "string" || c0[0] != "r" && c0[0] != "#" || c1 && !a) return null;
67
- if (!Color.pSBCr) Color.pSBCr = d => {
43
+ if (!(void 0).pSBCr) (void 0).pSBCr = d => {
68
44
  let n = d.length,
69
45
  x = {};
70
46
 
@@ -81,7 +57,7 @@ _defineProperty(Color, "pSBC", (p, c0, c1, l) => {
81
57
 
82
58
  return x;
83
59
  };
84
- h = c0.length > 9, h = a ? c1.length > 9 ? true : c1 == "c" ? !h : false : h, f = Color.pSBCr(c0), P = p < 0, t = c1 && c1 != "c" ? Color.pSBCr(c1) : P ? {
60
+ h = c0.length > 9, h = a ? c1.length > 9 ? true : c1 == "c" ? !h : false : h, f = (void 0).pSBCr(c0), P = p < 0, t = c1 && c1 != "c" ? (void 0).pSBCr(c1) : P ? {
85
61
  r: 0,
86
62
  g: 0,
87
63
  b: 0,
@@ -96,7 +72,35 @@ _defineProperty(Color, "pSBC", (p, c0, c1, l) => {
96
72
  if (l) r = m(P * f.r + p * t.r), g = m(P * f.g + p * t.g), b = m(P * f.b + p * t.b);else r = m((P * f.r ** 2 + p * t.r ** 2) ** 0.5), g = m((P * f.g ** 2 + p * t.g ** 2) ** 0.5), b = m((P * f.b ** 2 + p * t.b ** 2) ** 0.5);
97
73
  a = f.a, t = t.a, f = a >= 0 || t >= 0, a = f ? a < 0 ? t : t < 0 ? a : a * P + t * p : 0;
98
74
  if (h) return "rgb" + (f ? "a(" : "(") + r + "," + g + "," + b + (f ? "," + m(a * 1000) / 1000 : "") + ")";else return "#" + (4294967296 + r * 16777216 + g * 65536 + b * 256 + (f ? m(a * 255) : 0)).toString(16).slice(1, f ? undefined : -2);
99
- });
75
+ };
76
+
77
+ exports.pSBC = pSBC;
78
+
79
+ const hexToRgb = hex => {
80
+ var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
81
+ return result ? {
82
+ r: parseInt(result[1], 16),
83
+ g: parseInt(result[2], 16),
84
+ b: parseInt(result[3], 16)
85
+ } : null;
86
+ };
87
+
88
+ exports.hexToRgb = hexToRgb;
89
+
90
+ const hexDarken = (hex, amount) => {
91
+ return pSBC(-amount, hex);
92
+ };
93
+
94
+ exports.hexDarken = hexDarken;
95
+
96
+ const hexLighten = (hex, amount) => {
97
+ return pSBC(amount, hex);
98
+ };
99
+
100
+ exports.hexLighten = hexLighten;
101
+
102
+ const RGBToHex = rgb => {
103
+ return pSBC(0, rgb, "c", true);
104
+ };
100
105
 
101
- var _default = Color;
102
- exports.default = _default;
106
+ exports.RGBToHex = RGBToHex;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginext-utils",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
4
4
  "author": {
5
5
  "name": "TOP GROUP (a.k.a Digitop)",
6
6
  "email": "dev@wearetopgroup.com"