mirror of
https://git.minetest.land/MineClone2/MineClone2.git
synced 2024-11-28 05:43:43 +01:00
Correct value clamping
This commit is contained in:
parent
96a03b1923
commit
f6c3f4bd16
@ -190,8 +190,8 @@ end
|
|||||||
|
|
||||||
function skycolor_utils.convert_to_rgb(minval, maxval, current_val, colors)
|
function skycolor_utils.convert_to_rgb(minval, maxval, current_val, colors)
|
||||||
-- Clamp current_val to valid range
|
-- Clamp current_val to valid range
|
||||||
current_val = math.min(minval, current_val)
|
current_val = math.max(minval, current_val)
|
||||||
current_val = math.max(maxval, current_val)
|
current_val = math.min(maxval, current_val)
|
||||||
|
|
||||||
-- Rescale current_val from a number between minval and maxval to a number between 1 and #colors
|
-- Rescale current_val from a number between minval and maxval to a number between 1 and #colors
|
||||||
local scaled_value = (current_val - minval) / (maxval - minval) * (#colors - 1) + 1.0
|
local scaled_value = (current_val - minval) / (maxval - minval) * (#colors - 1) + 1.0
|
||||||
|
Loading…
Reference in New Issue
Block a user