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 //A Flag to check who called Dispose(). (By User or DisposeQueue)
44 private bool isDisposeQueued = false;
45 //A Flat to check if it is already disposed.
46 protected bool disposed = false;
52 isDisposeQueued = true;
53 DisposeQueue.Instance.Add(this);
58 /// To make Color instance be disposed.
62 //Throw excpetion if Dispose() is called in separate thread.
63 if (!Window.IsInstalled())
65 throw new System.InvalidOperationException("This API called from separate thread. This API must be called from MainThread.");
70 Dispose(DisposeTypes.Implicit);
74 Dispose(DisposeTypes.Explicit);
75 System.GC.SuppressFinalize(this);
79 protected virtual void Dispose(DisposeTypes type)
86 if(type == DisposeTypes.Explicit)
89 //Release your own managed resources here.
90 //You should release all of your own disposable objects here.
93 //Release your own unmanaged resources here.
94 //You should not access any managed member here except static instance.
95 //because the execution order of Finalizes is non-deterministic.
97 if (swigCPtr.Handle != global::System.IntPtr.Zero)
102 NDalicPINVOKE.delete_Vector4(swigCPtr);
104 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
110 /// Addition operator.
112 /// <param name="arg1">First value</param>
113 /// <param name="arg2">Second value</param>
114 /// <returns>A Color containing the result of the addition</returns>
115 public static Color operator +(Color arg1, Color arg2)
117 return arg1.Add(arg2);
121 /// Subtraction operator.
123 /// <param name="arg1">First value</param>
124 /// <param name="arg2">Second value</param>
125 /// <returns>A Color containing the result of the subtraction</returns>
126 public static Color operator -(Color arg1, Color arg2)
128 return arg1.Subtract(arg2);
132 /// Unary negation operator.
134 /// <param name="arg1">Target Value</param>
135 /// <returns>A Color containg the negation</returns>
136 public static Color operator -(Color arg1)
138 return arg1.Subtract();
142 /// Multiplication operator.
144 /// <param name="arg1">First Value</param>
145 /// <param name="arg2">Second Value</param>
146 /// <returns>A Color containing the result of the multiplication</returns>
147 public static Color operator *(Color arg1, Color arg2)
149 return arg1.Multiply(arg2);
152 public static Color operator*(Color arg1, float arg2)
154 return arg1.Multiply(arg2);
158 /// Division operator.
160 /// <param name="arg1">First Value</param>
161 /// <param name="arg2">Second Value</param>
162 /// <returns>A Color containing the result of the division</returns>
163 public static Color operator /(Color arg1, Color arg2)
165 return arg1.Divide(arg2);
168 public static Color operator/(Color arg1, float arg2)
170 return arg1.Divide(arg2);
174 /// Array subscript operator overload.
176 /// <param name="index">Subscript index</param>
177 /// <returns>The float at the given index</returns>
178 public float this[uint index]
182 return ValueOfIndex(index);
186 internal static Color GetColorFromPtr(global::System.IntPtr cPtr)
188 Color ret = new Color(cPtr, false);
189 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
194 /// Default constructor
196 public Color() : this(NDalicPINVOKE.new_Vector4__SWIG_0(), true)
198 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
205 /// <param name="r">red component</param>
206 /// <param name="g">green component</param>
207 /// <param name="b">blue component</param>
208 /// <param name="a">alpha component</param>
209 public Color(float r, float g, float b, float a) : this(NDalicPINVOKE.new_Vector4__SWIG_1(r, g, b, a), true)
211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215 /// Conversion constructor from an array of four floats.
217 /// <param name="array">array Array of R,G,B,A</param>
218 public Color(float[] array) : this(NDalicPINVOKE.new_Vector4__SWIG_2(array), true)
220 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
223 private Color Add(Color rhs)
225 Color ret = new Color(NDalicPINVOKE.Vector4_Add(swigCPtr, Color.getCPtr(rhs)), true);
226 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230 private Color AddAssign(Vector4 rhs)
232 Color ret = new Color(NDalicPINVOKE.Vector4_AddAssign(swigCPtr, Color.getCPtr(rhs)), false);
233 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237 private Color Subtract(Color rhs)
239 Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
240 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
244 private Color SubtractAssign(Color rhs)
246 Color ret = new Color(NDalicPINVOKE.Vector4_SubtractAssign(swigCPtr, Color.getCPtr(rhs)), false);
247 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
251 private Color Multiply(Color rhs)
253 Color ret = new Color(NDalicPINVOKE.Vector4_Multiply__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
254 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
258 private Color Multiply(float rhs)
260 Color ret = new Color(NDalicPINVOKE.Vector4_Multiply__SWIG_1(swigCPtr, rhs), true);
261 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
265 private Color MultiplyAssign(Color rhs)
267 Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
268 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
272 private Color MultiplyAssign(float rhs)
274 Color ret = new Color(NDalicPINVOKE.Vector4_MultiplyAssign__SWIG_1(swigCPtr, rhs), false);
275 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
279 private Color Divide(Vector4 rhs)
281 Color ret = new Color(NDalicPINVOKE.Vector4_Divide__SWIG_0(swigCPtr, Color.getCPtr(rhs)), true);
282 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
286 private Color Divide(float rhs)
288 Color ret = new Color(NDalicPINVOKE.Vector4_Divide__SWIG_1(swigCPtr, rhs), true);
289 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
293 private Color DivideAssign(Color rhs)
295 Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_0(swigCPtr, Color.getCPtr(rhs)), false);
296 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
300 private Color DivideAssign(float rhs)
302 Color ret = new Color(NDalicPINVOKE.Vector4_DivideAssign__SWIG_1(swigCPtr, rhs), false);
303 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
307 private Color Subtract()
309 Color ret = new Color(NDalicPINVOKE.Vector4_Subtract__SWIG_1(swigCPtr), true);
310 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
315 /// Check if two Color classes are same.
317 /// <param name="rhs">A Color to be compared</param>
318 /// <returns>If two Colors are are same, then true.</returns>
319 public bool EqualTo(Color rhs)
321 bool ret = NDalicPINVOKE.Vector4_EqualTo(swigCPtr, Color.getCPtr(rhs));
323 if (rhs == null) return false;
325 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
330 /// Check if two Color classes are different.
332 /// <param name="rhs">A Color to be compared</param>
333 /// <returns>If two Colors are are different, then true.</returns>
334 public bool NotEqualTo(Color rhs)
336 bool ret = NDalicPINVOKE.Vector4_NotEqualTo(swigCPtr, Color.getCPtr(rhs));
337 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
342 private float ValueOfIndex(uint index)
344 float ret = NDalicPINVOKE.Vector4_ValueOfIndex__SWIG_0(swigCPtr, index);
345 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
356 NDalicPINVOKE.Vector4_r_set(swigCPtr, value);
357 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
361 float ret = NDalicPINVOKE.Vector4_r_get(swigCPtr);
362 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
374 NDalicPINVOKE.Vector4_g_set(swigCPtr, value);
375 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
379 float ret = NDalicPINVOKE.Vector4_g_get(swigCPtr);
380 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
392 NDalicPINVOKE.Vector4_b_set(swigCPtr, value);
393 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
397 float ret = NDalicPINVOKE.Vector4_b_get(swigCPtr);
398 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
410 NDalicPINVOKE.Vector4_a_set(swigCPtr, value);
411 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
415 float ret = NDalicPINVOKE.Vector4_a_get(swigCPtr);
416 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
422 /// Get black colored Color class.
424 public static Color Black
428 global::System.IntPtr cPtr = NDalicPINVOKE.BLACK_get();
429 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
430 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
436 /// Get white colored Color class.
438 public static Color White
442 global::System.IntPtr cPtr = NDalicPINVOKE.WHITE_get();
443 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
444 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
450 /// Get red colored Color class.
452 public static Color Red
456 global::System.IntPtr cPtr = NDalicPINVOKE.RED_get();
457 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
458 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
464 /// Get green colored Color class.
466 public static Color Green
470 global::System.IntPtr cPtr = NDalicPINVOKE.GREEN_get();
471 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
472 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
478 /// Get blue colored Color class.
480 public static Color Blue
484 global::System.IntPtr cPtr = NDalicPINVOKE.BLUE_get();
485 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
486 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
492 /// Get yellow colored Color class.
494 public static Color Yellow
498 global::System.IntPtr cPtr = NDalicPINVOKE.YELLOW_get();
499 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
500 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
506 /// Get magenta colored Color class.
508 public static Color Magenta
512 global::System.IntPtr cPtr = NDalicPINVOKE.MAGENTA_get();
513 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
514 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
520 /// Get cyan colored Color class.
522 public static Color Cyan
526 global::System.IntPtr cPtr = NDalicPINVOKE.CYAN_get();
527 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
528 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
534 /// Get transparent colored Color class.
536 public static Color Transparent
540 global::System.IntPtr cPtr = NDalicPINVOKE.TRANSPARENT_get();
541 Color ret = (cPtr == global::System.IntPtr.Zero) ? null : new Color(cPtr, false);
542 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
548 /// convert Color class to Vector4 class implicitly.
550 /// <param name="color">A Color to be converted to Vector4</param>
551 public static implicit operator Vector4(Color color)
553 return new Vector4(color.R, color.G, color.B, color.A);
557 /// convert Vector4 class to Color class implicitly.
559 /// <param name="vec">A Vector4 to be converted to Color</param></param>
560 public static implicit operator Color(Vector4 vec)
562 return new Color(vec.R, vec.G, vec.B, vec.A);