Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
db63aa7e
"git@developer.sourcefind.cn:chenpangpang/ComfyUI.git" did not exist on "a527d0c795ba5572708095fcf0f9366e2076ba7e"
Commit
db63aa7e
authored
Sep 17, 2023
by
comfyanonymous
Browse files
Nodes can now control the rounding in the UI.
parent
321c5fa2
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
25 additions
and
10 deletions
+25
-10
custom_nodes/example_node.py.example
custom_nodes/example_node.py.example
+7
-1
nodes.py
nodes.py
+2
-2
web/scripts/widgets.js
web/scripts/widgets.js
+16
-7
No files found.
custom_nodes/example_node.py.example
View file @
db63aa7e
...
@@ -54,7 +54,13 @@ class Example:
...
@@ -54,7 +54,13 @@ class Example:
"step": 64, #Slider's step
"step": 64, #Slider's step
"display": "number" # Cosmetic only: display as "number" or "slider"
"display": "number" # Cosmetic only: display as "number" or "slider"
}),
}),
"float_field": ("FLOAT", {"default": 1.0, "min": 0.0, "max": 10.0, "step": 0.01, "display": "number"}),
"float_field": ("FLOAT", {
"default": 1.0,
"min": 0.0,
"max": 10.0,
"step": 0.01,
"round": 0.001, #The value represeting the precision to round to, will be set to the step value by default. Can be set to False to disable rounding.
"display": "number"}),
"print_to_screen": (["enable", "disable"],),
"print_to_screen": (["enable", "disable"],),
"string_field": ("STRING", {
"string_field": ("STRING", {
"multiline": False, #True if you want the field to look like the one on the ClipTextEncode node
"multiline": False, #True if you want the field to look like the one on the ClipTextEncode node
...
...
nodes.py
View file @
db63aa7e
...
@@ -1217,7 +1217,7 @@ class KSampler:
...
@@ -1217,7 +1217,7 @@ class KSampler:
{
"model"
:
(
"MODEL"
,),
{
"model"
:
(
"MODEL"
,),
"seed"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
0xffffffffffffffff
}),
"seed"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
0xffffffffffffffff
}),
"steps"
:
(
"INT"
,
{
"default"
:
20
,
"min"
:
1
,
"max"
:
10000
}),
"steps"
:
(
"INT"
,
{
"default"
:
20
,
"min"
:
1
,
"max"
:
10000
}),
"cfg"
:
(
"FLOAT"
,
{
"default"
:
8.0
,
"min"
:
0.0
,
"max"
:
100.0
}),
"cfg"
:
(
"FLOAT"
,
{
"default"
:
8.0
,
"min"
:
0.0
,
"max"
:
100.0
,
"step"
:
0.5
,
"round"
:
0.01
}),
"sampler_name"
:
(
comfy
.
samplers
.
KSampler
.
SAMPLERS
,
),
"sampler_name"
:
(
comfy
.
samplers
.
KSampler
.
SAMPLERS
,
),
"scheduler"
:
(
comfy
.
samplers
.
KSampler
.
SCHEDULERS
,
),
"scheduler"
:
(
comfy
.
samplers
.
KSampler
.
SCHEDULERS
,
),
"positive"
:
(
"CONDITIONING"
,
),
"positive"
:
(
"CONDITIONING"
,
),
...
@@ -1243,7 +1243,7 @@ class KSamplerAdvanced:
...
@@ -1243,7 +1243,7 @@ class KSamplerAdvanced:
"add_noise"
:
([
"enable"
,
"disable"
],
),
"add_noise"
:
([
"enable"
,
"disable"
],
),
"noise_seed"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
0xffffffffffffffff
}),
"noise_seed"
:
(
"INT"
,
{
"default"
:
0
,
"min"
:
0
,
"max"
:
0xffffffffffffffff
}),
"steps"
:
(
"INT"
,
{
"default"
:
20
,
"min"
:
1
,
"max"
:
10000
}),
"steps"
:
(
"INT"
,
{
"default"
:
20
,
"min"
:
1
,
"max"
:
10000
}),
"cfg"
:
(
"FLOAT"
,
{
"default"
:
8.0
,
"min"
:
0.0
,
"max"
:
100.0
}),
"cfg"
:
(
"FLOAT"
,
{
"default"
:
8.0
,
"min"
:
0.0
,
"max"
:
100.0
,
"step"
:
0.5
,
"round"
:
0.01
}),
"sampler_name"
:
(
comfy
.
samplers
.
KSampler
.
SAMPLERS
,
),
"sampler_name"
:
(
comfy
.
samplers
.
KSampler
.
SAMPLERS
,
),
"scheduler"
:
(
comfy
.
samplers
.
KSampler
.
SCHEDULERS
,
),
"scheduler"
:
(
comfy
.
samplers
.
KSampler
.
SCHEDULERS
,
),
"positive"
:
(
"CONDITIONING"
,
),
"positive"
:
(
"CONDITIONING"
,
),
...
...
web/scripts/widgets.js
View file @
db63aa7e
...
@@ -2,17 +2,22 @@ import { api } from "./api.js"
...
@@ -2,17 +2,22 @@ import { api } from "./api.js"
function
getNumberDefaults
(
inputData
,
defaultStep
)
{
function
getNumberDefaults
(
inputData
,
defaultStep
)
{
let
defaultVal
=
inputData
[
1
][
"
default
"
];
let
defaultVal
=
inputData
[
1
][
"
default
"
];
let
{
min
,
max
,
step
}
=
inputData
[
1
];
let
{
min
,
max
,
step
,
round
}
=
inputData
[
1
];
if
(
defaultVal
==
undefined
)
defaultVal
=
0
;
if
(
defaultVal
==
undefined
)
defaultVal
=
0
;
if
(
min
==
undefined
)
min
=
0
;
if
(
min
==
undefined
)
min
=
0
;
if
(
max
==
undefined
)
max
=
2048
;
if
(
max
==
undefined
)
max
=
2048
;
if
(
step
==
undefined
)
step
=
defaultStep
;
if
(
step
==
undefined
)
step
=
defaultStep
;
// precision is the number of decimal places to show.
// by default, display the the smallest number of decimal places such that changes of size step are visible.
// precision is the number of decimal places to show.
let
precision
=
Math
.
max
(
-
Math
.
floor
(
Math
.
log10
(
step
)),
0
)
// by default, display the the smallest number of decimal places such that changes of size step are visible.
// by default, round the value to those decimal places shown.
let
precision
=
Math
.
max
(
-
Math
.
floor
(
Math
.
log10
(
step
)),
0
);
let
round
=
Math
.
round
(
1000000
*
Math
.
pow
(
0.1
,
precision
))
/
1000000
;
if
(
round
==
undefined
||
round
===
true
)
{
// by default, round the value to those decimal places shown.
round
=
Math
.
round
(
1000000
*
Math
.
pow
(
0.1
,
precision
))
/
1000000
;
}
return
{
val
:
defaultVal
,
config
:
{
min
,
max
,
step
:
10.0
*
step
,
round
,
precision
}
};
return
{
val
:
defaultVal
,
config
:
{
min
,
max
,
step
:
10.0
*
step
,
round
,
precision
}
};
}
}
...
@@ -271,7 +276,11 @@ export const ComfyWidgets = {
...
@@ -271,7 +276,11 @@ export const ComfyWidgets = {
const
{
val
,
config
}
=
getNumberDefaults
(
inputData
,
0.5
);
const
{
val
,
config
}
=
getNumberDefaults
(
inputData
,
0.5
);
return
{
widget
:
node
.
addWidget
(
widgetType
,
inputName
,
val
,
return
{
widget
:
node
.
addWidget
(
widgetType
,
inputName
,
val
,
function
(
v
)
{
function
(
v
)
{
if
(
config
.
round
)
{
this
.
value
=
Math
.
round
(
v
/
config
.
round
)
*
config
.
round
;
this
.
value
=
Math
.
round
(
v
/
config
.
round
)
*
config
.
round
;
}
else
{
this
.
value
=
v
;
}
},
config
)
};
},
config
)
};
},
},
INT
(
node
,
inputName
,
inputData
,
app
)
{
INT
(
node
,
inputName
,
inputData
,
app
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment