优化黑色主题颜色计算

pull/1761/head
lyswhut 2023-12-17 21:50:12 +08:00
parent f75eeb07be
commit 2c0d2c4497
4 changed files with 21 additions and 21 deletions

View File

@ -8,7 +8,7 @@
* @param {string} c1 rgb(a) color2
* @returns color
*/
export const RGB_Linear_Blend=(p,c0,c1)=>{
exports.RGB_Linear_Blend=(p,c0,c1)=>{
var i=parseInt,r=Math.round,P=1-p,[a,b,c,d]=c0.split(","),[e,f,g,h]=c1.split(","),x=d||h,j=x?","+(!d?h:!h?d:r((parseFloat(d)*P+parseFloat(h)*p)*1000)/1000+")"):")";
return"rgb"+(x?"a(":"(")+r(i(a[3]=="a"?a.slice(5):a.slice(4))*P+i(e[3]=="a"?e.slice(5):e.slice(4))*p)+","+r(i(b)*P+i(f)*p)+","+r(i(c)*P+i(g)*p)+j;
}
@ -20,7 +20,7 @@ export const RGB_Linear_Blend=(p,c0,c1)=>{
* @param {string} c1 rgb(a) color2
* @returns color
*/
export const RGB_Log_Blend=(p,c0,c1)=>{
exports.RGB_Log_Blend=(p,c0,c1)=>{
var i=parseInt,r=Math.round,P=1-p,[a,b,c,d]=c0.split(","),[e,f,g,h]=c1.split(","),x=d||h,j=x?","+(!d?h:!h?d:r((parseFloat(d)*P+parseFloat(h)*p)*1000)/1000+")"):")";
return"rgb"+(x?"a(":"(")+r((P*i(a[3]=="a"?a.slice(5):a.slice(4))**2+p*i(e[3]=="a"?e.slice(5):e.slice(4))**2)**0.5)+","+r((P*i(b)**2+p*i(f)**2)**0.5)+","+r((P*i(c)**2+p*i(g)**2)**0.5)+j;
}
@ -32,7 +32,7 @@ export const RGB_Log_Blend=(p,c0,c1)=>{
* @param {string} c0 rgb(a) color
* @returns color
*/
export const RGB_Linear_Shade=(p,c0)=>{
exports.RGB_Linear_Shade=(p,c0)=>{
var i=parseInt,r=Math.round,[a,b,c,d]=c0.split(","),n=p<0,t=n?0:255*p,P=n?1+p:1-p;
return"rgb"+(d?"a(":"(")+r(i(a[3]=="a"?a.slice(5):a.slice(4))*P+t)+","+r(i(b)*P+t)+","+r(i(c)*P+t)+(d?","+d:")");
}
@ -44,7 +44,7 @@ export const RGB_Linear_Shade=(p,c0)=>{
* @param {string} c0 rgb(a) color
* @returns color
*/
export const RGB_Log_Shade=(p,c0)=>{
exports.RGB_Log_Shade=(p,c0)=>{
var i=parseInt,r=Math.round,[a,b,c,d]=c0.split(","),n=p<0,t=n?0:p*255**2,P=n?1+p:1-p;
return"rgb"+(d?"a(":"(")+r((P*i(a[3]=="a"?a.slice(5):a.slice(4))**2+t)**0.5)+","+r((P*i(b)**2+t)**0.5)+","+r((P*i(c)**2+t)**0.5)+(d?","+d:")");
}
@ -56,7 +56,7 @@ export const RGB_Log_Shade=(p,c0)=>{
* @param {string} color
* @returns color
*/
export const RGB_Alpha_Shade = (p, color) => {
exports.RGB_Alpha_Shade = (p, color) => {
var i = parseInt
var n = p < 0
var [r, g, b, a] = color.split(",")

View File

@ -1,8 +1,8 @@
//! 更新默认主题配置后,需要执行 npm run build:theme 重新构建index.json
import fs from 'fs'
import path from 'path'
import { createThemeColors } from './utils'
const fs = require('fs')
const path = require('path')
const { createThemeColors } = require('./utils')
const defaultThemes = [
{

View File

@ -2766,16 +2766,16 @@
"--color-primary-light-900-alpha-700": "rgba(59, 59, 59, 0.30)",
"--color-primary-light-900-alpha-800": "rgba(59, 59, 59, 0.20)",
"--color-primary-light-900-alpha-900": "rgba(59, 59, 59, 0.10)",
"--color-primary-light-1000": "rgb(47,47,47)",
"--color-primary-light-1000-alpha-100": "rgba(47, 47, 47, 0.90)",
"--color-primary-light-1000-alpha-200": "rgba(47, 47, 47, 0.80)",
"--color-primary-light-1000-alpha-300": "rgba(47, 47, 47, 0.70)",
"--color-primary-light-1000-alpha-400": "rgba(47, 47, 47, 0.60)",
"--color-primary-light-1000-alpha-500": "rgba(47, 47, 47, 0.50)",
"--color-primary-light-1000-alpha-600": "rgba(47, 47, 47, 0.40)",
"--color-primary-light-1000-alpha-700": "rgba(47, 47, 47, 0.30)",
"--color-primary-light-1000-alpha-800": "rgba(47, 47, 47, 0.20)",
"--color-primary-light-1000-alpha-900": "rgba(47, 47, 47, 0.10)",
"--color-primary-light-1000": "rgb(38,38,38)",
"--color-primary-light-1000-alpha-100": "rgba(38, 38, 38, 0.90)",
"--color-primary-light-1000-alpha-200": "rgba(38, 38, 38, 0.80)",
"--color-primary-light-1000-alpha-300": "rgba(38, 38, 38, 0.70)",
"--color-primary-light-1000-alpha-400": "rgba(38, 38, 38, 0.60)",
"--color-primary-light-1000-alpha-500": "rgba(38, 38, 38, 0.50)",
"--color-primary-light-1000-alpha-600": "rgba(38, 38, 38, 0.40)",
"--color-primary-light-1000-alpha-700": "rgba(38, 38, 38, 0.30)",
"--color-primary-light-1000-alpha-800": "rgba(38, 38, 38, 0.20)",
"--color-primary-light-1000-alpha-900": "rgba(38, 38, 38, 0.10)",
"--color-theme": "rgb(59,59,59)",
"--color-1000": "rgb(229, 229, 229)",
"--color-950": "rgb(218,218,218)",

View File

@ -1,6 +1,6 @@
import { RGB_Linear_Shade, RGB_Alpha_Shade } from './colorUtils'
const { RGB_Linear_Shade, RGB_Alpha_Shade } = require('./colorUtils')
export const createThemeColors = (rgbaColor, fontRgbaColor, isDark) => {
exports.createThemeColors = (rgbaColor, fontRgbaColor, isDark) => {
const colors = {
'--color-primary': rgbaColor,
}
@ -22,7 +22,7 @@ export const createThemeColors = (rgbaColor, fontRgbaColor, isDark) => {
colors[`--color-primary-light-${i * 100}-alpha-${j * 100}`] = RGB_Alpha_Shade(0.1 * j, preColor)
}
}
preColor = RGB_Linear_Shade(isDark ? -0.2 : 1, preColor)
preColor = RGB_Linear_Shade(isDark ? -0.35 : 1, preColor)
colors[`--color-primary-light-${1000}`] = preColor
for (let j = 1; j < 10; j += 1) {
colors[`--color-primary-light-${1000}-alpha-${j * 100}`] = RGB_Alpha_Shade(0.1 * j, preColor)