1 // Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
16 // This File has been auto-generated by SWIG and then modified using DALi Ruby Scripts
17 // Some have been manually changed
27 public class Color : global::System.IDisposable
29 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
30 protected bool swigCMemOwn;
32 internal Color(global::System.IntPtr cPtr, bool cMemoryOwn)
34 swigCMemOwn = cMemoryOwn;
35 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
38 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(Color obj)
40 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
45 DisposeQueue.Instance.Add(this);
49 /// To make Color instance be disposed.
51 public virtual void Dispose()
53 if (!Window.IsInstalled())
55 DisposeQueue.Instance.Add(this);
61 if (swigCPtr.Handle != global::System.IntPtr.Zero)
66 NDalicPINVOKE.delete_Vector4(swigCPtr);
68 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
70 global::System.GC.SuppressFinalize(this);
75 /// Addition operator.
77 /// <param name="arg1">First value</param>
78 /// <param name="arg2">Second value</param>
79 /// <returns>A Color containing the result of the addition</returns>
80 public static Color operator +(Color arg1, Color arg2)
82 return arg1.Add(arg2);
86 /// Subtraction operator.
88 /// <param name="arg1">First value</param>
89 /// <param name="arg2">Second value</param>
90 /// <returns>A Color containing the result of the subtraction</returns>
91 public static Color operator -(Color arg1, Color arg2)
93 return arg1.Subtract(arg2);
97 /// Unary negation operator.
99 /// <param name="arg1">Target Value</param>
100 /// <returns>A Color containg the negation</returns>
101 public static Color operator -(Color arg1)
103 return arg1.Subtract();
107 /// Multiplication operator.
109 /// <param name="arg1">First Value</param>
110 /// <param name="arg2">Second Value</param>
111 /// <returns>A Color containing the result of the multiplication</returns>
112 public static Color operator *(Color arg1, Color arg2)
114 return arg1.Multiply(arg2);
118 /// Division operator.
120 /// <param name="arg1">First Value</param>
121 /// <param name="arg2">Second Value</param>
122 /// <returns>A Color containing the result of the division</returns>
123 public static Color operator /(Color arg1, Color arg2)
125 return arg1.Divide(arg2);
129 /// Array subscript operator overload.
131 /// <param name="index">Subscript index</param>
132 /// <returns>The float at the given index</returns>
133 public float this[uint index]
137 return ValueOfIndex(index);
141 internal static Color GetColorFromPtr(global::System.IntPtr cPtr)
143 Color ret = new Color(cPtr, false);
144 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
149 /// Default constructor
151 public Color() : this(NDalicPINVOKE.new_Vector4__SWIG_0(), true)
153 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
160 /// <param name="r">red component</param>
161 /// <param name="g">green component</param>
162 /// <param name="b">blue component</param>
163 /// <param name="a">alpha component</param>
164 public Color(float r, float g, float b, float a) : this(NDalicPINVOKE.new_Vector4__SWIG_1(r, g, b, a), true)
166 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
170 /// Conversion constructor from an array of four floats.
172 /// <param name="array">array Array of R,G,B,A</param>
173 public Color(float[] array) : this(NDalicPINVOKE.new_Vector4__SWIG_2(array), true)
175 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
178 private Color Add(Color rhs)
180 Color ret = new Color(NDalicPINVOKE.Vector4_Add(swigCPtr, Color.getCPtr(rhs)), true);
181 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
185 private Color AddAssign(Vector4 rhs)
187 Color ret = new Color(NDalicPINVOKE.Vector4_AddAssign(swigCPtr, Color.getCPtr(rhs)), false);
188 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
192 private Color Subtract(Color rhs)
194 Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
195 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
199 private Color SubtractAssign(Color rhs)
201 Color ret = new Color(NDalicPINVOKE.Vector4_SubtractAssign(swigCPtr, Color.getCPtr(rhs)), false);
202 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
206 private Color Multiply(Color rhs)
208 Color ret = new Color(NDalicPINVOKE.Vector4_Multiply__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
209 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
213 private Color MultiplyAssign(Color rhs)
215 Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
216 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
220 private Color MultiplyAssign(float rhs)
222 Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_1(swigCPtr, rhs), false);
223 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
227 private Color Divide(Vector4 rhs)
229 Color ret = new Color(NDalicPINVOKE.Vector4_Divide__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
230 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
235 private Color DivideAssign(Color rhs)
237 Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
238 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
242 private Color DivideAssign(float rhs)
244 Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_1(swigCPtr, rhs), false);
245 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
249 private Color Subtract()
251 Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_1(swigCPtr), true);
252 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
257 /// Check if two Color classes are same.
259 /// <param name="rhs">A Color to be compared</param>
260 /// <returns>If two Colors are are same, then true.</returns>
261 public bool EqualTo(Color rhs)
263 bool ret = NDalicPINVOKE.Vector4_EqualTo(swigCPtr, Color.getCPtr(rhs));
265 if (rhs == null) return false;
267 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
272 /// Check if two Color classes are different.
274 /// <param name="rhs">A Color to be compared</param>
275 /// <returns>If two Colors are are different, then true.</returns>
276 public bool NotEqualTo(Color rhs)
278 bool ret = NDalicPINVOKE.Vector4_NotEqualTo(swigCPtr, Color.getCPtr(rhs));
279 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
284 private float ValueOfIndex(uint index)
286 float ret = NDalicPINVOKE.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
287 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
298 NDalicPINVOKE.Vector4_r_set(swigCPtr, value);
299 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
303 float ret = NDalicPINVOKE.Vector4_r_get(swigCPtr);
304 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
316 NDalicPINVOKE.Vector4_g_set(swigCPtr, value);
317 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
321 float ret = NDalicPINVOKE.Vector4_g_get(swigCPtr);
322 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
334 NDalicPINVOKE.Vector4_b_set(swigCPtr, value);
335 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
339 float ret = NDalicPINVOKE.Vector4_b_get(swigCPtr);
340 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
352 NDalicPINVOKE.Vector4_a_set(swigCPtr, value);
353 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
357 float ret = NDalicPINVOKE.Vector4_a_get(swigCPtr);
358 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
364 /// Get black colored Color class.
366 public static Color Black
370 global::System.IntPtr cPtr = NDalicPINVOKE.BLACK_get();
371 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
372 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
378 /// Get white colored Color class.
380 public static Color White
384 global::System.IntPtr cPtr = NDalicPINVOKE.WHITE_get();
385 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
386 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
392 /// Get red colored Color class.
394 public static Color Red
398 global::System.IntPtr cPtr = NDalicPINVOKE.RED_get();
399 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
400 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
406 /// Get green colored Color class.
408 public static Color Green
412 global::System.IntPtr cPtr = NDalicPINVOKE.GREEN_get();
413 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
414 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
420 /// Get blue colored Color class.
422 public static Color Blue
426 global::System.IntPtr cPtr = NDalicPINVOKE.BLUE_get();
427 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
428 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
434 /// Get yellow colored Color class.
436 public static Color Yellow
440 global::System.IntPtr cPtr = NDalicPINVOKE.YELLOW_get();
441 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
442 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
448 /// Get magenta colored Color class.
450 public static Color Magenta
454 global::System.IntPtr cPtr = NDalicPINVOKE.MAGENTA_get();
455 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
456 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
462 /// Get cyan colored Color class.
464 public static Color Cyan
468 global::System.IntPtr cPtr = NDalicPINVOKE.CYAN_get();
469 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
470 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
476 /// Get transparent colored Color class.
478 public static Color Transparent
482 global::System.IntPtr cPtr = NDalicPINVOKE.TRANSPARENT_get();
483 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
484 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
490 /// convert Color class to Vector4 class implicitly.
492 /// <param name="color">A Color to be converted to Vector4</param>
493 public static implicit operator Vector4(Color color)
495 return new Vector4(color.R, color.G, color.B, color.A);
499 /// convert Vector4 class to Color class implicitly.
501 /// <param name="vec">A Vector4 to be converted to Color</param></param>
502 public static implicit operator Color(Vector4 vec)
504 return new Color(vec.R, vec.G, vec.B, vec.A);