@magic-xpa/angular 4.801.0-dev481.313 → 4.801.0-dev481.320
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.
- package/esm2020/src/services/magic-color.service.mjs +14 -4
- package/fesm2015/magic-xpa-angular.mjs +13 -3
- package/fesm2015/magic-xpa-angular.mjs.map +1 -1
- package/fesm2020/magic-xpa-angular.mjs +13 -3
- package/fesm2020/magic-xpa-angular.mjs.map +1 -1
- package/package.json +3 -3
- package/src/services/magic-color.service.d.ts +1 -0
|
@@ -2243,6 +2243,7 @@ class MagicColorService {
|
|
|
2243
2243
|
constructor(http, colorFile1 = 'clr_rnt.eng') {
|
|
2244
2244
|
this.http = http;
|
|
2245
2245
|
this.colorFileName = 'clr_rnt.eng';
|
|
2246
|
+
this.fileNotFound = false;
|
|
2246
2247
|
if (colorFile1)
|
|
2247
2248
|
this.colorFileName = colorFile1;
|
|
2248
2249
|
else
|
|
@@ -2255,10 +2256,13 @@ class MagicColorService {
|
|
|
2255
2256
|
if (!this.colorsData) {
|
|
2256
2257
|
this.http.get(this.getColorFilePath(), { responseType: 'text' }).subscribe(resp => {
|
|
2257
2258
|
this.colorsData = resp.replace(/\n/g, '@').split('@');
|
|
2259
|
+
}, error1 => {
|
|
2260
|
+
console.error('File not found ' + this.colorFileName);
|
|
2261
|
+
this.fileNotFound = true;
|
|
2258
2262
|
});
|
|
2259
2263
|
}
|
|
2260
2264
|
}
|
|
2261
|
-
hexToRgba(hex) {
|
|
2265
|
+
hexToRgba(hex, isTransperent) {
|
|
2262
2266
|
let shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])([a-f\d])$/i;
|
|
2263
2267
|
hex = hex.replace(shorthandRegex, function (m, r, g, b, a) {
|
|
2264
2268
|
return a + a + r + r + g + g + b + b;
|
|
@@ -2270,16 +2274,22 @@ class MagicColorService {
|
|
|
2270
2274
|
'blue': parseInt(result[2], 16),
|
|
2271
2275
|
'alpha': (255 - parseInt(result[1], 16)) / 255
|
|
2272
2276
|
};
|
|
2277
|
+
if (isTransperent)
|
|
2278
|
+
rgb.alpha = 0;
|
|
2273
2279
|
return 'rgba(' + rgb.red + ',' + rgb.green + ',' + rgb.blue + ',' + rgb.alpha + ')';
|
|
2274
2280
|
}
|
|
2275
2281
|
getColor(colorIndex, colorType) {
|
|
2276
|
-
|
|
2282
|
+
let isTransperent = false;
|
|
2283
|
+
if (!this.colorsData && !this.fileNotFound)
|
|
2277
2284
|
this.getColorData();
|
|
2278
2285
|
if (this.colorsData) {
|
|
2279
2286
|
if (this.colorsData[colorIndex - 1]) {
|
|
2280
2287
|
let hex = '';
|
|
2281
2288
|
const grayHashCode = '00808080';
|
|
2282
2289
|
let color = this.colorsData[colorIndex - 1].split(',');
|
|
2290
|
+
if (+color[3] || 1 == +color[3]) {
|
|
2291
|
+
isTransperent = true;
|
|
2292
|
+
}
|
|
2283
2293
|
if (+color[3] <= 1) {
|
|
2284
2294
|
switch (colorType) {
|
|
2285
2295
|
case MAGIC_FG_COLOR:
|
|
@@ -2295,7 +2305,7 @@ class MagicColorService {
|
|
|
2295
2305
|
}
|
|
2296
2306
|
else
|
|
2297
2307
|
hex = grayHashCode;
|
|
2298
|
-
return this.hexToRgba('#' + hex);
|
|
2308
|
+
return this.hexToRgba('#' + hex, isTransperent);
|
|
2299
2309
|
}
|
|
2300
2310
|
else
|
|
2301
2311
|
console.log('Could not get color for number ' + colorIndex);
|