From b3e5108ad42eef99b153436d9051e4c3263b97a5 Mon Sep 17 00:00:00 2001 From: kijai <40791699+kijai@users.noreply.github.com> Date: Tue, 22 Oct 2024 16:33:22 +0300 Subject: [PATCH] Add AppendStringsToList --- __init__.py | 1 + nodes/nodes.py | 16 ++++++++++++++++ web/js/spline_editor.js | 26 +++++++++++++------------- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/__init__.py b/__init__.py index 50b374e..9b8606b 100644 --- a/__init__.py +++ b/__init__.py @@ -103,6 +103,7 @@ NODE_CONFIG = { "GetLatentsFromBatchIndexed": {"class": GetLatentsFromBatchIndexed, "name": "Get Latents From Batch Indexed"}, "ScaleBatchPromptSchedule": {"class": ScaleBatchPromptSchedule, "name": "Scale Batch Prompt Schedule"}, "CameraPoseVisualizer": {"class": CameraPoseVisualizer, "name": "Camera Pose Visualizer"}, + "AppendStringsToList": {"class": AppendStringsToList, "name": "Append Strings To List"}, "JoinStrings": {"class": JoinStrings, "name": "Join Strings"}, "JoinStringMulti": {"class": JoinStringMulti, "name": "Join String Multi"}, "SomethingToString": {"class": SomethingToString, "name": "Something To String"}, diff --git a/nodes/nodes.py b/nodes/nodes.py index fa0d5cf..5e44635 100644 --- a/nodes/nodes.py +++ b/nodes/nodes.py @@ -219,7 +219,23 @@ Combines multiple conditioning nodes into one cond = cond_concat_node.concat(cond, new_cond)[0] return (cond, inputcount,) +class AppendStringsToList: + @classmethod + def INPUT_TYPES(cls): + return { + "required": { + "string1": ("STRING", {"default": '', "forceInput": True}), + "string2": ("STRING", {"default": '', "forceInput": True}), + } + } + RETURN_TYPES = ("STRING",) + FUNCTION = "joinstring" + CATEGORY = "KJNodes/constants" + def joinstring(self, string1, string2): + joined_string = [string1, string2] + return (joined_string, ) + class JoinStrings: @classmethod def INPUT_TYPES(cls): diff --git a/web/js/spline_editor.js b/web/js/spline_editor.js index b4223c8..6c303aa 100644 --- a/web/js/spline_editor.js +++ b/web/js/spline_editor.js @@ -270,11 +270,11 @@ class SplineEditor{ this.widthWidget = context.widgets.find(w => w.name === "mask_width"); this.heightWidget = context.widgets.find(w => w.name === "mask_height"); - var interpolation = this.interpolationWidget.value - var tension = this.tensionWidget.value + this.interpolation = this.interpolationWidget.value + this.tension = this.tensionWidget.value this.points_to_sample = this.pointsWidget.value - var rangeMin = this.minValueWidget.value - var rangeMax = this.maxValueWidget.value + this.rangeMin = this.minValueWidget.value + this.rangeMax = this.maxValueWidget.value this.pointsLayer = null; this.samplingMethod = this.samplingMethodWidget.value @@ -284,11 +284,11 @@ class SplineEditor{ this.interpolationWidget.callback = () => { - interpolation = this.interpolationWidget.value + this.interpolation = this.interpolationWidget.value this.updatePath(); } this.samplingMethodWidget.callback = () => { - this.samplingMethod = samplingMethodWidget.value + this.samplingMethod = this.samplingMethodWidget.value if (this.samplingMethod == "path") { this.dotShape = "triangle" } @@ -299,7 +299,7 @@ class SplineEditor{ this.updatePath(); } this.tensionWidget.callback = () => { - tension = this.tensionWidget.value + this.tension = this.tensionWidget.value this.updatePath(); } this.pointsWidget.callback = () => { @@ -307,11 +307,11 @@ class SplineEditor{ this.updatePath(); } this.minValueWidget.callback = () => { - rangeMin = this.minValueWidget.value + this.rangeMin = this.minValueWidget.value this.updatePath(); } this.maxValueWidget.callback = () => { - rangeMax = this.maxValueWidget.value + this.rangeMax = this.maxValueWidget.value this.updatePath(); } this.widthWidget.callback = () => { @@ -428,8 +428,8 @@ this.heightWidget.callback = () => { .data(() => this.points) .left(d => d.x) .top(d => d.y) - .interpolate(() => interpolation) - .tension(() => tension) + .interpolate(() => this.interpolation) + .tension(() => this.tension) .segmented(() => false) .strokeStyle(pv.Colors.category10().by(pv.index)) .lineWidth(3) @@ -522,8 +522,8 @@ this.heightWidget.callback = () => { if (this.samplingMethod == "path") { return `X: ${Math.round(d.x)}, Y: ${Math.round(d.y)}`; } else { - let frame = Math.round((d.x / self.width) * this.points_to_sample); - let normalizedY = (1.0 - (d.y / self.height) - 0.0) * (rangeMax - rangeMin) + rangeMin; + let frame = Math.round((d.x / self.width) * self.points_to_sample); + let normalizedY = (1.0 - (d.y / self.height) - 0.0) * (self.rangeMax - self.rangeMin) + self.rangeMin; let normalizedX = (d.x / self.width); return `F: ${frame}, X: ${normalizedX.toFixed(2)}, Y: ${normalizedY.toFixed(2)}`; }