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;
43 //NUI Dispose Pattern written by Jinwoo Nam(jjw.nam)
45 //A Flag to check who called Dispose(). (By User or DisposeQueue)
46 private bool isDisposeQueued = false;
47 //A Flat to check if it is already disposed.
48 protected bool disposed = false;
54 isDisposeQueued = true;
55 DisposeQueue.Instance.Add(this);
60 /// To make Color instance be disposed.
64 //Throw excpetion if Dispose() is called in separate thread.
65 if (!Window.IsInstalled())
67 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
72 Dispose(DisposeTypes.Implicit);
76 Dispose(DisposeTypes.Explicit);
77 System.GC.SuppressFinalize(this);
81 protected virtual void Dispose(DisposeTypes type)
88 if(type == DisposeTypes.Explicit)
91 //Release your own managed resources here.
92 //You should release all of your own disposable objects here.
95 //Release your own unmanaged resources here.
96 //You should not access any managed member here except static instance.
97 //because the execution order of Finalizes is non-deterministic.
99 if (swigCPtr.Handle != global::System.IntPtr.Zero)
104 NDalicPINVOKE.delete_Vector4(swigCPtr);
106 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
112 /// Addition operator.
114 /// <param name="arg1">First value</param>
115 /// <param name="arg2">Second value</param>
116 /// <returns>A Color containing the result of the addition</returns>
117 public static Color operator +(Color arg1, Color arg2)
119 return arg1.Add(arg2);
123 /// Subtraction operator.
125 /// <param name="arg1">First value</param>
126 /// <param name="arg2">Second value</param>
127 /// <returns>A Color containing the result of the subtraction</returns>
128 public static Color operator -(Color arg1, Color arg2)
130 return arg1.Subtract(arg2);
134 /// Unary negation operator.
136 /// <param name="arg1">Target Value</param>
137 /// <returns>A Color containg the negation</returns>
138 public static Color operator -(Color arg1)
140 return arg1.Subtract();
144 /// Multiplication operator.
146 /// <param name="arg1">First Value</param>
147 /// <param name="arg2">Second Value</param>
148 /// <returns>A Color containing the result of the multiplication</returns>
149 public static Color operator *(Color arg1, Color arg2)
151 return arg1.Multiply(arg2);
154 public static Color operator*(Color arg1, float arg2)
156 return arg1.Multiply(arg2);
160 /// Division operator.
162 /// <param name="arg1">First Value</param>
163 /// <param name="arg2">Second Value</param>
164 /// <returns>A Color containing the result of the division</returns>
165 public static Color operator /(Color arg1, Color arg2)
167 return arg1.Divide(arg2);
170 public static Color operator/(Color arg1, float arg2)
172 return arg1.Divide(arg2);
176 /// Array subscript operator overload.
178 /// <param name="index">Subscript index</param>
179 /// <returns>The float at the given index</returns>
180 public float this[uint index]
184 return ValueOfIndex(index);
188 internal static Color GetColorFromPtr(global::System.IntPtr cPtr)
190 Color ret = new Color(cPtr, false);
191 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
196 /// Default constructor
198 public Color() : this(NDalicPINVOKE.new_Vector4__SWIG_0(), true)
200 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
207 /// <param name="r">red component</param>
208 /// <param name="g">green component</param>
209 /// <param name="b">blue component</param>
210 /// <param name="a">alpha component</param>
211 public Color(float r, float g, float b, float a) : this(NDalicPINVOKE.new_Vector4__SWIG_1(r, g, b, a), true)
213 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
217 /// Conversion constructor from an array of four floats.
219 /// <param name="array">array Array of R,G,B,A</param>
220 public Color(float[] array) : this(NDalicPINVOKE.new_Vector4__SWIG_2(array), true)
222 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225 private Color Add(Color rhs)
227 Color ret = new Color(NDalicPINVOKE.Vector4_Add(swigCPtr, Color.getCPtr(rhs)), true);
228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
232 private Color AddAssign(Vector4 rhs)
234 Color ret = new Color(NDalicPINVOKE.Vector4_AddAssign(swigCPtr, Color.getCPtr(rhs)), false);
235 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
239 private Color Subtract(Color rhs)
241 Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
242 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
246 private Color SubtractAssign(Color rhs)
248 Color ret = new Color(NDalicPINVOKE.Vector4_SubtractAssign(swigCPtr, Color.getCPtr(rhs)), false);
249 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
253 private Color Multiply(Color rhs)
255 Color ret = new Color(NDalicPINVOKE.Vector4_Multiply__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
256 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
260 private Color Multiply(float rhs)
262 Color ret = new Color(NDalicPINVOKE.Vector4_Multiply__SWIG_1(swigCPtr, rhs), true);
263 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
267 private Color MultiplyAssign(Color rhs)
269 Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
270 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
274 private Color MultiplyAssign(float rhs)
276 Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_1(swigCPtr, rhs), false);
277 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
281 private Color Divide(Vector4 rhs)
283 Color ret = new Color(NDalicPINVOKE.Vector4_Divide__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
284 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
288 private Color Divide(float rhs)
290 Color ret = new Color(NDalicPINVOKE.Vector4_Divide__SWIG_1(swigCPtr, rhs), true);
291 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
295 private Color DivideAssign(Color rhs)
297 Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
298 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
302 private Color DivideAssign(float rhs)
304 Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_1(swigCPtr, rhs), false);
305 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
309 private Color Subtract()
311 Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_1(swigCPtr), true);
312 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
317 /// Check if two Color classes are same.
319 /// <param name="rhs">A Color to be compared</param>
320 /// <returns>If two Colors are are same, then true.</returns>
321 public bool EqualTo(Color rhs)
323 bool ret = NDalicPINVOKE.Vector4_EqualTo(swigCPtr, Color.getCPtr(rhs));
325 if (rhs == null) return false;
327 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
332 /// Check if two Color classes are different.
334 /// <param name="rhs">A Color to be compared</param>
335 /// <returns>If two Colors are are different, then true.</returns>
336 public bool NotEqualTo(Color rhs)
338 bool ret = NDalicPINVOKE.Vector4_NotEqualTo(swigCPtr, Color.getCPtr(rhs));
339 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
344 private float ValueOfIndex(uint index)
346 float ret = NDalicPINVOKE.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
347 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
358 NDalicPINVOKE.Vector4_r_set(swigCPtr, value);
359 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
363 float ret = NDalicPINVOKE.Vector4_r_get(swigCPtr);
364 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
376 NDalicPINVOKE.Vector4_g_set(swigCPtr, value);
377 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
381 float ret = NDalicPINVOKE.Vector4_g_get(swigCPtr);
382 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
394 NDalicPINVOKE.Vector4_b_set(swigCPtr, value);
395 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
399 float ret = NDalicPINVOKE.Vector4_b_get(swigCPtr);
400 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
412 NDalicPINVOKE.Vector4_a_set(swigCPtr, value);
413 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
417 float ret = NDalicPINVOKE.Vector4_a_get(swigCPtr);
418 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
424 /// Get black colored Color class.
426 public static Color Black
430 global::System.IntPtr cPtr = NDalicPINVOKE.BLACK_get();
431 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
432 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
438 /// Get white colored Color class.
440 public static Color White
444 global::System.IntPtr cPtr = NDalicPINVOKE.WHITE_get();
445 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
446 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
452 /// Get red colored Color class.
454 public static Color Red
458 global::System.IntPtr cPtr = NDalicPINVOKE.RED_get();
459 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
460 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
466 /// Get green colored Color class.
468 public static Color Green
472 global::System.IntPtr cPtr = NDalicPINVOKE.GREEN_get();
473 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
474 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
480 /// Get blue colored Color class.
482 public static Color Blue
486 global::System.IntPtr cPtr = NDalicPINVOKE.BLUE_get();
487 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
488 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
494 /// Get yellow colored Color class.
496 public static Color Yellow
500 global::System.IntPtr cPtr = NDalicPINVOKE.YELLOW_get();
501 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
502 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
508 /// Get magenta colored Color class.
510 public static Color Magenta
514 global::System.IntPtr cPtr = NDalicPINVOKE.MAGENTA_get();
515 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
516 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
522 /// Get cyan colored Color class.
524 public static Color Cyan
528 global::System.IntPtr cPtr = NDalicPINVOKE.CYAN_get();
529 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
530 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
536 /// Get transparent colored Color class.
538 public static Color Transparent
542 global::System.IntPtr cPtr = NDalicPINVOKE.TRANSPARENT_get();
543 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
544 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
550 /// convert Color class to Vector4 class implicitly.
552 /// <param name="color">A Color to be converted to Vector4</param>
553 public static implicit operator Vector4(Color color)
555 return new Vector4(color.R, color.G, color.B, color.A);
559 /// convert Vector4 class to Color class implicitly.
561 /// <param name="vec">A Vector4 to be converted to Color</param></param>
562 public static implicit operator Color(Vector4 vec)
564 return new Color(vec.R, vec.G, vec.B, vec.A);