Skip to content

Commit

Permalink
* aligned core_color to match breakout updates
Browse files Browse the repository at this point in the history
* fixed configuration bug when no configuration present
* moved color defaults to top and better entries
* removed old config file route
  • Loading branch information
Amorano committed Mar 3, 2025
1 parent 7678d67 commit c01c68b
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 82 deletions.
33 changes: 18 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,22 +94,13 @@ You can colorize nodes via their `title background`, `node body` or `title text`

## UPDATES

**2024/02/18** @1.7.25:
* nomenclature alignment for breakout repos
* better typehints
*
**IF YOU ARE USING AN OLD VERSION THAT HAS COLOR CONFIGURATIONS THAT NO LONGER WORK, I CAN HELP YOU MIGRATE THEM. JUST START A TICKET OR SEND A MESSAGE**

**2024/02/17** @1.7.20:
* changed to newer conversion logic on frontend 1.10.3+ -- `VECTOR` types will auto-switch to conversion logic based on version
* Fix for `VALUE NODE` to properly output vector data -- node in deprecation mode
* Added explcit `VECTOR2 / INT`, `VECTOR3 / INT`, `VECTOR4 / INT` nodes for value input
* Restructure to remove old UX hide/show widget features for compatibility with frontend (1.10.3+)
* Added `BATCH` output to `TICK NODE` so you can get a normal comfyui list (top output) and a Jovimetrix list (BATCH)

<div align="center">
<img src="https://github.com/user-attachments/assets/8ed13e6a-218c-468a-a480-53ab55b04d21" alt="explicit vector node supports" width="640"/>
<img src="https://github.com/user-attachments/assets/4459855c-c4e6-4739-811e-a6c90aa5a90c" alt="TICK Node Batch Support Output" width="384"/>
</div>
**2025/03/02** @1.7.33:
* aligned core_color to match breakout updates
* fixed configuration bug when no configuration present
* moved color defaults to top and better entries
* removed old config file route

**2025/03/01** @1.7.31:
* fixed all the year dates in readme since I have been writing 2024! =D
Expand All @@ -131,6 +122,18 @@ You can colorize nodes via their `title background`, `node body` or `title text`
* cleaned up typehints
* fixed stupid bug that would just overwrite color defaults on refresh

**2025/02/17** @1.7.20:
* changed to newer conversion logic on frontend 1.10.3+ -- `VECTOR` types will auto-switch to conversion logic based on version
* Fix for `VALUE NODE` to properly output vector data -- node in deprecation mode
* Added explcit `VECTOR2 / INT`, `VECTOR3 / INT`, `VECTOR4 / INT` nodes for value input
* Restructure to remove old UX hide/show widget features for compatibility with frontend (1.10.3+)
* Added `BATCH` output to `TICK NODE` so you can get a normal comfyui list (top output) and a Jovimetrix list (BATCH)

<div align="center">
<img src="https://github.com/user-attachments/assets/8ed13e6a-218c-468a-a480-53ab55b04d21" alt="explicit vector node supports" width="640"/>
<img src="https://github.com/user-attachments/assets/4459855c-c4e6-4739-811e-a6c90aa5a90c" alt="TICK Node Batch Support Output" width="384"/>
</div>

# INSTALLATION

