Shift node color's brightness for light mode (#123)

* Shift node color's brightness for light mode

* nit

* Fix test
This commit is contained in:
Chenlei Hu
2024-07-13 09:01:35 -04:00
committed by GitHub
parent 15900cd523
commit f1acdf976a
4 changed files with 115 additions and 3 deletions

View File

@@ -20,6 +20,7 @@ import {
parseComfyWorkflow,
} from "../types/comfyWorkflow";
import { ComfyNodeDef } from "@/types/apiTypes";
import { lightenColor } from "@/utils/colorUtil";
import { ComfyAppMenu } from "./ui/menu/index";
import { getStorageValue } from "./utils";
import { ComfyWorkflowManager, ComfyWorkflow } from "./workflows";
@@ -1538,7 +1539,8 @@ export class ComfyApp {
// @ts-ignore
LGraphCanvas.prototype.drawNode = function (node, ctx) {
var editor_alpha = this.editor_alpha;
var old_color = node.bgcolor;
var old_color = node.color;
var old_bgcolor = node.bgcolor;
if (node.mode === 2) {
// never
@@ -1551,10 +1553,19 @@ 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 res = origDrawNode.apply(this, arguments);
this.editor_alpha = editor_alpha;
node.bgcolor = old_color;
node.color = old_color;
node.bgcolor = old_bgcolor;
return res;
};