JSFiddle - React, Tailwind, and code Playground
by magneto903
JavaScript
function map(x, in_min, in_max, out_min, out_max)
{
return Math.floor((x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min);
}
alert(map(512, 0, 1023, 0, 255))