fix in widgets

This commit is contained in:
tamat
2020-04-21 12:35:02 +02:00
parent e2fce11afc
commit 78e55db0b1
11 changed files with 1593 additions and 751 deletions

View File

@@ -110,6 +110,7 @@
function MathRange() {
this.addInput("in", "number", { locked: true });
this.addOutput("out", "number", { locked: true });
this.addOutput("clamped", "number", { locked: true });
this.addProperty("in", 0);
this.addProperty("in_min", 0);
@@ -117,7 +118,7 @@
this.addProperty("out_min", 0);
this.addProperty("out_max", 1);
this.size = [80, 30];
this.size = [120, 50];
}
MathRange.title = "Range";
@@ -151,10 +152,22 @@
var in_max = this.properties.in_max;
var out_min = this.properties.out_min;
var out_max = this.properties.out_max;
/*
if( in_min > in_max )
{
in_min = in_max;
in_max = this.properties.in_min;
}
if( out_min > out_max )
{
out_min = out_max;
out_max = this.properties.out_min;
}
*/
this._last_v =
((v - in_min) / (in_max - in_min)) * (out_max - out_min) + out_min;
this._last_v = ((v - in_min) / (in_max - in_min)) * (out_max - out_min) + out_min;
this.setOutputData(0, this._last_v);
this.setOutputData(1, Math.clamp( this._last_v, out_min, out_max ));
};
MathRange.prototype.onDrawBackground = function(ctx) {