mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2025-12-11 13:54:30 +08:00
Spline editor cleanup
This commit is contained in:
parent
0920c127be
commit
6e0784801a
2
nodes.py
2
nodes.py
@ -4755,7 +4755,7 @@ class SplineEditor:
|
|||||||
"coordinates": ("STRING", {"multiline": False}),
|
"coordinates": ("STRING", {"multiline": False}),
|
||||||
"mask_width": ("INT", {"default": 512, "min": 8, "max": MAX_RESOLUTION, "step": 8}),
|
"mask_width": ("INT", {"default": 512, "min": 8, "max": MAX_RESOLUTION, "step": 8}),
|
||||||
"mask_height": ("INT", {"default": 512, "min": 8, "max": MAX_RESOLUTION, "step": 8}),
|
"mask_height": ("INT", {"default": 512, "min": 8, "max": MAX_RESOLUTION, "step": 8}),
|
||||||
"points_to_sample": ("INT", {"default": 4, "min": 2, "max": 1000, "step": 1}),
|
"points_to_sample": ("INT", {"default": 16, "min": 2, "max": 1000, "step": 1}),
|
||||||
"interpolation": (
|
"interpolation": (
|
||||||
[
|
[
|
||||||
'cardinal',
|
'cardinal',
|
||||||
|
|||||||
@ -151,6 +151,17 @@ app.registerExtension({
|
|||||||
function createSplineEditor(context, reset=false) {
|
function createSplineEditor(context, reset=false) {
|
||||||
console.log("creatingSplineEditor")
|
console.log("creatingSplineEditor")
|
||||||
|
|
||||||
|
function updatePath() {
|
||||||
|
points_to_sample = pointsWidget.value
|
||||||
|
let coords = samplePoints(pathElements[0], points_to_sample);
|
||||||
|
let coordsString = JSON.stringify(coords);
|
||||||
|
pointsStoreWidget.value = JSON.stringify(points);
|
||||||
|
if (coordWidget) {
|
||||||
|
coordWidget.value = coordsString;
|
||||||
|
}
|
||||||
|
vis.render();
|
||||||
|
}
|
||||||
|
|
||||||
if (reset && context.splineEditor.element) {
|
if (reset && context.splineEditor.element) {
|
||||||
context.splineEditor.element.innerHTML = ''; // Clear the container
|
context.splineEditor.element.innerHTML = ''; // Clear the container
|
||||||
}
|
}
|
||||||
@ -166,30 +177,15 @@ function createSplineEditor(context, reset=false) {
|
|||||||
var points_to_sample = pointsWidget.value
|
var points_to_sample = pointsWidget.value
|
||||||
interpolationWidget.callback = () => {
|
interpolationWidget.callback = () => {
|
||||||
interpolation = interpolationWidget.value
|
interpolation = interpolationWidget.value
|
||||||
vis.render();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
tensionWidget.callback = () => {
|
tensionWidget.callback = () => {
|
||||||
tension = tensionWidget.value
|
tension = tensionWidget.value
|
||||||
points_to_sample = pointsWidget.value
|
updatePath();
|
||||||
let coords = samplePoints(pathElements[0], points_to_sample);
|
|
||||||
let coordsString = JSON.stringify(coords);
|
|
||||||
pointsStoreWidget.value = JSON.stringify(points);
|
|
||||||
if (coordWidget) {
|
|
||||||
coordWidget.value = coordsString;
|
|
||||||
vis.render();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pointsWidget.callback = () => {
|
pointsWidget.callback = () => {
|
||||||
points_to_sample = pointsWidget.value
|
updatePath();
|
||||||
let coords = samplePoints(pathElements[0], points_to_sample);
|
|
||||||
let coordsString = JSON.stringify(coords);
|
|
||||||
pointsStoreWidget.value = JSON.stringify(points);
|
|
||||||
if (coordWidget) {
|
|
||||||
coordWidget.value = coordsString;
|
|
||||||
vis.render();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Initialize or reset points array
|
// Initialize or reset points array
|
||||||
@ -234,12 +230,7 @@ function createSplineEditor(context, reset=false) {
|
|||||||
})
|
})
|
||||||
.event("mouseup", function() {
|
.event("mouseup", function() {
|
||||||
if (this.pathElements !== null) {
|
if (this.pathElements !== null) {
|
||||||
let coords = samplePoints(pathElements[0], points_to_sample);
|
updatePath();
|
||||||
let coordsString = JSON.stringify(coords);
|
|
||||||
pointsStoreWidget.value = JSON.stringify(points);
|
|
||||||
if (coordWidget) {
|
|
||||||
coordWidget.value = coordsString;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user