From 7e01d2083d3e26d5239a332cf12e520468a39565 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 4 Mar 2024 19:53:45 +0200 Subject: proper selection colors --- src/services/theme_data/theme3_slot_functions.js | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'src/services') diff --git a/src/services/theme_data/theme3_slot_functions.js b/src/services/theme_data/theme3_slot_functions.js index 2715c827..074a88f0 100644 --- a/src/services/theme_data/theme3_slot_functions.js +++ b/src/services/theme_data/theme3_slot_functions.js @@ -1,5 +1,5 @@ import { convert, brightness } from 'chromatism' -import { alphaBlend, relativeLuminance } from '../color_convert/color_convert.js' +import { alphaBlend, getTextColor, relativeLuminance } from '../color_convert/color_convert.js' export const process = (text, functions, { findColor, findShadow }, { dynamicVars, staticVars }) => { const { funcName, argsString } = /\$(?\w+)\((?[#a-zA-Z0-9-,.'"\s]*)\)/.exec(text).groups @@ -23,6 +23,17 @@ export const colorFunctions = { return { ...colorArg, a: amount } } }, + textColor: { + argsNeeded: 2, + exec: (args, { findColor }, { dynamicVars, staticVars }) => { + const [backgroundArg, foregroundArg, preserve = 'preserve'] = args + + const background = convert(findColor(backgroundArg, { dynamicVars, staticVars })).rgb + const foreground = convert(findColor(foregroundArg, { dynamicVars, staticVars })).rgb + + return getTextColor(background, foreground, preserve === 'preserve') + } + }, blend: { argsNeeded: 3, exec: (args, { findColor }, { dynamicVars, staticVars }) => { -- cgit v1.2.3-70-g09d2