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   * @since 11
37   * @version 1.0
38   */
39  
40  #include "drawing_error_code.h"
41  #include "drawing_types.h"
42  
43  #ifdef __cplusplus
44  extern "C" {
45  #endif
46  
47  /**
48   * @brief Enumerates of corner radii position.
49   *
50   * @since 12
51   * @version 1.0
52   */
53  typedef enum {
54      /**
55       * Index of top-left corner radii.
56       */
57      CORNER_POS_TOP_LEFT,
58      /**
59       * Index of top-right corner radii.
60       */
61      CORNER_POS_TOP_RIGHT,
62      /**
63       * Index of bottom-right corner radii.
64       */
65      CORNER_POS_BOTTOM_RIGHT,
66      /**
67       * Index of bottom-left corner radii.
68       */
69      CORNER_POS_BOTTOM_LEFT,
70  } OH_Drawing_CornerPos;
71  
72  /**
73   * @brief Creates an <b>OH_Drawing_RoundRect</b> object.
74   *
75   * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
76   * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
77   * @param xRad Indicates the corner radii on x-axis.
78   * @param yRad Indicates the corner radii on y-axis.
79   * @return Returns the pointer to the <b>OH_Drawing_RoundRect</b> object created.
80   * @since 11
81   * @version 1.0
82   */
83  OH_Drawing_RoundRect* OH_Drawing_RoundRectCreate(const OH_Drawing_Rect*, float xRad, float yRad);
84  
85  /**
86   * @brief Sets the radiusX and radiusY for a specific corner position.
87   *
88   * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
89   * @param OH_Drawing_RoundRect Indicates the pointer to an <b>OH_Drawing_Rect</b> object.
90   * @param pos Indicates the corner radii position.
91   * @param OH_Drawing_Corner_Radii Indicates the corner radii on x-axis and y-axis.
92   * @since 12
93   * @version 1.0
94   */
95  void OH_Drawing_RoundRectSetCorner(OH_Drawing_RoundRect*, OH_Drawing_CornerPos pos, OH_Drawing_Corner_Radii radiusXY);
96  
97  /**
98   * @brief Gets an <b>OH_Drawing_Corner_Radii</b> struct, the point is round corner radiusX and radiusY.
99   *
100   * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
101   * @param OH_Drawing_RoundRect Indicates the pointer to an <b>OH_Drawing_RoundRect</b> object.
102   * @param pos Indicates the corner radii position.
103   * @return Returns the corner radii of <b>OH_Drawing_Corner_Radii</b> struct.
104   * @since 12
105   * @version 1.0
106   */
107  OH_Drawing_Corner_Radii OH_Drawing_RoundRectGetCorner(OH_Drawing_RoundRect*, OH_Drawing_CornerPos pos);
108  
109  /**
110   * @brief Destroys an <b>OH_Drawing_RoundRect</b> object and reclaims the memory occupied by the object.
111   *
112   * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
113   * @param OH_Drawing_RoundRect Indicates the pointer to an <b>OH_Drawing_RoundRect</b> object.
114   * @since 11
115   * @version 1.0
116   */
117  void OH_Drawing_RoundRectDestroy(OH_Drawing_RoundRect*);
118  
119  /**
120   * @brief Translates round rect by (dx, dy).
121   *
122   * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
123   * @param roundRect Indicates the pointer to an <b>OH_Drawing_RoundRect</b> object.
124   * @param dx Indicates the offsets added to rect left and rect right.
125   * @param dy Indicates the offsets added to rect top and rect bottom.
126   * @return Returns the error code.
127   *         Returns {@link OH_DRAWING_SUCCESS} if the operation is successful.
128   *         Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if roundRect is nullptr.
129   * @since 12
130   * @version 1.0
131   */
132  OH_Drawing_ErrorCode OH_Drawing_RoundRectOffset(OH_Drawing_RoundRect* roundRect, float dx, float dy);
133  #ifdef __cplusplus
134  }
135  #endif
136  /** @} */
137  #endif
138