Skip to content

Commit

Permalink
Update clamp function
Browse files Browse the repository at this point in the history
  • Loading branch information
yzrmn committed Sep 15, 2024
1 parent e740b6b commit e2868b5
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion packages/redgeometry/src/utility/scalar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export function betweenInt(a: number, b: number, t: number): number {
* Returns the value `x` clamped between `min` and `max`.
*/
export function clamp(x: number, min: number, max: number): number {
return x <= min ? min : x >= max ? max : x;
return Math.min(Math.max(x, min), max);
}

/**
Expand Down

0 comments on commit e2868b5

Please sign in to comment.