Merge "Fix PageFactory to take in Texture rather than Image" into devel/master
[platform/core/uifw/dali-toolkit.git] / plugins / dali-swig / manual / csharp / Color.cs
1 namespace Dali {
2
3 using System;
4
5 public class Color : Vector4
6        {
7   /**
8    * @brief constructor
9    *
10    * @since 1.0.0
11    */
12            public Color()
13                : base()
14            { }
15   /**
16    * @brief constructor
17    *
18    * @since 1.0.0
19    * @param [in] red The Color r.
20    * @param [in] green The Color g.
21    * @param [in] blue The Color b.
22    * @param [in] alpha The Color a.
23    */
24            public Color(float red, float green, float blue, float alpha)
25                : base(red, green, blue, alpha)
26            { }
27
28   /**
29    * @brief constructor
30    *
31    * @since 1.0.0
32    * @param [in] o The Vector4 having r g b a components
33    */
34           public Color(Vector4 o)
35                : base(o.x, o.y, o.z, o.w)
36           {
37                  
38           }
39
40   /**
41    * @brief constructor
42    *
43    * @since 1.0.0
44    * @param [in] color as string.
45    */
46            public Color(string color)
47                : base(0, 0, 0, 0)
48            {
49                switch (color)
50                {
51                    case "red":
52                        SetColor(255, 0, 0, 255);
53                        break;
54                    case "white":
55                        SetColor(255, 255, 255, 255);
56                        break;
57                    case "blue":
58                        SetColor(0, 0, 255, 255);
59                        break;
60                    case "green":
61                        SetColor(0, 255, 0, 255);
62                        break;
63                    case "black":
64                        SetColor(0, 0, 0, 255);
65                        break;
66                    case "grey":
67                        SetColor(128, 128, 128, 255);
68                        break;
69                    case "yellow":
70                        SetColor(255, 255, 0, 255);
71                        break;
72                    case "azure":
73                        SetColor(0, 255, 255, 255);
74                        break;
75                    case "rose":
76                        SetColor(255, 0, 255, 255);
77                        break;
78                }
79            }
80    
81   /**
82    * @brief SetColor
83    *
84    * @since 1.0.0
85    * @param [in] red The Color r.
86    * @param [in] green The Color g.
87    * @param [in] blue The Color b.
88    * @param [in] alpha The Color a.
89    */
90            public void SetColor(float red, float green, float blue, float alpha)
91            { 
92                r = red;
93                g = green;
94                b = blue;
95                a = alpha;
96            }
97
98       /**
99        * @brief name "R", type float (Color's Red component)
100        * @SINCE_1_0.0
101        */
102
103            public float R
104            {
105                get { return r; }
106                set { r = value; }
107            }
108
109       /**
110        * @brief name "G", type float (Color's Green component)
111        * @SINCE_1_0.0
112        */
113            public float G
114            {
115                get { return g; }
116                set { g = value; }
117            }
118
119       /**
120        * @brief name "B", type float (Color's Blue component)
121        * @SINCE_1_0.0
122        */
123            public float B
124            {
125                get { return b; }
126                set { b = value; }
127            }
128
129       /**
130        * @brief name "A", type float (Color's Alpha value)
131        * @SINCE_1_0.0
132        */
133            public float A
134            {
135                get { return a; }
136                set { a = value; }
137            }
138
139   /**
140    * @brief operator+
141    *
142    * @since 1.0.0
143    * @param [in] l The Color to add.
144    * @param [in] r The Color to add
145    * @return A reference to this
146    */
147            public static Color operator +(Color l, Color r)
148            {
149                return new Color(l.R + r.R, l.G + r.G, l.B + r.B, l.A + r.A);
150            }
151
152   /**
153    * @brief operator-
154    *
155    * @since 1.0.0
156    * @param [in] l The Color to substract.
157    * @param [in] r The Color to substract
158    * @return A reference to this
159    */
160            public static Color operator -(Color l, Color r)
161            {
162                return new Color(l.R - r.R, l.G - r.G, l.B - r.B, l.A - r.A);
163            }
164
165   /**
166    * @brief operator*
167    *
168    * @since 1.0.0
169    * @param [in] a The Color to multiply.
170    * @param [in] b The Color to multiply
171    * @return A reference to this
172    */
173            public static Color operator *(Color a, double b)
174            {
175                return new Color((int)(a.R * b), (int)(a.G * b), (int)(a.B * b), (int)(a.A * b));
176            }
177
178   /**
179    * @brief operator/
180    *
181    * @since 1.0.0
182    * @param [in] a The Color to divide.
183    * @param [in] b The Color to divide
184    * @return float value of division operation
185    */
186            public static float operator /(Color a, Color b)
187            {
188                return (float)System.Math.Sqrt((a.R / b.R) * (a.G / b.G) * (a.B / b.B) * (a.A / b.A));
189            }
190
191   /**
192    * @brief Equals
193    *
194    * @since 1.0.0
195    * @param [in] o The Color object to compare.
196    * @param [in] r The Color to add
197    * @return bool, whether object equal or not
198    */
199            public override bool Equals(object obj)
200            {
201                Color l = this;
202                Color r = obj as Color;
203                if (r == null)
204                {
205                    return false;
206                }
207                return l.R == r.R && l.G == r.G && l.B == r.B && l.A == r.A;
208            }
209
210   /**
211    * @brief GetHashCode
212    *
213    * @since 1.0.0
214    * @return int, hascode of Color
215    */
216            public override int GetHashCode()
217            {
218                return base.GetHashCode();
219            }
220
221   /**
222    * @brief Clone
223    *
224    * @since 1.0.0
225    * @return Color object
226    */
227            public Color Clone()
228            {
229                Color copy = new Color(R, G, B, A);
230                return copy;
231            }
232        }
233
234 }