diff --git a/visual_area_prompt.py b/visual_area_prompt.py index cb8867a..7a916c7 100644 --- a/visual_area_prompt.py +++ b/visual_area_prompt.py @@ -5,7 +5,7 @@ class VisualAreaPrompt: @classmethod def INPUT_TYPES(cls): return { - "required": { + "optional": { "global_conditioning": ("CONDITIONING", { "tooltip": "Base conditioning. Will be applied to the whole image." }), }, "hidden": { @@ -25,7 +25,8 @@ class VisualAreaPrompt: # TODO: Implement this function for node in extra_pnginfo["workflow"]["nodes"]: if node["id"] == int(unique_id): - print(node["properties"]) + conditioning_areas = node["properties"]["area_values"] + print(conditioning_areas) break return (global_conditioning, global_conditioning) diff --git a/web/visual_area_prompt.js b/web/visual_area_prompt.js index 2f1555b..1b3b128 100644 --- a/web/visual_area_prompt.js +++ b/web/visual_area_prompt.js @@ -10,6 +10,29 @@ function addNumberInput(node, inputName, startValue, updateFunc, settings = { mi ) } +function updateWidgetValues(node, index) { + // Return x value to widget + const xValue = node.properties["area_values"][index][0]; + node.properties["area_values"][index][0] = xValue ? xValue : 0.0; + node.widgets[1].value = xValue ? xValue : 0.0; + // Return y value to widget + const yValue = node.properties["area_values"][index][1]; + node.properties["area_values"][index][1] = yValue ? yValue : 0.0; + node.widgets[2].value = yValue ? yValue : 0.0; + // Return width value to widget + const widthValue = node.properties["area_values"][index][2]; + node.properties["area_values"][index][2] = widthValue ? widthValue : 1.0; + node.widgets[3].value = widthValue ? widthValue : 1.0; + // Return height value to widget + const heightValue = node.properties["area_values"][index][3]; + node.properties["area_values"][index][3] = heightValue ? heightValue : 1.0; + node.widgets[4].value = heightValue ? heightValue : 1.0; + // Return strength value to widget + const strValue = node.properties["area_values"][index][4]; + node.properties["area_values"][index][4] = strValue ? strValue : 1.0; + node.widgets[5].value = strValue ? strValue : 1.0; +} + const TypeSlot = { Input: 1, Output: 2, @@ -44,26 +67,7 @@ app.registerExtension({ if (!node.properties["area_values"][this.index]) { node.properties["area_values"][this.index] = []; } - // Return x value to widget - const xValue = node.properties["area_values"][this.index][0]; - node.properties["area_values"][this.index][0] = xValue ? xValue : 0.0; - node.widgets[1].value = xValue ? xValue : 0.0; - // Return y value to widget - const yValue = node.properties["area_values"][this.index][1]; - node.properties["area_values"][this.index][1] = yValue ? yValue : 0.0; - node.widgets[2].value = yValue ? yValue : 0.0; - // Return width value to widget - const widthValue = node.properties["area_values"][this.index][2]; - node.properties["area_values"][this.index][2] = widthValue ? widthValue : 1.0; - node.widgets[3].value = widthValue ? widthValue : 1.0; - // Return height value to widget - const heightValue = node.properties["area_values"][this.index][3]; - node.properties["area_values"][this.index][3] = heightValue ? heightValue : 1.0; - node.widgets[4].value = heightValue ? heightValue : 1.0; - // Return strength value to widget - const strValue = node.properties["area_values"][this.index][4]; - node.properties["area_values"][this.index][4] = strValue ? strValue : 1.0; - node.widgets[5].value = strValue ? strValue : 1.0; + updateWidgetValues(node, this.index); }, { min: 0, max: 0, step: 10, precision: 0 }); // x value input, has index 0 addNumberInput(this, "x", 0.0, (value, _, node) => { @@ -155,6 +159,7 @@ app.registerExtension({ } // Set ID widget max to correct value this.widgets[0].options.max = (dynamicInputs.length - 1) >= 0 ? (dynamicInputs.length - 1) : 0; + updateWidgetValues(this, this.index); // Return node this?.graph?.setDirtyCanvas(true); return me;