颜色转换

This commit is contained in:
xiaoxiao 2025-07-10 09:29:37 +08:00
parent 4641e9ecee
commit 4d6af76e47

View File

@ -181,4 +181,12 @@ export class ChangeUtil {
}
return length as number; // 已经是数值类型
}
// 将HEX颜色转换为RGBA格式
static hexToRgba (hex: string, alpha: number) : string | ResourceStr {
const r = parseInt(hex.slice(1, 3), 16);
const g = parseInt(hex.slice(3, 5), 16);
const b = parseInt(hex.slice(5, 7), 16);
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
};
}