@acorex/core 5.5.0 → 5.6.0

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.
@@ -100,6 +100,20 @@ class AXColorUtil {
100
100
  console.log(_color);
101
101
  }
102
102
  static to(color, mode) {
103
+ const _color = tinycolor(color);
104
+ switch (mode) {
105
+ case 'rgba':
106
+ return _color.toRgb();
107
+ case 'hsla':
108
+ return _color.toHsl();
109
+ case 'hsva':
110
+ return _color.toHsv();
111
+ default:
112
+ return _color.toHex();
113
+ }
114
+ }
115
+ ;
116
+ static toString(color, mode) {
103
117
  const _color = tinycolor(color);
104
118
  switch (mode) {
105
119
  case 'rgba':
@@ -113,18 +127,27 @@ class AXColorUtil {
113
127
  }
114
128
  }
115
129
  ;
116
- static toHex(color) {
130
+ static mix(baseColor, hex, percentage) {
131
+ return tinycolor.mix(baseColor, hex, percentage);
132
+ }
133
+ static multiply(rgb1, rgb2) {
134
+ rgb1.b = Math.floor(rgb1.b * rgb2.b / 255);
135
+ rgb1.g = Math.floor(rgb1.g * rgb2.g / 255);
136
+ rgb1.r = Math.floor(rgb1.r * rgb2.r / 255);
137
+ return tinycolor('rgb ' + rgb1.r + ' ' + rgb1.g + ' ' + rgb1.b);
138
+ }
139
+ static toHexSting(color) {
117
140
  const _color = tinycolor(color);
118
141
  return _color.toHexString();
119
142
  }
120
143
  ;
121
- static toRGB(color) {
144
+ static toRGBString(color) {
122
145
  const _color = tinycolor(color);
123
146
  return _color.toRgbString();
124
147
  }
125
148
  ;
126
149
  static illuminance(hexColor) {
127
- let rgbColor = AXColorUtil.toRGB(hexColor);
150
+ let rgbColor = AXColorUtil.toRGBString(hexColor);
128
151
  if (!rgbColor)
129
152
  return -1;
130
153
  let r = rgbColor.r, g = rgbColor.g, b = rgbColor.b;
@@ -144,6 +167,12 @@ class AXColorUtil {
144
167
  return tinycolor.readability("#fff", color);
145
168
  }
146
169
  ;
170
+ static lighten(hex, percentage) {
171
+ return tinycolor(hex).lighten(percentage);
172
+ }
173
+ static darken(hex, percentage) {
174
+ return tinycolor(hex).darken(percentage);
175
+ }
147
176
  }
148
177
 
149
178
  class AXSafePipe {