修复十六进制颜色不兼容的bug

This commit is contained in:
unanmed 2023-06-20 11:56:25 +08:00
parent d4c03cdaec
commit 6ecf201beb
4 changed files with 13 additions and 9 deletions

View File

@ -1,7 +1,5 @@
interface MotaConfig { interface MotaConfig {
name: string; name: string;
/** 资源分组打包信息 */
resourceZip?: string[][];
resourceName?: string; resourceName?: string;
} }

View File

@ -12,6 +12,7 @@ import {
setLightList, setLightList,
setShadowNodes setShadowNodes
} from './shadow'; } from './shadow';
import { pColor } from '../utils';
export default function init() { export default function init() {
const origin4 = control.prototype.drawHero; const origin4 = control.prototype.drawHero;
@ -39,7 +40,7 @@ const shadowInfo: Partial<Record<FloorIds, Light[]>> = {
y: 144, y: 144,
decay: 20, decay: 20,
r: 150, r: 150,
color: '#e953', color: pColor('#e953'),
noShelter: true noShelter: true
}, },
{ {
@ -48,7 +49,7 @@ const shadowInfo: Partial<Record<FloorIds, Light[]>> = {
y: 144, y: 144,
decay: 20, decay: 20,
r: 150, r: 150,
color: '#e953', color: pColor('#e953'),
noShelter: true noShelter: true
}, },
{ {
@ -57,7 +58,7 @@ const shadowInfo: Partial<Record<FloorIds, Light[]>> = {
y: 336, y: 336,
decay: 20, decay: 20,
r: 150, r: 150,
color: '#e953', color: pColor('#e953'),
noShelter: true noShelter: true
}, },
{ {
@ -66,13 +67,13 @@ const shadowInfo: Partial<Record<FloorIds, Light[]>> = {
y: 336, y: 336,
decay: 20, decay: 20,
r: 150, r: 150,
color: '#e953', color: pColor('#e953'),
noShelter: true noShelter: true
} }
] ]
}; };
const backgroundInfo: Partial<Record<FloorIds, Color>> = { const backgroundInfo: Partial<Record<FloorIds, Color>> = {
MT50: '#0006' MT50: pColor('#0006')
}; };
const blurInfo: Partial<Record<FloorIds, number>> = {}; const blurInfo: Partial<Record<FloorIds, number>> = {};
const immersionInfo: Partial<Record<FloorIds, number>> = {}; const immersionInfo: Partial<Record<FloorIds, number>> = {};
@ -86,7 +87,7 @@ export function updateShadow(nocache: boolean = false) {
if (!shadowInfo[floor] || !backgroundInfo[floor]) { if (!shadowInfo[floor] || !backgroundInfo[floor]) {
removeAllLights(); removeAllLights();
setShadowNodes([]); setShadowNodes([]);
setBackground('#0000'); setBackground('transparent');
return; return;
} }
const f = core.status.thisMap; const f = core.status.thisMap;

View File

@ -6,6 +6,7 @@ import { ComputedRef, ref } from 'vue';
import { EVENT_KEY_CODE_MAP } from './keyCodes'; import { EVENT_KEY_CODE_MAP } from './keyCodes';
import axios from 'axios'; import axios from 'axios';
import { decompressFromBase64 } from 'lz-string'; import { decompressFromBase64 } from 'lz-string';
import { parseColor } from './webgl/utils';
type CanParseCss = keyof { type CanParseCss = keyof {
[P in keyof CSSStyleDeclaration as CSSStyleDeclaration[P] extends string [P in keyof CSSStyleDeclaration as CSSStyleDeclaration[P] extends string
@ -258,3 +259,7 @@ export function ensureArray<T>(arr: T): T extends any[] ? T : T[] {
// @ts-ignore // @ts-ignore
return arr instanceof Array ? arr : [arr]; return arr instanceof Array ? arr : [arr];
} }
export function pColor(color: string) {
return core.arrayToRGBA(parseColor(color));
}

2
src/types/util.d.ts vendored
View File

@ -563,7 +563,7 @@ type RGBArray = [number, number, number, number?];
/** /**
* *
*/ */
type Color = `#${string}` | _RGBA | RGBArray; type Color = `#${string}` | _RGBA | RGBArray | 'transparent';
/** /**
* *