From 00e1172eb8f71fb14e465e6aac52fb3dfdcf119c Mon Sep 17 00:00:00 2001 From: Palazzini Luca Date: Fri, 13 Sep 2024 20:48:13 +0200 Subject: [PATCH] Rename some node inputs --- pyproject.toml | 2 +- visual_area_prompt.py | 10 +++++----- web/visual_area_prompt.js | 14 +++++--------- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/pyproject.toml b/pyproject.toml index f6aaa73..f716d8b 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "comfyui-visualarea-nodes" description = "This is a collection of nodes created to aid when managing area conditionings." -version = "1.0.6" +version = "1.0.7" license = {file = "LICENSE"} [project.urls] diff --git a/visual_area_prompt.py b/visual_area_prompt.py index c920651..f166acc 100644 --- a/visual_area_prompt.py +++ b/visual_area_prompt.py @@ -8,8 +8,8 @@ class VisualAreaPrompt: def INPUT_TYPES(cls): return { "required": { - "general_conditioning": ("CONDITIONING", { "tooltip": "Base conditioning. Will be concatenated to all other conditionings." }), - "global_conditioning": ("CONDITIONING", { "tooltip": "Base conditioning. Will be applied to the whole image once." }), + "all_area_conditioning": ("CONDITIONING", { "tooltip": "Base conditioning. Will be concatenated to all other conditionings, including global." }), + "global_conditioning": ("CONDITIONING", { "tooltip": "Will be applied to the whole image once." }), "merge_global": ("BOOLEAN", { "default": False, "tooltip": "Turning this on will make it so that the global conditioning will be concatenated to all other conditionings before being applied. (will not affect combined_conditioning output)." }), }, "hidden": { @@ -25,7 +25,7 @@ class VisualAreaPrompt: OUTPUT_NODE = False CATEGORY = "RegionalPrompt" - def run_node(self, general_conditioning, global_conditioning, merge_global, extra_pnginfo, unique_id, **kwargs): + def run_node(self, all_area_conditioning, global_conditioning, merge_global, extra_pnginfo, unique_id, **kwargs): # Get values for the conditioning areas from the extra_pnginfo conditioning_areas: list[list[float]] = [] for node in extra_pnginfo["workflow"]["nodes"]: @@ -38,7 +38,7 @@ class VisualAreaPrompt: # Create graph to evaluate the node graph: GraphBuilder = GraphBuilder() # Concat all other conditionings (to: (to: (to: general, from cond1), from cond2), from cond3... ... from global) - last_concat: Node = graph.node("ConditioningConcat", conditioning_to=general_conditioning, conditioning_from=conditionings[0]) + last_concat: Node = graph.node("ConditioningConcat", conditioning_to=all_area_conditioning, conditioning_from=conditionings[0]) # Start loop from the second element (first already concatenated) for cond in conditionings[1:]: last_concat: Node = graph.node("ConditioningConcat", conditioning_to=last_concat.out(0), conditioning_from=cond) @@ -47,7 +47,7 @@ class VisualAreaPrompt: # Concat general to all other area conditionings (to: general, from: cond) conditionings_general: list = [] for cond in conditionings: - conditionings_general.append(graph.node("ConditioningConcat", conditioning_to=general_conditioning, conditioning_from=cond)) + conditionings_general.append(graph.node("ConditioningConcat", conditioning_to=all_area_conditioning, conditioning_from=cond)) # Apply area with percentage from conditionings conditionings_area: list = [] for i in range(len(conditionings_general)): diff --git a/web/visual_area_prompt.js b/web/visual_area_prompt.js index a088f7a..856d663 100644 --- a/web/visual_area_prompt.js +++ b/web/visual_area_prompt.js @@ -15,7 +15,7 @@ const CANVAS_BORDER_COLOR = "#000000"; // Id of the node const _ID = "VisualAreaPrompt"; // Prefix of the input to add -const _PREFIX = "area-conditioning_"; +const _PREFIX = "area_conditioning_"; // Type of the input to add const _TYPE = "CONDITIONING"; // Defaults for area widgets (make sure to copy, or it will be modified) @@ -183,12 +183,12 @@ app.registerExtension({ // Add the canvas addAreaGraphWidget(this); // Add area selection control - addNumberInput(this, "id", 0, (value, _, node) => { + addNumberInput(this, "area_id", 0, (value, _, node) => { node.index = value; updateWidgetValues(node); }, { min: 0, max: 0, step: 10, precision: 0 }); // Add conditioning controls - ["x", "y", "width", "height", "strength"].forEach((name, i) => { + ["x", "y", "width", "height", "conditioning_strength"].forEach((name, i) => { addNumberInput(this, name, [..._AREA_DEFAULTS][i], (value, _, node) => { node.properties["area_values"][node.index][i] = value; }, { min: 0, max: i === 4 ? 10 : 1, step: 0.1, precision: 2 }); @@ -228,7 +228,7 @@ app.registerExtension({ // Remove the input this.removeInput(slot_idx); } - let slot_tracker = {}; + let counter = 0; let idx = 0; for (const slot of this.inputs) { // Skip static nodes @@ -242,12 +242,8 @@ app.registerExtension({ continue; } idx += 1; - const name = slot.name.split('_')[0]; - // Correctly increment the count in slot_tracker - const count = (slot_tracker[name] || 0) + 1; - slot_tracker[name] = count; // Update the slot name with the count if greater than 1 - slot.name = `${name}_${count - 1}`; + slot.name = `${_PREFIX}${counter++}`; } // Set ID widget new max and value const countDynamicInputs = this.inputs.filter((input) => input.name.includes(_PREFIX)).length;