mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-08 00:50:05 +00:00
Apply node opacity setting to all node colors (#947)
* Apply opacity to node colors. Resolves #928 * Handle default and custom colors all in draw handler * Add colorUtil unit tests * Add Playwright test * Remove comment * Revert colorPalette.ts changes * Remove unused imports * Fix typo * Update test expectations [skip ci] --------- Co-authored-by: github-actions <github-actions@github.com>
This commit is contained in:
@@ -21,7 +21,7 @@ import {
|
||||
validateComfyWorkflow
|
||||
} from '../types/comfyWorkflow'
|
||||
import { ComfyNodeDef, StatusWsMessageStatus } from '@/types/apiTypes'
|
||||
import { lightenColor } from '@/utils/colorUtil'
|
||||
import { adjustColor, ColorAdjustOptions } from '@/utils/colorUtil'
|
||||
import { ComfyAppMenu } from './ui/menu/index'
|
||||
import { getStorageValue } from './utils'
|
||||
import { ComfyWorkflowManager, ComfyWorkflow } from './workflows'
|
||||
@@ -1568,14 +1568,25 @@ export class ComfyApp {
|
||||
this.editor_alpha = 0.2
|
||||
}
|
||||
|
||||
const adjustColor = (color?: string) => {
|
||||
return color ? lightenColor(color, 0.5) : color
|
||||
}
|
||||
if (app.ui.settings.getSettingValue('Comfy.ColorPalette') === 'light') {
|
||||
node.bgcolor = adjustColor(node.bgcolor)
|
||||
node.color = adjustColor(node.color)
|
||||
const adjustments: ColorAdjustOptions = {}
|
||||
|
||||
const opacity = useSettingStore().get('Comfy.Node.Opacity')
|
||||
if (opacity) adjustments.opacity = opacity
|
||||
|
||||
if (useSettingStore().get('Comfy.ColorPalette') === 'light') {
|
||||
adjustments.lightness = 0.5
|
||||
|
||||
// Lighten title bar of colored nodes on light theme
|
||||
if (old_color) {
|
||||
node.color = adjustColor(old_color, { lightness: 0.5 })
|
||||
}
|
||||
}
|
||||
|
||||
node.bgcolor = adjustColor(
|
||||
old_bgcolor || LiteGraph.NODE_DEFAULT_BGCOLOR,
|
||||
adjustments
|
||||
)
|
||||
|
||||
const res = origDrawNode.apply(this, arguments)
|
||||
|
||||
this.editor_alpha = editor_alpha
|
||||
|
||||
Reference in New Issue
Block a user