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
7372255e
"...composable_kernel_onnx.git" did not exist on "54b3e73d17b8594cb779cea2f0a53d55e832044d"
Commit
7372255e
authored
Sep 09, 2023
by
Chris
Browse files
Specify the precision and rounding based on step
parent
3ebe6b53
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 @
7372255e
...
@@ -2,15 +2,19 @@ import { api } from "./api.js"
...
@@ -2,15 +2,19 @@ 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
,
round
}
=
inputData
[
1
];
let
{
min
,
max
,
step
,
round
,
precision
}
=
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
;
if
(
round
==
undefined
)
round
=
0.001
;
// 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.
if
(
precision
==
undefined
)
precision
=
Math
.
max
(
-
Math
.
floor
(
Math
.
log10
(
step
)),
0
)
// by default, round the value to those decimal places shown.
if
(
round
==
undefined
)
round
=
Math
.
round
(
1000000
*
Math
.
pow
(
0.1
,
precision
))
/
1000000
;
return
{
val
:
defaultVal
,
config
:
{
min
,
max
,
step
:
10.0
*
step
,
round
}
};
return
{
val
:
defaultVal
,
config
:
{
min
,
max
,
step
:
10.0
*
step
,
round
,
precision
}
};
}
}
export
function
addValueControlWidget
(
node
,
targetWidget
,
defaultValue
=
"
randomize
"
,
values
)
{
export
function
addValueControlWidget
(
node
,
targetWidget
,
defaultValue
=
"
randomize
"
,
values
)
{
...
...
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