• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 /**
17  * @addtogroup Drawing
18  * @{
19  *
20  * @brief Provides functions such as 2D graphics rendering, text drawing, and image display.
21  *
22  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
23  *
24  * @since 11
25  * @version 1.0
26  */
27 
28 /**
29  * @file drawing_round_rect.h
30  *
31  * @brief Declares functions related to the <b>roundRect</b> object in the drawing module.
32  *
33  * @kit ArkGraphics2D
34  * @library libnative_drawing.so
35  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
36  * @since 11
37  * @version 1.0
38  */
39 
40 #ifndef C_INCLUDE_DRAWING_ROUND_RECT_H
41 #define C_INCLUDE_DRAWING_ROUND_RECT_H
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 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* 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 roundRect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
93  * @param pos Indicates the corner radii position.
94  * @param 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* roundRect,
99     OH_Drawing_CornerPos pos, OH_Drawing_Corner_Radii radii);
100 
101 /**
102  * @brief Gets an <b>OH_Drawing_Corner_Radii</b> struct, the point is round corner radiusX and radiusY.
103  *
104  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
105  * @param roundRect Indicates the pointer to an <b>OH_Drawing_RoundRect</b> object.
106  * @param pos Indicates the corner radii position.
107  * @return Returns the corner radii of <b>OH_Drawing_Corner_Radii</b> struct.
108  * @since 12
109  * @version 1.0
110  */
111 OH_Drawing_Corner_Radii OH_Drawing_RoundRectGetCorner(OH_Drawing_RoundRect* roundRect, OH_Drawing_CornerPos pos);
112 
113 /**
114  * @brief Destroys an <b>OH_Drawing_RoundRect</b> object and reclaims the memory occupied by the object.
115  *
116  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
117  * @param roundRect Indicates the pointer to an <b>OH_Drawing_RoundRect</b> object.
118  * @since 11
119  * @version 1.0
120  */
121 void OH_Drawing_RoundRectDestroy(OH_Drawing_RoundRect* roundRect);
122 
123 /**
124  * @brief Translates round rect by (dx, dy).
125  *
126  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
127  * @param roundRect Indicates the pointer to an <b>OH_Drawing_RoundRect</b> object.
128  * @param dx Indicates the offsets added to rect left and rect right.
129  * @param dy Indicates the offsets added to rect top and rect bottom.
130  * @return Returns the error code.
131  *         Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
132  *         Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if roundRect is nullptr.
133  * @since 12
134  * @version 1.0
135  */
136 OH_Drawing_ErrorCode OH_Drawing_RoundRectOffset(OH_Drawing_RoundRect* roundRect, float dx, float dy);
137 #ifdef __cplusplus
138 }
139 #endif
140 /** @} */
141 #endif
142