Skip to content

Commit

Permalink
Use std::clamp in Clamp01
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 518696741
  • Loading branch information
sfreilich authored and Copybara-Service committed Mar 22, 2023
1 parent ab17d17 commit f86c1f4
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions ink_stroke_modeler/internal/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#ifndef INK_STROKE_MODELER_INTERNAL_UTILS_H_
#define INK_STROKE_MODELER_INTERNAL_UTILS_H_

#include <cmath>
#include <algorithm>

#include "ink_stroke_modeler/types.h"

Expand All @@ -27,11 +27,7 @@ namespace stroke_model {
// General utility functions for use within the stroke model.

// Clamps the given value to the range [0, 1].
inline float Clamp01(float value) {
if (value < 0.f) return 0.f;
if (value > 1.f) return 1.f;
return value;
}
inline float Clamp01(float value) { return std::clamp(value, 0.f, 1.f); }

// Returns the ratio of the difference from `start` to `value` and the
// difference from `start` to `end`, clamped to the range [0, 1]. If
Expand Down

0 comments on commit f86c1f4

Please sign in to comment.