From 590cca9776c0876a28fca6433cbebbd1d027e842 Mon Sep 17 00:00:00 2001 From: jules Date: Sat, 14 Jun 2014 11:32:02 +0100 Subject: [PATCH] Added an overload for calling roundToInt with an int. Added a a Point::roundToInt method. --- modules/juce_core/maths/juce_MathsFunctions.h | 5 +++++ modules/juce_graphics/geometry/juce_Point.h | 3 +++ 2 files changed, 8 insertions(+) diff --git a/modules/juce_core/maths/juce_MathsFunctions.h b/modules/juce_core/maths/juce_MathsFunctions.h index 3469c6c949..d62ed17949 100644 --- a/modules/juce_core/maths/juce_MathsFunctions.h +++ b/modules/juce_core/maths/juce_MathsFunctions.h @@ -364,6 +364,11 @@ inline int roundToInt (const FloatType value) noexcept #endif } +inline int roundToInt (int value) noexcept +{ + return value; +} + #if JUCE_MSVC #ifndef __INTEL_COMPILER #pragma float_control (pop) diff --git a/modules/juce_graphics/geometry/juce_Point.h b/modules/juce_graphics/geometry/juce_Point.h index ffe80fe2fc..7cc5d4990c 100644 --- a/modules/juce_graphics/geometry/juce_Point.h +++ b/modules/juce_graphics/geometry/juce_Point.h @@ -213,6 +213,9 @@ public: /** Casts this point to a Point object. */ Point toDouble() const noexcept { return Point (static_cast (x), static_cast (y)); } + /** Casts this point to a Point object using roundToInt() to convert the values. */ + Point roundToInt() const noexcept { return Point (juce::roundToInt (x), juce::roundToInt (y)); } + /** Returns the point as a string in the form "x, y". */ String toString() const { return String (x) + ", " + String (y); }