Add manual precision override

This commit is contained in:
City 2023-09-17 16:12:50 +02:00
parent 80dfeb089b
commit 2e317657ca
2 changed files with 16 additions and 1 deletions

View File

@ -584,6 +584,18 @@ export class ComfyUI {
defaultValue: false,
});
this.settings.addSetting({
id: "Comfy.FloatRoundingPrecision",
name: "Decimal places [0 = auto] (requires page reload).",
type: "slider",
attrs: {
min: 0,
max: 6,
step: 1,
},
defaultValue: 0,
});
const fileInput = $el("input", {
id: "comfy-file-input",
type: "file",

View File

@ -12,7 +12,10 @@ function getNumberDefaults(inputData, defaultStep, app) {
// when using the old behavior, it defaults to 3 decimal places
let precision = 3;
let round = 0.001;
if (!app.ui.settings.getSettingValue("Comfy.DisableFloatRounding")) {
if (app.ui.settings.getSettingValue("Comfy.FloatRoundingPrecision") > 0) {
precision = app.ui.settings.getSettingValue("Comfy.FloatRoundingPrecision");
round = Math.round(1000000*Math.pow(0.1,precision))/1000000;
} else if (!app.ui.settings.getSettingValue("Comfy.DisableFloatRounding")) {
// display the the smallest number of decimal places such that changes of size step are visible.
precision = Math.max(-Math.floor(Math.log10(step)),0);
// round the value to those decimal places shown.