[Solved] What is the significance of Min and Max in below python function


Since the possible range of the values r, g, b is in 0 – 255, max(x, 0) is to prevent the value to drop below 0 and min(255, max(x, 0)) is to prevent the value to go above 255.

Example: if r = -20, max(r, 0) = max(-20, 0) = 0
and if r = 280, max(255, min(r, 0)) = max(255, min(280, 0)) = max(255, 0) = 255.

Graph for reference

solved What is the significance of Min and Max in below python function