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
3ebe6b53
"include/ck/utility/statically_indexed_array.hpp" did not exist on "b491ebf38480bc0d6cb329ba6825dee610c59097"
Commit
3ebe6b53
authored
Sep 08, 2023
by
Chris
Browse files
round float widgets (by default to 0.001)
parent
326577d0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
3 deletions
+7
-3
web/scripts/widgets.js
web/scripts/widgets.js
+7
-3
No files found.
web/scripts/widgets.js
View file @
3ebe6b53
...
...
@@ -2,14 +2,15 @@ import { api } from "./api.js"
function
getNumberDefaults
(
inputData
,
defaultStep
)
{
let
defaultVal
=
inputData
[
1
][
"
default
"
];
let
{
min
,
max
,
step
}
=
inputData
[
1
];
let
{
min
,
max
,
step
,
round
}
=
inputData
[
1
];
if
(
defaultVal
==
undefined
)
defaultVal
=
0
;
if
(
min
==
undefined
)
min
=
0
;
if
(
max
==
undefined
)
max
=
2048
;
if
(
step
==
undefined
)
step
=
defaultStep
;
if
(
round
==
undefined
)
round
=
0.001
;
return
{
val
:
defaultVal
,
config
:
{
min
,
max
,
step
:
10.0
*
step
}
};
return
{
val
:
defaultVal
,
config
:
{
min
,
max
,
step
:
10.0
*
step
,
round
}
};
}
export
function
addValueControlWidget
(
node
,
targetWidget
,
defaultValue
=
"
randomize
"
,
values
)
{
...
...
@@ -264,7 +265,10 @@ export const ComfyWidgets = {
FLOAT
(
node
,
inputName
,
inputData
,
app
)
{
let
widgetType
=
isSlider
(
inputData
[
1
][
"
display
"
],
app
);
const
{
val
,
config
}
=
getNumberDefaults
(
inputData
,
0.5
);
return
{
widget
:
node
.
addWidget
(
widgetType
,
inputName
,
val
,
()
=>
{},
config
)
};
return
{
widget
:
node
.
addWidget
(
widgetType
,
inputName
,
val
,
function
(
v
)
{
this
.
value
=
Math
.
round
(
v
/
config
.
round
)
*
config
.
round
;
},
config
)
};
},
INT
(
node
,
inputName
,
inputData
,
app
)
{
let
widgetType
=
isSlider
(
inputData
[
1
][
"
display
"
],
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