diff options
| author | levlam <levlam@telegram.org> | 2023-09-20 17:22:01 +0300 |
|---|---|---|
| committer | levlam <levlam@telegram.org> | 2023-09-20 17:22:01 +0300 |
| commit | a7e9980246d74fdae1a89086bcdb8fb79b3ac740 (patch) | |
| tree | a6af13b6395b2defa623891be8df781e33418075 /td/telegram/MediaAreaCoordinates.cpp | |
| parent | b72fa2998138f40899dda0073fd2e42e76e38c9b (diff) | |
Allow negative rotation angle.
Diffstat (limited to 'td/telegram/MediaAreaCoordinates.cpp')
| -rw-r--r-- | td/telegram/MediaAreaCoordinates.cpp | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/td/telegram/MediaAreaCoordinates.cpp b/td/telegram/MediaAreaCoordinates.cpp index bb20c2d15..f2e52d785 100644 --- a/td/telegram/MediaAreaCoordinates.cpp +++ b/td/telegram/MediaAreaCoordinates.cpp @@ -6,18 +6,17 @@ // #include "td/telegram/MediaAreaCoordinates.h" +#include "td/utils/misc.h" + #include <cmath> namespace td { -static double fix_double(double &value, double max_value = 100.0) { - if (!std::isfinite(value) || value < 0.0) { +static double fix_double(double &value, double min_value = 0.0, double max_value = 100.0) { + if (!std::isfinite(value)) { return 0.0; } - if (value > max_value) { - return max_value; - } - return value; + return clamp(value, min_value, max_value); } void MediaAreaCoordinates::init(double x, double y, double width, double height, double rotation_angle) { @@ -25,7 +24,10 @@ void MediaAreaCoordinates::init(double x, double y, double width, double height, y_ = fix_double(y); width_ = fix_double(width); height_ = fix_double(height); - rotation_angle_ = fix_double(rotation_angle, 360.0); + rotation_angle_ = fix_double(rotation_angle, -360.0, 360.0); + if (rotation_angle_ < 0) { + rotation_angle_ += 360.0; + } } MediaAreaCoordinates::MediaAreaCoordinates( |
