Revert "Modify color"
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Color.cs
1 /*
2  * Copyright(c) 2019 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 using System;
19 using Tizen.NUI.Binding;
20 using System.ComponentModel;
21
22 namespace Tizen.NUI
23 {
24
25     /// <summary>
26     /// The Color class.
27     /// </summary>
28     [Tizen.NUI.Binding.TypeConverter(typeof(ColorTypeConverter))]
29     public class Color : Disposable, ICloneable
30     {
31         /// <summary>
32         /// Gets the black colored Color class.
33         /// </summary>
34         /// <since_tizen> 3 </since_tizen>
35         public static readonly Color Black = new Color(0.0f, 0.0f, 0.0f, 1.0f);
36
37         /// <summary>
38         /// Gets the white colored Color class.
39         /// </summary>
40         /// <since_tizen> 3 </since_tizen>
41         public static readonly Color White = new Color(1.0f, 1.0f, 1.0f, 1.0f);
42
43         /// <summary>
44         /// Gets the red colored Color class.
45         /// </summary>
46         /// <since_tizen> 3 </since_tizen>
47         public static readonly Color Red = new Color(1.0f, 0.0f, 0.0f, 1.0f);
48
49         /// <summary>
50         /// Gets the green colored Color class.
51         /// </summary>
52         /// <since_tizen> 3 </since_tizen>
53         public static readonly Color Green = new Color(0.0f, 1.0f, 0.0f, 1.0f);
54
55         /// <summary>
56         /// Gets the blue colored Color class.
57         /// </summary>
58         /// <since_tizen> 3 </since_tizen>
59         public static readonly Color Blue = new Color(0.0f, 0.0f, 1.0f, 1.0f);
60
61         /// <summary>
62         /// Gets the yellow colored Color class.
63         /// </summary>
64         /// <since_tizen> 3 </since_tizen>
65         public static readonly Color Yellow = new Color(1.0f, 1.0f, 0.0f, 1.0f);
66
67         /// <summary>
68         /// Gets the magenta colored Color class.
69         /// </summary>
70         /// <since_tizen> 3 </since_tizen>
71         public static readonly Color Magenta = new Color(1.0f, 0.0f, 1.0f, 1.0f);
72
73         /// <summary>
74         /// Gets the cyan colored Color class.
75         /// </summary>
76         /// <since_tizen> 3 </since_tizen>
77         public static readonly Color Cyan = new Color(0.0f, 1.0f, 1.0f, 1.0f);
78
79         /// <summary>
80         /// Gets the  transparent colored Color class.
81         /// </summary>
82         /// <since_tizen> 3 </since_tizen>
83         public static readonly Color Transparent = new Color(0.0f, 0.0f, 0.0f, 0.0f);
84
85         private readonly bool hashDummy;
86
87         /// <summary>
88         /// Default constructor
89         /// </summary>
90         /// <since_tizen> 3 </since_tizen>
91         public Color() : this(Interop.Vector4.new_Vector4__SWIG_0(), true)
92         {
93             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
94         }
95
96
97         /// <summary>
98         /// The constructor.
99         /// </summary>
100         /// <param name="r">The red component.</param>
101         /// <param name="g">The green component.</param>
102         /// <param name="b">The blue component.</param>
103         /// <param name="a">The alpha component.</param>
104         /// <since_tizen> 3 </since_tizen>
105         public Color(float r, float g, float b, float a) : this(Interop.Vector4.new_Vector4__SWIG_1(ValueCheck(r), ValueCheck(g), ValueCheck(b), ValueCheck(a)), true)
106         {
107             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
108         }
109
110         /// <summary>
111         /// The conversion constructor from an array of four floats.
112         /// </summary>
113         /// <param name="array">array Array of R,G,B,A.</param>
114         /// <since_tizen> 3 </since_tizen>
115         public Color(float[] array) : this(Interop.Vector4.new_Vector4__SWIG_2(ValueCheck(array)), true)
116         {
117             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
118         }
119
120         /// <summary>
121         /// The conversion constructor from an hexcode of four floats.
122         /// </summary>
123         /// <param name="hexColor">Hex color code</param>
124         /// <exception cref="ArgumentNullException">This exception is thrown when hexColor is null.</exception>
125         /// <since_tizen> 6 </since_tizen>
126         /// This will be public opened in tizen_6.0 after ACR done. Before ACR, need to be hidden as inhouse API.
127         [EditorBrowsable(EditorBrowsableState.Never)]
128         public Color(string hexColor) : this(Interop.Vector4.new_Vector4__SWIG_0(), true)
129         {
130             try
131             {
132                 if (null == hexColor)
133                 {
134                     throw new ArgumentNullException(nameof(hexColor));
135                 }
136                 hexColor = hexColor.Replace("#", "");
137
138                 R = ((float)Convert.ToInt32(hexColor.Substring(0, 2), 16)) / 255.0f;
139                 G = ((float)Convert.ToInt32(hexColor.Substring(2, 2), 16)) / 255.0f;
140                 B = ((float)Convert.ToInt32(hexColor.Substring(4, 2), 16)) / 255.0f;
141                 A = hexColor.Length > 6 ? ((float)Convert.ToInt32(hexColor.Substring(6, 2), 16)) / 255.0f : 1.0f;
142             }
143             catch
144             {
145                 throw new global::System.ArgumentException("Please check your hex code");
146             }
147         }
148
149         /// <summary>
150         /// The conversion constructor from an System.Drawing.Color instance.
151         /// </summary>
152         /// <param name="color">System.Drawing.Color instance</param>
153         [EditorBrowsable(EditorBrowsableState.Never)]
154         public Color(global::System.Drawing.Color color) : this(Interop.Vector4.new_Vector4__SWIG_0(), true)
155         {
156             R = color.R / 255.0f;
157             G = color.G / 255.0f;
158             B = color.B / 255.0f;
159             A = color.A / 255.0f;
160         }
161
162         /// <summary>
163         /// The copy constructor.
164         /// </summary>
165         /// <param name="other">The copy target.</param>
166         [EditorBrowsable(EditorBrowsableState.Never)]
167         public Color(Color other) : this((float)other?.R, (float)other.G, (float)other.B, (float)other.A)
168         {
169         }
170
171         internal Color(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
172         {
173             hashDummy = false;
174         }
175
176         internal Color(ColorChangedCallback cb, float r, float g, float b, float a) : this(Interop.Vector4.new_Vector4__SWIG_1(ValueCheck(r), ValueCheck(g), ValueCheck(b), ValueCheck(a)), true)
177         {
178             callback = cb;
179             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
180         }
181
182         internal Color(ColorChangedCallback cb, Color other) : this(cb, other.R, other.G, other.B, other.A)
183         {
184         }
185
186         internal delegate void ColorChangedCallback(float r, float g, float b, float a);
187         private ColorChangedCallback callback = null;
188
189         /// <summary>
190         /// The red component.
191         /// </summary>
192         /// <since_tizen> 3 </since_tizen>
193         [Obsolete("Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Color(...) constructor")]
194         public float R
195         {
196             set
197             {
198                 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Color(...) constructor");
199                 Interop.Vector4.Vector4_r_set(swigCPtr, ValueCheck(value));
200                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
201
202                 callback?.Invoke(R, G, B, A);
203             }
204             get
205             {
206                 float ret = Interop.Vector4.Vector4_r_get(swigCPtr);
207                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
208                 return ret;
209             }
210         }
211
212         /// <summary>
213         /// The green component.
214         /// </summary>
215         /// <since_tizen> 3 </since_tizen>
216         [Obsolete("Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Color(...) constructor")]
217         public float G
218         {
219             set
220             {
221                 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Color(...) constructor");
222                 Interop.Vector4.Vector4_g_set(swigCPtr, ValueCheck(value));
223                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
224
225                 callback?.Invoke(R, G, B, A);
226             }
227             get
228             {
229                 float ret = Interop.Vector4.Vector4_g_get(swigCPtr);
230                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
231                 return ret;
232             }
233         }
234
235         /// <summary>
236         /// The blue component.
237         /// </summary>
238         /// <since_tizen> 3 </since_tizen>
239         [Obsolete("Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Color(...) constructor")]
240         public float B
241         {
242             set
243             {
244                 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Color(...) constructor");
245                 Interop.Vector4.Vector4_b_set(swigCPtr, ValueCheck(value));
246                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
247
248                 callback?.Invoke(R, G, B, A);
249             }
250             get
251             {
252                 float ret = Interop.Vector4.Vector4_b_get(swigCPtr);
253                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
254                 return ret;
255             }
256         }
257
258         /// <summary>
259         /// The alpha component.
260         /// </summary>
261         /// <since_tizen> 3 </since_tizen>
262         [Obsolete("Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Color(...) constructor")]
263         public float A
264         {
265             set
266             {
267                 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Color(...) constructor");
268                 Interop.Vector4.Vector4_a_set(swigCPtr, ValueCheck(value));
269                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
270
271                 callback?.Invoke(R, G, B, A);
272             }
273             get
274             {
275                 float ret = Interop.Vector4.Vector4_a_get(swigCPtr);
276                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
277                 return ret;
278             }
279         }
280
281         /// <summary>
282         /// The array subscript operator overload.
283         /// </summary>
284         /// <param name="index">The subscript index.</param>
285         /// <returns>The float at the given index.</returns>
286         /// <since_tizen> 3 </since_tizen>
287         public float this[uint index]
288         {
289             get
290             {
291                 return ValueOfIndex(index);
292             }
293         }
294
295         /// <summary>
296         /// Converts the Color class to Vector4 class implicitly.
297         /// </summary>
298         /// <param name="color">A color to be converted to Vector4</param>
299         /// <since_tizen> 3 </since_tizen>
300         public static implicit operator Vector4(Color color)
301         {
302             return new Vector4((float)color?.R, (float)color.G, (float)color.B, (float)color.A);
303         }
304
305         /// <summary>
306         /// Converts Vector4 class to Color class implicitly.
307         /// </summary>
308         /// <param name="vec">A Vector4 to be converted to color.</param>
309         /// <since_tizen> 3 </since_tizen>
310         public static implicit operator Color(Vector4 vec)
311         {
312             return new Color((float)vec?.R, (float)vec.G, (float)vec.B, (float)vec.A);
313         }
314
315         /// <summary>
316         /// The addition operator.
317         /// </summary>
318         /// <param name="arg1">The first value.</param>
319         /// <param name="arg2">The second value.</param>
320         /// <returns>The color containing the result of the addition.</returns>
321         /// <exception cref="ArgumentNullException"> Thrown when arg1 is null. </exception>
322         /// <since_tizen> 3 </since_tizen>
323         public static Color operator +(Color arg1, Color arg2)
324         {
325             if (null == arg1)
326             {
327                 throw new ArgumentNullException(nameof(arg1));
328             }
329             Color result = arg1.Add(arg2);
330             return ValueCheck(result);
331         }
332
333         /// <summary>
334         /// The subtraction operator.
335         /// </summary>
336         /// <param name="arg1">The first value.</param>
337         /// <param name="arg2">The second value.</param>
338         /// <returns>The color containing the result of the subtraction.</returns>
339         /// <exception cref="ArgumentNullException"> Thrown when arg1 is null. </exception>
340         /// <since_tizen> 3 </since_tizen>
341         public static Color operator -(Color arg1, Color arg2)
342         {
343             if (null == arg1)
344             {
345                 throw new ArgumentNullException(nameof(arg1));
346             }
347             Color result = arg1.Subtract(arg2);
348             return ValueCheck(result);
349         }
350
351         /// <summary>
352         /// The unary negation operator.
353         /// </summary>
354         /// <param name="arg1">The target value.</param>
355         /// <returns>The color containg the negation.</returns>
356         /// <exception cref="ArgumentNullException"> Thrown when arg1 is null. </exception>
357         /// <since_tizen> 3 </since_tizen>
358         public static Color operator -(Color arg1)
359         {
360             if (null == arg1)
361             {
362                 throw new ArgumentNullException(nameof(arg1));
363             }
364             Color result = arg1.Subtract();
365             return ValueCheck(result);
366         }
367
368         /// <summary>
369         /// The multiplication operator.
370         /// </summary>
371         /// <param name="arg1">The first value.</param>
372         /// <param name="arg2">The second value.</param>
373         /// <returns>The color containing the result of the multiplication.</returns>
374         /// <exception cref="ArgumentNullException"> Thrown when arg1 is null. </exception>
375         /// <since_tizen> 3 </since_tizen>
376         public static Color operator *(Color arg1, Color arg2)
377         {
378             if (null == arg1)
379             {
380                 throw new ArgumentNullException(nameof(arg1));
381             }
382             Color result = arg1.Multiply(arg2);
383             return ValueCheck(result);
384         }
385
386         /// <summary>
387         /// The multiplication operator.
388         /// </summary>
389         /// <param name="arg1">The first value.</param>
390         /// <param name="arg2">The second value.</param>
391         /// <returns>The color containing the result of the multiplication.</returns>
392         /// <exception cref="ArgumentNullException"> Thrown when arg1 is null. </exception>
393         /// <since_tizen> 3 </since_tizen>
394         public static Color operator *(Color arg1, float arg2)
395         {
396             if (null == arg1)
397             {
398                 throw new ArgumentNullException(nameof(arg1));
399             }
400             Color result = arg1.Multiply(arg2);
401             return ValueCheck(result);
402         }
403
404         /// <summary>
405         /// The division operator.
406         /// </summary>
407         /// <param name="arg1">The first value.</param>
408         /// <param name="arg2">The second value.</param>
409         /// <returns>The color containing the result of the division.</returns>
410         /// <exception cref="ArgumentNullException"> Thrown when arg1 is null. </exception>
411         /// <since_tizen> 3 </since_tizen>
412         public static Color operator /(Color arg1, Color arg2)
413         {
414             if (null == arg1)
415             {
416                 throw new ArgumentNullException(nameof(arg1));
417             }
418             Color result = arg1.Divide(arg2);
419             return ValueCheck(result);
420         }
421
422         /// <summary>
423         /// The division operator.
424         /// </summary>
425         /// <param name="arg1">The first value.</param>
426         /// <param name="arg2">The second value.</param>
427         /// <returns>The color containing the result of the division.</returns>
428         /// <exception cref="ArgumentNullException"> Thrown when arg1 is null. </exception>
429         /// <since_tizen> 3 </since_tizen>
430         public static Color operator /(Color arg1, float arg2)
431         {
432             if (null == arg1)
433             {
434                 throw new ArgumentNullException(nameof(arg1));
435             }
436             Color result = arg1.Divide(arg2);
437             return ValueCheck(result);
438         }
439
440         /// <summary>
441         /// Checks if two color classes are same.
442         /// </summary>
443         /// <param name="rhs">A color to be compared.</param>
444         /// <returns>If two colors are are same, then true.</returns>
445         /// <since_tizen> 3 </since_tizen>
446         public bool EqualTo(Color rhs)
447         {
448             bool ret = Interop.Vector4.Vector4_EqualTo(swigCPtr, Color.getCPtr(rhs));
449
450             if (rhs == null) return false;
451
452             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
453             return ret;
454         }
455
456         /// <summary>
457         /// Checks if two color classes are different.
458         /// </summary>
459         /// <param name="rhs">A color to be compared.</param>
460         /// <returns>If two colors are are different, then true.</returns>
461         /// <since_tizen> 3 </since_tizen>
462         public bool NotEqualTo(Color rhs)
463         {
464             bool ret = Interop.Vector4.Vector4_NotEqualTo(swigCPtr, Color.getCPtr(rhs));
465             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
466             return ret;
467         }
468
469         /// <inheritdoc/>
470         [EditorBrowsable(EditorBrowsableState.Never)]
471         public object Clone() => new Color(this);
472
473         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Color obj)
474         {
475             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
476         }
477
478         internal static Color GetColorFromPtr(global::System.IntPtr cPtr)
479         {
480             Color ret = new Color(cPtr, false);
481             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
482             return ret;
483         }
484
485         internal static Color ValueCheck(Color color)
486         {
487             float r = color.R;
488             float g = color.G;
489             float b = color.B;
490             float a = color.A;
491
492             if (r < 0.0f)
493             {
494                 r = 0.0f;
495                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
496             }
497             else if (r > 1.0f)
498             {
499                 r = 1.0f;
500                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
501             }
502             if (g < 0.0f)
503             {
504                 g = 0.0f;
505                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
506             }
507             else if (g > 1.0f)
508             {
509                 g = 1.0f;
510                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
511             }
512             if (b < 0.0f)
513             {
514                 b = 0.0f;
515                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
516             }
517             else if (b > 1.0f)
518             {
519                 b = 1.0f;
520                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
521             }
522             if (a < 0.0f)
523             {
524                 a = 0.0f;
525                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
526             }
527             else if (a > 1.0f)
528             {
529                 a = 1.0f;
530                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
531             }
532             color = new Color(r, g, b, a);
533             return color;
534         }
535
536         internal static float ValueCheck(float value)
537         {
538             if (value < 0.0f)
539             {
540                 value = 0.0f;
541                 NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
542             }
543             else if (value > 1.0f)
544             {
545                 value = 1.0f;
546                 NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
547             }
548             return value;
549         }
550
551         internal static float[] ValueCheck(float[] arr)
552         {
553             if (null == arr)
554             {
555                 throw new ArgumentNullException(nameof(arr));
556             }
557
558             for (int i = 0; i < arr.Length; i++)
559             {
560                 if (arr[i] < 0.0f)
561                 {
562                     arr[i] = 0.0f;
563                     NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
564                 }
565                 else if (arr[i] > 1.0f)
566                 {
567                     arr[i] = 1.0f;
568                     NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
569                 }
570             }
571             return arr;
572         }
573
574         /// This will not be public opened.
575         [EditorBrowsable(EditorBrowsableState.Never)]
576         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
577         {
578             Interop.Vector4.delete_Vector4(swigCPtr);
579         }
580
581         private Color Add(Color rhs)
582         {
583             Color ret = new Color(Interop.Vector4.Vector4_Add(swigCPtr, Color.getCPtr(rhs)), true);
584             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
585             return ret;
586         }
587
588         private Color AddAssign(Vector4 rhs)
589         {
590             Color ret = new Color(Interop.Vector4.Vector4_AddAssign(swigCPtr, Color.getCPtr(rhs)), false);
591             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
592             return ret;
593         }
594
595         private Color Subtract(Color rhs)
596         {
597             Color ret = new Color(Interop.Vector4.Vector4_Subtract__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
598             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
599             return ret;
600         }
601
602         private Color SubtractAssign(Color rhs)
603         {
604             Color ret = new Color(Interop.Vector4.Vector4_SubtractAssign(swigCPtr, Color.getCPtr(rhs)), false);
605             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
606             return ret;
607         }
608
609         private Color Multiply(Color rhs)
610         {
611             Color ret = new Color(Interop.Vector4.Vector4_Multiply__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
612             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
613             return ret;
614         }
615
616         private Color Multiply(float rhs)
617         {
618             Color ret = new Color(Interop.Vector4.Vector4_Multiply__SWIG_1(swigCPtr, rhs), true);
619             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
620             return ret;
621         }
622
623         private Color MultiplyAssign(Color rhs)
624         {
625             Color ret = new Color(Interop.Vector4.Vector4_MultiplyAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
626             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
627             return ret;
628         }
629
630         private Color MultiplyAssign(float rhs)
631         {
632             Color ret = new Color(Interop.Vector4.Vector4_MultiplyAssign__SWIG_1(swigCPtr, rhs), false);
633             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
634             return ret;
635         }
636
637         private Color Divide(Vector4 rhs)
638         {
639             Color ret = new Color(Interop.Vector4.Vector4_Divide__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
640             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
641             return ret;
642         }
643
644         private Color Divide(float rhs)
645         {
646             Color ret = new Color(Interop.Vector4.Vector4_Divide__SWIG_1(swigCPtr, rhs), true);
647             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
648             return ret;
649         }
650
651         private Color DivideAssign(Color rhs)
652         {
653             Color ret = new Color(Interop.Vector4.Vector4_DivideAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
654             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
655             return ret;
656         }
657
658         private Color DivideAssign(float rhs)
659         {
660             Color ret = new Color(Interop.Vector4.Vector4_DivideAssign__SWIG_1(swigCPtr, rhs), false);
661             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
662             return ret;
663         }
664
665         private Color Subtract()
666         {
667             Color ret = new Color(Interop.Vector4.Vector4_Subtract__SWIG_1(swigCPtr), true);
668             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
669             return ret;
670         }
671
672         private static bool EqualsColorValue(float f1, float f2)
673         {
674             float EPS = (float)Math.Abs(f1 * .00001);
675             if (Math.Abs(f1 - f2) <= EPS)
676             {
677                 return true;
678             }
679             else
680             {
681                 return false;
682             }
683         }
684
685         private static bool EqualsColor(Color c1, Color c2)
686         {
687             return EqualsColorValue(c1.R, c2.R) && EqualsColorValue(c1.G, c2.G)
688                 && EqualsColorValue(c1.B, c2.B) && EqualsColorValue(c1.A, c2.A);
689         }
690
691         /// <summary>
692         /// Determines whether the specified object is equal to the current object.
693         /// </summary>
694         /// <param name="obj">The object to compare with the current object.</param>
695         /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
696         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
697         [EditorBrowsable(EditorBrowsableState.Never)]
698         public override bool Equals(System.Object obj)
699         {
700             Color color = obj as Color;
701             bool equal = false;
702             if (color == null)
703             {
704                 return equal;
705             }
706
707             if (EqualsColor(this, color))
708             {
709                 equal = true;
710             }
711             return equal;
712         }
713
714         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
715         [EditorBrowsable(EditorBrowsableState.Never)]
716         public override int GetHashCode()
717         {
718             return hashDummy.GetHashCode();
719         }
720
721         private float ValueOfIndex(uint index)
722         {
723             float ret = Interop.Vector4.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
724             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
725             return ret;
726         }
727
728     }
729
730 }
731
732