Remap or Map function in Javascript

后端 未结 5 1980
小鲜肉
小鲜肉 2020-12-08 11:26

Of late, most of my programming experience has been in Processing, and more recently I have been wanting to branch out a little deeper in to some JavaScript, since they are

5条回答
  •  萌比男神i
    2020-12-08 11:37

    The function below produces the same behaviour as the original Processing function:

    function map_range(value, low1, high1, low2, high2) {
        return low2 + (high2 - low2) * (value - low1) / (high1 - low1);
    }
    

提交回复
热议问题