@thi.ng/imgui
Version:
Immediate mode GUI with flexible state handling & data only shape output
19 lines (18 loc) • 518 B
JavaScript
import { TAU } from "@thi.ng/math/api";
import { fit } from "@thi.ng/math/fit";
import { heading } from "@thi.ng/vectors/heading";
import { sub2 } from "@thi.ng/vectors/sub";
import { slider1Val } from "./slider.js";
const dialVal = (p, origin, startTheta, thetaGap, min, max, prec) => {
let theta = heading(sub2([], p, origin)) - startTheta;
theta < -0.5 && (theta += TAU);
return slider1Val(
fit(Math.min(theta / (TAU - thetaGap)), 0, 1, min, max),
min,
max,
prec
);
};
export {
dialVal
};