[NUI] Re-structuring NUI by classifying modules
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Common / 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.NewVector4(), 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.NewVector4(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.NewVector4(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.NewVector4(), 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.NewVector4(), 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.NewVector4(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         /// <remarks>
193         /// The setter is deprecated in API8 and will be removed in API10. Please use new Color(...) constructor.
194         /// </remarks>
195         /// <code>
196         /// // DO NOT use like the followings!
197         /// Color color = new Color();
198         /// color.R = 0.1f; 
199         /// // Please USE like this
200         /// float r = 0.1f, g = 0.5f, b = 0.9f, a = 1.0f;
201         /// Color color = new Color(r, g, b, a);
202         /// </code>
203         /// <since_tizen> 3 </since_tizen>
204         public float R
205         {
206             set
207             {
208                 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Color(...) constructor");
209                 Interop.Vector4.RSet(SwigCPtr, ValueCheck(value));
210                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
211
212                 callback?.Invoke(R, G, B, A);
213             }
214             get
215             {
216                 float ret = Interop.Vector4.RGet(SwigCPtr);
217                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
218                 return ret;
219             }
220         }
221
222         /// <summary>
223         /// The green component.
224         /// </summary>
225         /// <remarks>
226         /// The setter is deprecated in API8 and will be removed in API10. Please use new Color(...) constructor.
227         /// </remarks>
228         /// <code>
229         /// // DO NOT use like the followings!
230         /// Color color = new Color();
231         /// color.G = 0.5f; 
232         /// // Please USE like this
233         /// float r = 0.1f, g = 0.5f, b = 0.9f, a = 1.0f;
234         /// Color color = new Color(r, g, b, a);
235         /// </code>
236         /// <since_tizen> 3 </since_tizen>
237         public float G
238         {
239             set
240             {
241                 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Color(...) constructor");
242                 Interop.Vector4.GSet(SwigCPtr, ValueCheck(value));
243                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
244
245                 callback?.Invoke(R, G, B, A);
246             }
247             get
248             {
249                 float ret = Interop.Vector4.GGet(SwigCPtr);
250                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
251                 return ret;
252             }
253         }
254
255         /// <summary>
256         /// The blue component.
257         /// </summary>
258         /// <remarks>
259         /// The setter is deprecated in API8 and will be removed in API10. Please use new Color(...) constructor.
260         /// </remarks>
261         /// <code>
262         /// // DO NOT use like the followings!
263         /// Color color = new Color();
264         /// color.B = 0.9f; 
265         /// // Please USE like this
266         /// float r = 0.1f, g = 0.5f, b = 0.9f, a = 1.0f;
267         /// Color color = new Color(r, g, b, a);
268         /// </code>
269         /// <since_tizen> 3 </since_tizen>
270         public float B
271         {
272             set
273             {
274                 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Color(...) constructor");
275                 Interop.Vector4.BSet(SwigCPtr, ValueCheck(value));
276                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
277
278                 callback?.Invoke(R, G, B, A);
279             }
280             get
281             {
282                 float ret = Interop.Vector4.BGet(SwigCPtr);
283                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
284                 return ret;
285             }
286         }
287
288         /// <summary>
289         /// The alpha component.
290         /// </summary>
291         /// <remarks>
292         /// The setter is deprecated in API8 and will be removed in API10. Please use new Color(...) constructor.
293         /// </remarks>
294         /// <code>
295         /// // DO NOT use like the followings!
296         /// Color color = new Color();
297         /// color.A = 1.0f; 
298         /// // Please USE like this
299         /// float r = 0.1f, g = 0.5f, b = 0.9f, a = 1.0f;
300         /// Color color = new Color(r, g, b, a);
301         /// </code>
302         /// <since_tizen> 3 </since_tizen>
303         public float A
304         {
305             set
306             {
307                 Tizen.Log.Fatal("NUI", "Please do not use this setter, Deprecated in API8, will be removed in API10. please use new Color(...) constructor");
308                 Interop.Vector4.ASet(SwigCPtr, ValueCheck(value));
309                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
310
311                 callback?.Invoke(R, G, B, A);
312             }
313             get
314             {
315                 float ret = Interop.Vector4.AGet(SwigCPtr);
316                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw new InvalidOperationException("FATAL: get Exception", NDalicPINVOKE.SWIGPendingException.Retrieve());
317                 return ret;
318             }
319         }
320
321         /// <summary>
322         /// The array subscript operator overload.
323         /// </summary>
324         /// <param name="index">The subscript index.</param>
325         /// <returns>The float at the given index.</returns>
326         /// <since_tizen> 3 </since_tizen>
327         public float this[uint index]
328         {
329             get
330             {
331                 return ValueOfIndex(index);
332             }
333         }
334
335         /// <summary>
336         /// Converts the Color class to Vector4 class implicitly.
337         /// </summary>
338         /// <param name="color">A color to be converted to Vector4</param>
339         /// <since_tizen> 3 </since_tizen>
340         public static implicit operator Vector4(Color color)
341         {
342             return new Vector4((float)color?.R, (float)color.G, (float)color.B, (float)color.A);
343         }
344
345         /// <summary>
346         /// Converts Vector4 class to Color class implicitly.
347         /// </summary>
348         /// <param name="vec">A Vector4 to be converted to color.</param>
349         /// <since_tizen> 3 </since_tizen>
350         public static implicit operator Color(Vector4 vec)
351         {
352             return new Color((float)vec?.R, (float)vec.G, (float)vec.B, (float)vec.A);
353         }
354
355         /// <summary>
356         /// The addition operator.
357         /// </summary>
358         /// <param name="arg1">The first value.</param>
359         /// <param name="arg2">The second value.</param>
360         /// <returns>The color containing the result of the addition.</returns>
361         /// <exception cref="ArgumentNullException"> Thrown when arg1 is null. </exception>
362         /// <since_tizen> 3 </since_tizen>
363         public static Color operator +(Color arg1, Color arg2)
364         {
365             if (null == arg1)
366             {
367                 throw new ArgumentNullException(nameof(arg1));
368             }
369             Color result = arg1.Add(arg2);
370             return ValueCheck(result);
371         }
372
373         /// <summary>
374         /// The subtraction operator.
375         /// </summary>
376         /// <param name="arg1">The first value.</param>
377         /// <param name="arg2">The second value.</param>
378         /// <returns>The color containing the result of the subtraction.</returns>
379         /// <exception cref="ArgumentNullException"> Thrown when arg1 is null. </exception>
380         /// <since_tizen> 3 </since_tizen>
381         public static Color operator -(Color arg1, Color arg2)
382         {
383             if (null == arg1)
384             {
385                 throw new ArgumentNullException(nameof(arg1));
386             }
387             Color result = arg1.Subtract(arg2);
388             return ValueCheck(result);
389         }
390
391         /// <summary>
392         /// The unary negation operator.
393         /// </summary>
394         /// <param name="arg1">The target value.</param>
395         /// <returns>The color containg the negation.</returns>
396         /// <exception cref="ArgumentNullException"> Thrown when arg1 is null. </exception>
397         /// <since_tizen> 3 </since_tizen>
398         public static Color operator -(Color arg1)
399         {
400             if (null == arg1)
401             {
402                 throw new ArgumentNullException(nameof(arg1));
403             }
404             Color result = arg1.Subtract();
405             return ValueCheck(result);
406         }
407
408         /// <summary>
409         /// The multiplication operator.
410         /// </summary>
411         /// <param name="arg1">The first value.</param>
412         /// <param name="arg2">The second value.</param>
413         /// <returns>The color containing the result of the multiplication.</returns>
414         /// <exception cref="ArgumentNullException"> Thrown when arg1 is null. </exception>
415         /// <since_tizen> 3 </since_tizen>
416         public static Color operator *(Color arg1, Color arg2)
417         {
418             if (null == arg1)
419             {
420                 throw new ArgumentNullException(nameof(arg1));
421             }
422             Color result = arg1.Multiply(arg2);
423             return ValueCheck(result);
424         }
425
426         /// <summary>
427         /// The multiplication operator.
428         /// </summary>
429         /// <param name="arg1">The first value.</param>
430         /// <param name="arg2">The second value.</param>
431         /// <returns>The color containing the result of the multiplication.</returns>
432         /// <exception cref="ArgumentNullException"> Thrown when arg1 is null. </exception>
433         /// <since_tizen> 3 </since_tizen>
434         public static Color operator *(Color arg1, float arg2)
435         {
436             if (null == arg1)
437             {
438                 throw new ArgumentNullException(nameof(arg1));
439             }
440             Color result = arg1.Multiply(arg2);
441             return ValueCheck(result);
442         }
443
444         /// <summary>
445         /// The division operator.
446         /// </summary>
447         /// <param name="arg1">The first value.</param>
448         /// <param name="arg2">The second value.</param>
449         /// <returns>The color containing the result of the division.</returns>
450         /// <exception cref="ArgumentNullException"> Thrown when arg1 is null. </exception>
451         /// <since_tizen> 3 </since_tizen>
452         public static Color operator /(Color arg1, Color arg2)
453         {
454             if (null == arg1)
455             {
456                 throw new ArgumentNullException(nameof(arg1));
457             }
458             Color result = arg1.Divide(arg2);
459             return ValueCheck(result);
460         }
461
462         /// <summary>
463         /// The division operator.
464         /// </summary>
465         /// <param name="arg1">The first value.</param>
466         /// <param name="arg2">The second value.</param>
467         /// <returns>The color containing the result of the division.</returns>
468         /// <exception cref="ArgumentNullException"> Thrown when arg1 is null. </exception>
469         /// <since_tizen> 3 </since_tizen>
470         public static Color operator /(Color arg1, float arg2)
471         {
472             if (null == arg1)
473             {
474                 throw new ArgumentNullException(nameof(arg1));
475             }
476             Color result = arg1.Divide(arg2);
477             return ValueCheck(result);
478         }
479
480         /// <summary>
481         /// Checks if two color classes are same.
482         /// </summary>
483         /// <param name="rhs">A color to be compared.</param>
484         /// <returns>If two colors are are same, then true.</returns>
485         /// <since_tizen> 3 </since_tizen>
486         public bool EqualTo(Color rhs)
487         {
488             bool ret = Interop.Vector4.EqualTo(SwigCPtr, Color.getCPtr(rhs));
489
490             if (rhs == null) return false;
491
492             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
493             return ret;
494         }
495
496         /// <summary>
497         /// Checks if two color classes are different.
498         /// </summary>
499         /// <param name="rhs">A color to be compared.</param>
500         /// <returns>If two colors are are different, then true.</returns>
501         /// <since_tizen> 3 </since_tizen>
502         public bool NotEqualTo(Color rhs)
503         {
504             bool ret = Interop.Vector4.NotEqualTo(SwigCPtr, Color.getCPtr(rhs));
505             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
506             return ret;
507         }
508
509         /// <inheritdoc/>
510         [EditorBrowsable(EditorBrowsableState.Never)]
511         public object Clone() => new Color(this);
512
513         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Color obj)
514         {
515             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
516         }
517
518         internal static Color GetColorFromPtr(global::System.IntPtr cPtr)
519         {
520             Color ret = new Color(cPtr, false);
521             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
522             return ret;
523         }
524
525         internal static Color ValueCheck(Color color)
526         {
527             float r = color.R;
528             float g = color.G;
529             float b = color.B;
530             float a = color.A;
531
532             if (IsInvalidValue(ref r) | IsInvalidValue(ref g) | IsInvalidValue(ref b) | IsInvalidValue(ref a))
533             {
534                 NUILog.Error($"The value of Result is invalid! Should be between [0, 1]. Color is {color.R}, {color.G}, {color.B}, {color.A}");
535             }
536             color = new Color(r, g, b, a);
537             return color;
538         }
539
540         internal static float ValueCheck(float value)
541         {
542             float refValue = value;
543             if (IsInvalidValue(ref refValue))
544             {
545                 NUILog.Error($"The value of Result is invalid! Should be between [0, 1]. float value is {value}");
546             }
547             return refValue;
548         }
549
550         internal static float[] ValueCheck(float[] arr)
551         {
552             if (null == arr)
553             {
554                 throw new ArgumentNullException(nameof(arr));
555             }
556
557             for (int i = 0; i < arr.Length; i++)
558             {
559                 float refValue = arr[i];
560                 if (IsInvalidValue(ref refValue))
561                 {
562                     NUILog.Error($"The value of Result is invalid! Should be between [0, 1]. arr[] is {arr[i]}");
563                     arr[i] = refValue;
564                 }
565             }
566             return arr;
567         }
568
569         private static bool IsInvalidValue(ref float value)
570         {
571             if (value < 0.0f)
572             {
573                 value = 0.0f;
574                 return true;
575             }
576             else if (value > 1.0f)
577             {
578                 value = 1.0f;
579                 return true;
580             }
581             return false;
582         }
583
584         /// This will not be public opened.
585         [EditorBrowsable(EditorBrowsableState.Never)]
586         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
587         {
588             Interop.Vector4.DeleteVector4(swigCPtr);
589         }
590
591         private Color Add(Color rhs)
592         {
593             Color ret = new Color(Interop.Vector4.Add(SwigCPtr, Color.getCPtr(rhs)), true);
594             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
595             return ret;
596         }
597
598         private Color AddAssign(Vector4 rhs)
599         {
600             Color ret = new Color(Interop.Vector4.AddAssign(SwigCPtr, Color.getCPtr(rhs)), false);
601             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
602             return ret;
603         }
604
605         private Color Subtract(Color rhs)
606         {
607             Color ret = new Color(Interop.Vector4.Subtract(SwigCPtr, Color.getCPtr(rhs)), true);
608             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
609             return ret;
610         }
611
612         private Color SubtractAssign(Color rhs)
613         {
614             Color ret = new Color(Interop.Vector4.SubtractAssign(SwigCPtr, Color.getCPtr(rhs)), false);
615             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
616             return ret;
617         }
618
619         private Color Multiply(Color rhs)
620         {
621             Color ret = new Color(Interop.Vector4.Multiply(SwigCPtr, Color.getCPtr(rhs)), true);
622             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
623             return ret;
624         }
625
626         private Color Multiply(float rhs)
627         {
628             Color ret = new Color(Interop.Vector4.Multiply(SwigCPtr, rhs), true);
629             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
630             return ret;
631         }
632
633         private Color MultiplyAssign(Color rhs)
634         {
635             Color ret = new Color(Interop.Vector4.MultiplyAssign(SwigCPtr, Color.getCPtr(rhs)), false);
636             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
637             return ret;
638         }
639
640         private Color MultiplyAssign(float rhs)
641         {
642             Color ret = new Color(Interop.Vector4.MultiplyAssign(SwigCPtr, rhs), false);
643             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
644             return ret;
645         }
646
647         private Color Divide(Vector4 rhs)
648         {
649             Color ret = new Color(Interop.Vector4.Divide(SwigCPtr, Color.getCPtr(rhs)), true);
650             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
651             return ret;
652         }
653
654         private Color Divide(float rhs)
655         {
656             Color ret = new Color(Interop.Vector4.Divide(SwigCPtr, rhs), true);
657             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
658             return ret;
659         }
660
661         private Color DivideAssign(Color rhs)
662         {
663             Color ret = new Color(Interop.Vector4.DivideAssign(SwigCPtr, Color.getCPtr(rhs)), false);
664             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
665             return ret;
666         }
667
668         private Color DivideAssign(float rhs)
669         {
670             Color ret = new Color(Interop.Vector4.DivideAssign(SwigCPtr, rhs), false);
671             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
672             return ret;
673         }
674
675         private Color Subtract()
676         {
677             Color ret = new Color(Interop.Vector4.Subtract(SwigCPtr), true);
678             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
679             return ret;
680         }
681
682         private static bool EqualsColorValue(float f1, float f2)
683         {
684             float EPS = (float)Math.Abs(f1 * .00001);
685             if (Math.Abs(f1 - f2) <= EPS)
686             {
687                 return true;
688             }
689             else
690             {
691                 return false;
692             }
693         }
694
695         private static bool EqualsColor(Color c1, Color c2)
696         {
697             return EqualsColorValue(c1.R, c2.R) && EqualsColorValue(c1.G, c2.G)
698                 && EqualsColorValue(c1.B, c2.B) && EqualsColorValue(c1.A, c2.A);
699         }
700
701         /// <summary>
702         /// Determines whether the specified object is equal to the current object.
703         /// </summary>
704         /// <param name="obj">The object to compare with the current object.</param>
705         /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
706         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
707         [EditorBrowsable(EditorBrowsableState.Never)]
708         public override bool Equals(System.Object obj)
709         {
710             Color color = obj as Color;
711             bool equal = false;
712             if (color == null)
713             {
714                 return equal;
715             }
716
717             if (EqualsColor(this, color))
718             {
719                 equal = true;
720             }
721             return equal;
722         }
723
724         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
725         [EditorBrowsable(EditorBrowsableState.Never)]
726         public override int GetHashCode()
727         {
728             return hashDummy.GetHashCode();
729         }
730
731         private float ValueOfIndex(uint index)
732         {
733             float ret = Interop.Vector4.ValueOfIndex(SwigCPtr, index);
734             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
735             return ret;
736         }
737
738     }
739
740 }
741
742