@acorex/core 5.3.2 → 5.4.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.
@@ -1,5 +1,6 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { Pipe, NgModule, Injectable, Inject } from '@angular/core';
3
+ import tinycolor from 'tinycolor2';
3
4
  import * as i1 from '@angular/platform-browser';
4
5
  import _ from 'lodash';
5
6
  import { Subject, fromEvent } from 'rxjs';
@@ -93,6 +94,58 @@ class AXStringUtil {
93
94
  }
94
95
  }
95
96
 
97
+ class AXColorUtil {
98
+ static testa(color) {
99
+ var _color = tinycolor(color);
100
+ console.log(_color);
101
+ }
102
+ static to(color, mode) {
103
+ const _color = tinycolor(color);
104
+ switch (mode) {
105
+ case 'rgba':
106
+ return _color.toRgbString();
107
+ case 'hsla':
108
+ return _color.toHslString();
109
+ case 'hsva':
110
+ return _color.toHsvString();
111
+ default:
112
+ return _color.toHexString();
113
+ }
114
+ }
115
+ ;
116
+ static toHex(color) {
117
+ const _color = tinycolor(color);
118
+ return _color.toHexString();
119
+ }
120
+ ;
121
+ static toRGB(color) {
122
+ const _color = tinycolor(color);
123
+ return _color.toRgbString();
124
+ }
125
+ ;
126
+ static illuminance(hexColor) {
127
+ let rgbColor = AXColorUtil.toRGB(hexColor);
128
+ if (!rgbColor)
129
+ return -1;
130
+ let r = rgbColor.r, g = rgbColor.g, b = rgbColor.b;
131
+ let a = [r, g, b].map(v => {
132
+ v /= 255;
133
+ return (v <= 0.03928) ?
134
+ v / 12.92 :
135
+ Math.pow(((v + 0.055) / 1.055), 2.4);
136
+ });
137
+ return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722;
138
+ }
139
+ ;
140
+ static contrastToWhite(color) {
141
+ // let whiteIlluminance = 1;
142
+ // let illuminance = AXColorUtil.illuminance(hexColor);
143
+ // return whiteIlluminance / illuminance;
144
+ return tinycolor.readability("#fff", color);
145
+ }
146
+ ;
147
+ }
148
+
96
149
  class AXSafePipe {
97
150
  constructor(sanitizer) {
98
151
  this.sanitizer = sanitizer;
@@ -1325,5 +1378,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.3.9", ngImpor
1325
1378
  * Generated bundle index. Do not edit.
1326
1379
  */
1327
1380
 
1328
- export { AXCalendarMonth, AXConfig, AXCoreModule, AXDateTime, AXDateTimeModule, AXDateTimePipe, AXDateTimeRange, AXDrawingUtil, AXEventService, AXHotkeysService, AXObjectUtil, AXPlatform, AXPlatformEvent, AXSafePipe, AXStringUtil, AXTranslationModule, AXTranslator, AXTranslatorPipe, GeorgianCalendar, JalaliCalendar, testUserAgent };
1381
+ export { AXCalendarMonth, AXColorUtil, AXConfig, AXCoreModule, AXDateTime, AXDateTimeModule, AXDateTimePipe, AXDateTimeRange, AXDrawingUtil, AXEventService, AXHotkeysService, AXObjectUtil, AXPlatform, AXPlatformEvent, AXSafePipe, AXStringUtil, AXTranslationModule, AXTranslator, AXTranslatorPipe, GeorgianCalendar, JalaliCalendar, testUserAgent };
1329
1382
  //# sourceMappingURL=acorex-core.mjs.map