[Please see the wiki for advanced use of the environment variables used during startup](https://github.com/Amorano/Jovimetrix/wiki/B.-ASICS)
Expand Down
11 changes: 0 additions & 11 deletions __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@

JOV_CONFIG = {}
JOV_WEB = ROOT / 'web'
JOV_CONFIG_FILE = JOV_WEB / 'config.json'

# nodes to skip on import; for online systems; skip Export, Streamreader, etc...
JOV_IGNORE_NODE = ROOT / 'ignore.txt'
Expand Down Expand Up @@ -767,13 +766,6 @@ async def jovimetrix_message_post(req) -> Any:
return web.json_response(json_data)
return web.json_response({})

@PromptServer.instance.routes.get("/jovimetrix/config")
async def jovimetrix_config(req) -> Any:
global JOV_CONFIG, JOV_CONFIG_FILE
if len(JOV_CONFIG) == 0:
JOV_CONFIG = configLoad(JOV_CONFIG_FILE)
return web.json_response(JOV_CONFIG)

async def object_info(node_class: str, scheme:str, host: str) -> Any:
global COMFYUI_OBJ_DATA
if (info := COMFYUI_OBJ_DATA.get(node_class, None)) is None:
Expand Down Expand Up @@ -881,9 +873,6 @@ def loader():
global JOV_CONFIG, JOV_IGNORE_NODE, NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
NODE_LIST_MAP = {}

if JOV_CONFIG_FILE.exists():
JOV_CONFIG = configLoad(JOV_CONFIG_FILE)

if JOV_IGNORE_NODE.exists():
JOV_IGNORE_NODE = configLoad(JOV_IGNORE_NODE, False)
else:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[project]
name = "jovimetrix"
description = "Integrates Webcam, MIDI, Spout and GLSL shader support. Animation via tick. Parameter manipulation with wave generator. Math operations with Unary and Binary support. Value conversion for all major types (int, string, list, dict, Image, Mask). Shape mask generation, image stacking and channel ops, batch splitting, merging and randomizing, load images and video from anywhere, dynamic bus routing with a single node, export support for GIPHY, save output anywhere! flatten, crop, transform; check colorblindness, make stereogram or stereoscopic images, or liner interpolate values and more."
version = "1.7.31"
version = "1.7.33"
license = { file = "LICENSE" }
readme = "README.md"
authors = [{ name = "Alexander G. Morano", email = "[email protected]" }]
Expand Down
109 changes: 54 additions & 55 deletions web/core/core_color.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,25 @@ import { app } from "../../../scripts/app.js";
import { api } from "../../../scripts/api.js"
import { $el } from "../../../scripts/ui.js";

const setting_regex = 'jovi.color.regex';
const setting_theme = 'jovi.color.theme';
const DEFAULT_THEME = {
"JOV_CAPTURE 📸": { title: "#661f66" },
"JOV_GL 🌈": { title: "#1f661f" },
"JOV_MEASURE 📐": { title: "#993838" },
"JOV_MIDI 🎛️": { title: "#66661f" },
"JOV_SPOUT 📺": { title: "#1f6666" },
"JOVIMETRIX 🔺🟩🔵": { title: "#a23da2" },
"JOVIMETRIX 🔺🟩🔵/CREATE": { title: "#1b871b" },
"JOVIMETRIX 🔺🟩🔵/COMPOSE": { title: "#5c1f9a" },
"JOVIMETRIX 🔺🟩🔵/CALC": { title: "#993838" },
"JOVIMETRIX 🔺🟩🔵/DEVICE": { title: "#1f9999" },
"JOVIMETRIX 🔺🟩🔵/UTILITY": { title: "#0a0a0a" }
};

const SETTING_REGEX = 'jovi.color.regex';
const SETTING_THEME = 'jovi.color.theme';

let PANEL_COLORIZE, NODE_LIST;

async function api_get(url) {
var response = await api.fetchApi(url, { cache: "no-store" })
return await response.json()
}

function normalizeHex(hex) {
if (!hex.startsWith('#')) {
hex = '#' + hex;
Expand Down Expand Up @@ -47,15 +56,17 @@ function colorContrast(hexColor) {

function getColor(node) {
// regex overrides first
const CONFIG_REGEX = app.extensionManager.setting.get(setting_regex);
for (const { regex, ...colors } of CONFIG_REGEX || []) {
if (regex && node.type.match(new RegExp(regex, "i"))) {
return colors;
const CONFIG_REGEX = app.extensionManager.setting.get(SETTING_REGEX);
if (Array.isArray(CONFIG_REGEX)) {
for (const { regex, ...colors } of CONFIG_REGEX) {
if (regex && node.type.match(new RegExp(regex, "i"))) {
return colors;
}
}
}

// explicit color set first...
const CONFIG_THEME = app.extensionManager.setting.get(setting_theme);
const CONFIG_THEME = app.extensionManager.setting.get(SETTING_THEME);
const newColor = CONFIG_THEME?.[node.type]
?? (function() {
const color = NODE_LIST[node.type];
Expand Down Expand Up @@ -243,11 +254,11 @@ class JovimetrixPanelColorize {
const cb = this.buttonCurrent.dataset;
const color = normalizeHex(cb.color)
if (cb.idx && cb.idx !== "undefined") {
const CONFIG_REGEX = app.extensionManager.setting.get(setting_regex);
const CONFIG_REGEX = app.extensionManager.setting.get(SETTING_REGEX);
CONFIG_REGEX[cb.idx][cb.type] = color;
await app.extensionManager.setting.set(setting_regex, CONFIG_REGEX);
await app.extensionManager.setting.set(SETTING_REGEX, CONFIG_REGEX);
} else {
const CONFIG_THEME = app.extensionManager.setting.get(setting_theme);
const CONFIG_THEME = app.extensionManager.setting.get(SETTING_THEME);
CONFIG_THEME[cb.name] = CONFIG_THEME[cb.name] || (CONFIG_THEME[cb.name] = {});

let colorCheck = LiteGraph.NODE_DEFAULT_BGCOLOR;
Expand All @@ -262,7 +273,7 @@ class JovimetrixPanelColorize {
} else if (color !== colorCheck) {
CONFIG_THEME[cb.name][cb.type] = color;
}
await app.extensionManager.setting.set(setting_theme, CONFIG_THEME);
await app.extensionManager.setting.set(SETTING_THEME, CONFIG_THEME);
}

this.buttonCurrent.style.backgroundColor = color;
Expand Down Expand Up @@ -444,7 +455,7 @@ class JovimetrixPanelColorize {
const table = $el("table.flexible-table");
this.tbody = $el("tbody");

let CONFIG_REGEX = app.extensionManager.setting.get(setting_regex) || [];
let CONFIG_REGEX = app.extensionManager.setting.get(SETTING_REGEX) || [];
if (!Array.isArray(CONFIG_REGEX)) {
CONFIG_REGEX = []
}
Expand All @@ -466,7 +477,7 @@ class JovimetrixPanelColorize {
createColorPalettes() {
let background_index = 0;
const categories = [];
const CONFIG_THEME = app.extensionManager.setting.get(setting_theme);
const CONFIG_THEME = app.extensionManager.setting.get(SETTING_THEME);

Object.entries(NODE_LIST).forEach(([nodeName, node]) => {
const category = node.category;
Expand Down Expand Up @@ -568,21 +579,28 @@ app.registerExtension({
name: "jovimetrix.color",
settings: [
{
id: setting_regex,
id: SETTING_REGEX,
name: "Regex Entries for Jovimetrix Colorizer",
type: "hidden",
defaultValue: {}
},
{
id: setting_theme,
id: SETTING_THEME,
name: "Node theme entries for Jovimetrix Colorizer",
type: "hidden",
defaultValue: {}
},
],
async init() {
document.head.appendChild(Object.assign(document.createElement('script'), {
src: "https://cdn.jsdelivr.net/npm/@jaames/iro@5"
}));
},
async setup() {

const all_nodes = await api_get("/object_info");
var response = await api.fetchApi("/object_info", { cache: "no-store" });
const all_nodes = await response.json();

NODE_LIST = Object.entries(all_nodes).sort((a, b) => {
const categoryA = a[1].category.toLowerCase();
const categoryB = b[1].category.toLowerCase();
Expand All @@ -596,46 +614,27 @@ app.registerExtension({
});
NODE_LIST = Object.fromEntries(NODE_LIST);

const CONFIG_CORE = await api_get("/jovimetrix/config");
let CONFIG_REGEX = app.extensionManager.setting.get(setting_regex);
let CONFIG_REGEX = app.extensionManager.setting.get(SETTING_REGEX) || [];
if (!Array.isArray(CONFIG_REGEX)) {
CONFIG_REGEX = CONFIG_CORE?.user?.default?.color?.regex || [
{ "regex": "" },
{ "regex": "" },
{ "regex": "" },
{ "regex": "" },
{ "regex": "" }
];
CONFIG_REGEX = [];
}
while (CONFIG_REGEX.length < 5) {
CONFIG_REGEX.push({ "regex": "" });
}
await app.extensionManager.setting.set(setting_regex, CONFIG_REGEX);
await app.extensionManager.setting.set(SETTING_REGEX, CONFIG_REGEX);

let CONFIG_THEME = app.extensionManager.setting.get(setting_theme);
if (Object.keys(CONFIG_THEME).length === 0) {
const CONFIG_THEME = CONFIG_CORE?.user?.default?.color?.theme || {
"JOVIMETRIX \ud83d\udd3a\ud83d\udfe9\ud83d\udd35": {
title: "#A23DA2"
},
"JOVIMETRIX \ud83d\udd3a\ud83d\udfe9\ud83d\udd35/CREATE": {
title: "#1b871b"
},
"JOVIMETRIX \ud83d\udd3a\ud83d\udfe9\ud83d\udd35/COMPOSE": {
title: "#5C1F9A"
},
"JOVIMETRIX \ud83d\udd3a\ud83d\udfe9\ud83d\udd35/CALC": {
title: "#993838"
},
"JOVIMETRIX \ud83d\udd3a\ud83d\udfe9\ud83d\udd35/DEVICE": {
title: "#1f9999"
},
"JOVIMETRIX \ud83d\udd3a\ud83d\udfe9\ud83d\udd35/UTILITY": {
title: "#0A0A0A"
}
let CONFIG_THEME = app.extensionManager.setting.get(SETTING_THEME) || {};
Object.keys(DEFAULT_THEME).forEach(key => {
if (!(key in CONFIG_THEME)) {
CONFIG_THEME[key] = DEFAULT_THEME[key];
}
await app.extensionManager.setting.set(setting_theme, CONFIG_THEME);
}
});

try {
await app.extensionManager.setting.set(SETTING_THEME, CONFIG_THEME);
console.info("wrote new Jovi_Colorizer defaults")
} catch (error) {
console.error("Failed to update settings:", error);
}
}
});
});

0 comments on commit c01c68b

Please sign in to comment.