84e110de88b8c41d5db0f61cf8dbe355074acd77
[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             if (color.R < 0.0f)
488             {
489                 color.R = 0.0f;
490                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
491             }
492             else if (color.R > 1.0f)
493             {
494                 color.R = 1.0f;
495                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
496             }
497             if (color.G < 0.0f)
498             {
499                 color.G = 0.0f;
500                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
501             }
502             else if (color.G > 1.0f)
503             {
504                 color.G = 1.0f;
505                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
506             }
507             if (color.B < 0.0f)
508             {
509                 color.B = 0.0f;
510                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
511             }
512             else if (color.B > 1.0f)
513             {
514                 color.B = 1.0f;
515                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
516             }
517             if (color.A < 0.0f)
518             {
519                 color.A = 0.0f;
520                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
521             }
522             else if (color.A > 1.0f)
523             {
524                 color.A = 1.0f;
525                 NUILog.Error("The value of Result is invalid! Should be between [0, 1].");
526             }
527             return color;
528         }
529
530         internal static float ValueCheck(float value)
531         {
532             if (value < 0.0f)
533             {
534                 value = 0.0f;
535                 NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
536             }
537             else if (value > 1.0f)
538             {
539                 value = 1.0f;
540                 NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
541             }
542             return value;
543         }
544
545         internal static float[] ValueCheck(float[] arr)
546         {
547             if (null == arr)
548             {
549                 throw new ArgumentNullException(nameof(arr));
550             }
551
552             for (int i = 0; i < arr.Length; i++)
553             {
554                 if (arr[i] < 0.0f)
555                 {
556                     arr[i] = 0.0f;
557                     NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
558                 }
559                 else if (arr[i] > 1.0f)
560                 {
561                     arr[i] = 1.0f;
562                     NUILog.Error("The value of Parameters is invalid! Should be between [0, 1].");
563                 }
564             }
565             return arr;
566         }
567
568         /// This will not be public opened.
569         [EditorBrowsable(EditorBrowsableState.Never)]
570         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
571         {
572             Interop.Vector4.delete_Vector4(swigCPtr);
573         }
574
575         private Color Add(Color rhs)
576         {
577             Color ret = new Color(Interop.Vector4.Vector4_Add(swigCPtr, Color.getCPtr(rhs)), true);
578             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
579             return ret;
580         }
581
582         private Color AddAssign(Vector4 rhs)
583         {
584             Color ret = new Color(Interop.Vector4.Vector4_AddAssign(swigCPtr, Color.getCPtr(rhs)), false);
585             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
586             return ret;
587         }
588
589         private Color Subtract(Color rhs)
590         {
591             Color ret = new Color(Interop.Vector4.Vector4_Subtract__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
592             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
593             return ret;
594         }
595
596         private Color SubtractAssign(Color rhs)
597         {
598             Color ret = new Color(Interop.Vector4.Vector4_SubtractAssign(swigCPtr, Color.getCPtr(rhs)), false);
599             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
600             return ret;
601         }
602
603         private Color Multiply(Color rhs)
604         {
605             Color ret = new Color(Interop.Vector4.Vector4_Multiply__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
606             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
607             return ret;
608         }
609
610         private Color Multiply(float rhs)
611         {
612             Color ret = new Color(Interop.Vector4.Vector4_Multiply__SWIG_1(swigCPtr, rhs), true);
613             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
614             return ret;
615         }
616
617         private Color MultiplyAssign(Color rhs)
618         {
619             Color ret = new Color(Interop.Vector4.Vector4_MultiplyAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
620             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
621             return ret;
622         }
623
624         private Color MultiplyAssign(float rhs)
625         {
626             Color ret = new Color(Interop.Vector4.Vector4_MultiplyAssign__SWIG_1(swigCPtr, rhs), false);
627             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
628             return ret;
629         }
630
631         private Color Divide(Vector4 rhs)
632         {
633             Color ret = new Color(Interop.Vector4.Vector4_Divide__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
634             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
635             return ret;
636         }
637
638         private Color Divide(float rhs)
639         {
640             Color ret = new Color(Interop.Vector4.Vector4_Divide__SWIG_1(swigCPtr, rhs), true);
641             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
642             return ret;
643         }
644
645         private Color DivideAssign(Color rhs)
646         {
647             Color ret = new Color(Interop.Vector4.Vector4_DivideAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
648             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
649             return ret;
650         }
651
652         private Color DivideAssign(float rhs)
653         {
654             Color ret = new Color(Interop.Vector4.Vector4_DivideAssign__SWIG_1(swigCPtr, rhs), false);
655             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
656             return ret;
657         }
658
659         private Color Subtract()
660         {
661             Color ret = new Color(Interop.Vector4.Vector4_Subtract__SWIG_1(swigCPtr), true);
662             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
663             return ret;
664         }
665
666         private static bool EqualsColorValue(float f1, float f2)
667         {
668             float EPS = (float)Math.Abs(f1 * .00001);
669             if (Math.Abs(f1 - f2) <= EPS)
670             {
671                 return true;
672             }
673             else
674             {
675                 return false;
676             }
677         }
678
679         private static bool EqualsColor(Color c1, Color c2)
680         {
681             return EqualsColorValue(c1.R, c2.R) && EqualsColorValue(c1.G, c2.G)
682                 && EqualsColorValue(c1.B, c2.B) && EqualsColorValue(c1.A, c2.A);
683         }
684
685         /// <summary>
686         /// Determines whether the specified object is equal to the current object.
687         /// </summary>
688         /// <param name="obj">The object to compare with the current object.</param>
689         /// <returns>true if the specified object is equal to the current object; otherwise, false.</returns>
690         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
691         [EditorBrowsable(EditorBrowsableState.Never)]
692         public override bool Equals(System.Object obj)
693         {
694             Color color = obj as Color;
695             bool equal = false;
696             if (color == null)
697             {
698                 return equal;
699             }
700
701             if (EqualsColor(this, color))
702             {
703                 equal = true;
704             }
705             return equal;
706         }
707
708         /// This will be public opened in tizen_5.0 after ACR done. Before ACR, need to be hidden as inhouse API.
709         [EditorBrowsable(EditorBrowsableState.Never)]
710         public override int GetHashCode()
711         {
712             return hashDummy.GetHashCode();
713         }
714
715         private float ValueOfIndex(uint index)
716         {
717             float ret = Interop.Vector4.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
718             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
719             return ret;
720         }
721
722     }
723
724 }
725
726