mirror of
https://git.datalinker.icu/kijai/ComfyUI-KJNodes.git
synced 2025-12-09 21:04:41 +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}),
|
||||
"mask_width": ("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": (
|
||||
[
|
||||
'cardinal',
|
||||
|
||||
@ -150,10 +150,21 @@ app.registerExtension({
|
||||
|
||||
function createSplineEditor(context, reset=false) {
|
||||
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) {
|
||||
context.splineEditor.element.innerHTML = ''; // Clear the container
|
||||
}
|
||||
}
|
||||
const coordWidget = context.widgets.find(w => w.name === "coordinates");
|
||||
const interpolationWidget = context.widgets.find(w => w.name === "interpolation");
|
||||
const pointsWidget = context.widgets.find(w => w.name === "points_to_sample");
|
||||
@ -166,31 +177,16 @@ function createSplineEditor(context, reset=false) {
|
||||
var points_to_sample = pointsWidget.value
|
||||
interpolationWidget.callback = () => {
|
||||
interpolation = interpolationWidget.value
|
||||
vis.render();
|
||||
}
|
||||
|
||||
tensionWidget.callback = () => {
|
||||
tension = tensionWidget.value
|
||||
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();
|
||||
updatePath();
|
||||
}
|
||||
}
|
||||
|
||||
pointsWidget.callback = () => {
|
||||
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();
|
||||
updatePath();
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize or reset points array
|
||||
var w = 512
|
||||
@ -234,12 +230,7 @@ function createSplineEditor(context, reset=false) {
|
||||
})
|
||||
.event("mouseup", function() {
|
||||
if (this.pathElements !== null) {
|
||||
let coords = samplePoints(pathElements[0], points_to_sample);
|
||||
let coordsString = JSON.stringify(coords);
|
||||
pointsStoreWidget.value = JSON.stringify(points);
|
||||
if (coordWidget) {
|
||||
coordWidget.value = coordsString;
|
||||
}
|
||||
updatePath();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user