e03d5bf12aca66f09b727fb77efcc9c1fab48555
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / BaseComponents / VectorGraphcis / Drawable.cs
1 /*
2 * Copyright(c) 2021 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 using System;
18 using System.ComponentModel;
19
20 namespace Tizen.NUI.BaseComponents.VectorGraphics
21 {
22     /// <summary>
23     /// Drawable is a object class for drawing a vector primitive.
24     /// </summary>
25     [EditorBrowsable(EditorBrowsableState.Never)]
26     public class Drawable : BaseHandle
27     {
28         /// <summary>
29         /// Creates an initialized drawable.
30         /// </summary>
31         [EditorBrowsable(EditorBrowsableState.Never)]
32         private Drawable() {}
33
34         internal Drawable(global::System.IntPtr cPtr, bool cMemoryOwn) : base(cPtr, cMemoryOwn)
35         {
36         }
37
38         /// <summary>
39         /// The transparency level [0 ~ 1.0], 0 means totally transparent, while 1 means opaque.
40         /// </summary>
41         [EditorBrowsable(EditorBrowsableState.Never)]
42         public float Opacity
43         {   
44             get {
45                 return Interop.Drawable.GetOpacity(BaseHandle.getCPtr(this));
46             }
47             set {
48                 Interop.Drawable.SetOpacity(BaseHandle.getCPtr(this), value);
49                 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
50             }   
51         }
52
53         /// <summary>
54         /// Set the angle of rotation transformation.
55         /// </summary>
56         /// <param name="degree">The degree value of angle.</param>
57         /// <returns>True when it's successful. False otherwise.</returns>
58         [EditorBrowsable(EditorBrowsableState.Never)]
59         public bool Rotate(float degree)
60         {   
61             bool ret = Interop.Drawable.Rotate(BaseHandle.getCPtr(this), degree);
62             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
63             return ret;
64         }
65
66         /// <summary>
67         /// Set the scale value of scale transformation.
68         /// </summary>
69         /// <param name="factor">The scale factor value.</param>
70         /// <returns>True when it's successful. False otherwise.</returns>
71         [EditorBrowsable(EditorBrowsableState.Never)]
72         public bool Scale(float factor)
73         {   
74             bool ret = Interop.Drawable.Scale(BaseHandle.getCPtr(this), factor);
75             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
76             return ret;
77         }
78
79         /// <summary>
80         /// Set the matrix value for affine transform.
81         /// </summary>
82         /// <param name="matrix">The float type array of 3x3 matrix.</param>
83         /// <returns>True when it's successful. False otherwise.</returns>
84         /// <exception cref="ArgumentNullException"> Thrown when matrix is null. </exception>
85         /// <exception cref="ArgumentException"> Thrown when matrix array length is not 9. </exception>
86         [EditorBrowsable(EditorBrowsableState.Never)]
87         public bool Transform(float[] matrix)
88         {   
89             if (matrix == null)
90             {
91                 throw new ArgumentNullException(nameof(matrix));
92             }
93             if (matrix.Length != 9)
94             {
95                 throw new ArgumentException("matrix array length is not 9.", nameof(matrix));
96             }
97             bool ret = Interop.Drawable.Transform(BaseHandle.getCPtr(this), matrix);
98             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
99             return ret;
100         }
101
102         /// <summary>
103         /// Set the x, y movement value of translate transformation.
104         /// </summary>
105         /// <param name="x">The x-axis movement value.</param>
106         /// <param name="y">The y-axis movement value.</param>
107         /// <returns>True when it's successful. False otherwise.</returns>
108         [EditorBrowsable(EditorBrowsableState.Never)]
109         public bool Translate(float x, float y)
110         {   
111             bool ret = Interop.Drawable.Translate(BaseHandle.getCPtr(this), x, y);
112             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
113             return ret;
114         }
115     }
116 }