3 ms·
It’s usually nicer to make a helper function: const clamp = (x, low, high) => Math.max(low, Math.min(x, high)); Then it can be easily used later via a d
by jacobolus 6y ago
It’s usually nicer to make a helper function:
const clamp = (x, low, high) =>
Math.max(low, Math.min(x, high));
Then it can be easily used later via a descriptive name. e.g.
color_component = clamp(color_component, 0, 255);
- deleted 6y ago[deleted]