Modify color
authorhuiyu.eun <huiyu.eun@samsung.com>
Wed, 25 Nov 2020 08:46:01 +0000 (17:46 +0900)
committerdongsug-song <35130733+dongsug-song@users.noreply.github.com>
Tue, 1 Dec 2020 08:56:39 +0000 (17:56 +0900)
Signed-off-by: huiyu.eun <huiyu.eun@samsung.com>
src/Tizen.NUI/src/public/Color.cs

index 15f3919..e932b98 100755 (executable)
@@ -484,68 +484,12 @@ namespace Tizen.NUI
 
         internal static Color ValueCheck(Color color)
         {
-            float r = color.R;
-            float g = color.G;
-            float b = color.B;
-            float a = color.A;
-
-            if (r < 0.0f)
-            {
-                r = 0.0f;
-                NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
-            }
-            else if (r > 1.0f)
-            {
-                r = 1.0f;
-                NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
-            }
-            if (g < 0.0f)
-            {
-                g = 0.0f;
-                NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
-            }
-            else if (g > 1.0f)
-            {
-                g = 1.0f;
-                NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
-            }
-            if (b < 0.0f)
-            {
-                b = 0.0f;
-                NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
-            }
-            else if (b > 1.0f)
-            {
-                b = 1.0f;
-                NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
-            }
-            if (a < 0.0f)
-            {
-                a = 0.0f;
-                NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
-            }
-            else if (a > 1.0f)
-            {
-                a = 1.0f;
-                NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
-            }
-            color = new Color(r, g, b, a);
-            return color;
+            return new Color(InvalidChecker(color.R), InvalidChecker(color.G), InvalidChecker(color.B), InvalidChecker(color.A));
         }
 
         internal static float ValueCheck(float value)
         {
-            if (value < 0.0f)
-            {
-                value = 0.0f;
-                NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
-            }
-            else if (value > 1.0f)
-            {
-                value = 1.0f;
-                NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
-            }
-            return value;
+            return InvalidChecker(value);
         }
 
         internal static float[] ValueCheck(float[] arr)
@@ -557,19 +501,25 @@ namespace Tizen.NUI
 
             for (int i = 0; i < arr.Length; i++)
             {
-                if (arr[i] < 0.0f)
-                {
-                    arr[i] = 0.0f;
-                    NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
-                }
-                else if (arr[i] > 1.0f)
-                {
-                    arr[i] = 1.0f;
-                    NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
-                }
+                arr[i] = InvalidChecker(arr[i]);
             }
             return arr;
         }
+        
+        private static float InvalidChecker(float value)
+        {
+            if (value < 0.0f)
+            {
+                value = 0.0f;
+                NUILog.Error($"The value of Result is invalid! Should be between [0, 1]. value is {value}");
+            }
+            else if(value > 1.0f)
+            {
+                value = 1.0f;
+                NUILog.Error($"The value of Result is invalid! Should be between [0, 1]. value is {value}");
+            }
+            return value;
+        }
 
         /// This will not be public opened.
         [EditorBrowsable(EditorBrowsableState.Never)]