1 /*
2  * Copyright (c) 2023-2024 Huawei Device 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
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
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.
14  */
15 
16 #ifndef C_INCLUDE_DRAWING_ROUND_RECT_H
17 #define C_INCLUDE_DRAWING_ROUND_RECT_H
18 
19 /**
20  * @addtogroup Drawing
21  * @{
22  *
23  * @brief Provides functions such as 2D graphics rendering, text drawing, and image display.
24  *
25  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
26  *
27  * @since 11
28  * @version 1.0
29  */
30 
31 /**
32  * @file drawing_round_rect.h
33  *
34  * @brief Declares functions related to the <b>roundRect</b> object in the drawing module.
35  *
36  * @kit ArkGraphics2D
37  * @library libnative_drawing.so
38  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
39  * @since 11
40  * @version 1.0
41  */
42 
43 #include "drawing_error_code.h"
44 #include "drawing_types.h"
45 
46 #ifdef __cplusplus
47 extern "C" {
48 #endif
49 
50 /**
51  * @brief Enumerates of corner radii position.
52  *
53  * @since 12
54  * @version 1.0
55  */
56 typedef enum {
57     /**
58      * Index of top-left corner radii.
59      */
60     CORNER_POS_TOP_LEFT,
61     /**
62      * Index of top-right corner radii.
63      */
64     CORNER_POS_TOP_RIGHT,
65     /**
66      * Index of bottom-right corner radii.
67      */
68     CORNER_POS_BOTTOM_RIGHT,
69     /**
70      * Index of bottom-left corner radii.
71      */
72     CORNER_POS_BOTTOM_LEFT,
73 } OH_Drawing_CornerPos;
74 
75 /**
76  * @brief Creates an <b>OH_Drawing_RoundRect</b> object.
77  *
78  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
79  * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
80  * @param xRad Indicates the corner radii on x-axis.
81  * @param yRad Indicates the corner radii on y-axis.
82  * @return Returns the pointer to the <b>OH_Drawing_RoundRect</b> object created.
83  * @since 11
84  * @version 1.0
85  */
86 OH_Drawing_RoundRect* OH_Drawing_RoundRectCreate(const OH_Drawing_Rect*, float xRad, float yRad);
87 
88 /**
89  * @brief Sets the radiusX and radiusY for a specific corner position.
90  *
91  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
92  * @param OH_Drawing_RoundRect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
93  * @param pos Indicates the corner radii position.
94  * @param OH_Drawing_Corner_Radii Indicates the corner radii on x-axis and y-axis.
95  * @since 12
96  * @version 1.0
97  */
98 void OH_Drawing_RoundRectSetCorner(OH_Drawing_RoundRect*, OH_Drawing_CornerPos pos, OH_Drawing_Corner_Radii);
99 
100 /**
101  * @brief Gets an <b>OH_Drawing_Corner_Radii</b> struct, the point is round corner radiusX and radiusY.
102  *
103  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
104  * @param OH_Drawing_RoundRect Indicates the pointer to an <b>OH_Drawing_RoundRect</b> object.
105  * @param pos Indicates the corner radii position.
106  * @return Returns the corner radii of <b>OH_Drawing_Corner_Radii</b> struct.
107  * @since 12
108  * @version 1.0
109  */
110 OH_Drawing_Corner_Radii OH_Drawing_RoundRectGetCorner(OH_Drawing_RoundRect*, OH_Drawing_CornerPos pos);
111 
112 /**
113  * @brief Destroys an <b>OH_Drawing_RoundRect</b> object and reclaims the memory occupied by the object.
114  *
115  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
116  * @param OH_Drawing_RoundRect Indicates the pointer to an <b>OH_Drawing_RoundRect</b> object.
117  * @since 11
118  * @version 1.0
119  */
120 void OH_Drawing_RoundRectDestroy(OH_Drawing_RoundRect*);
121 
122 /**
123  * @brief Translates round rect by (dx, dy).
124  *
125  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
126  * @param roundRect Indicates the pointer to an <b>OH_Drawing_RoundRect</b> object.
127  * @param dx Indicates the offsets added to rect left and rect right.
128  * @param dy Indicates the offsets added to rect top and rect bottom.
129  * @return Returns the error code.
130  *         Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
131  *         Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if roundRect is nullptr.
132  * @since 12
133  * @version 1.0
134  */
135 OH_Drawing_ErrorCode OH_Drawing_RoundRectOffset(OH_Drawing_RoundRect* roundRect, float dx, float dy);
136 #ifdef __cplusplus
137 }
138 #endif
139 /** @} */
140 #endif
141