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:
bymyself
2024-09-24 00:19:53 -07:00
committed by GitHub
parent 5d8e8a2486
commit b21c0f59f9
19 changed files with 850 additions and 155 deletions

View File

@@ -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