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 Creates an <b>OH_Drawing_RoundRect</b> copy object. 87 * 88 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 89 * @param roundRect Indicates the pointer to an <b>OH_Drawing_RoundRect</b> object to copy. 90 * @return Returns the pointer to the <b>OH_Drawing_RoundRect</b> object created. 91 * @since 20 92 * @version 1.0 93 */ 94 OH_Drawing_RoundRect* OH_Drawing_RoundRectCopy(const OH_Drawing_RoundRect* roundRect); 95 96 /** 97 * @brief Sets the radiusX and radiusY for a specific corner position. 98 * 99 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 100 * @param OH_Drawing_RoundRect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 101 * @param pos Indicates the corner radii position. 102 * @param OH_Drawing_Corner_Radii Indicates the corner radii on x-axis and y-axis. 103 * @since 12 104 * @version 1.0 105 */ 106 void OH_Drawing_RoundRectSetCorner(OH_Drawing_RoundRect*, OH_Drawing_CornerPos pos, OH_Drawing_Corner_Radii radiusXY); 107 108 /** 109 * @brief Gets an <b>OH_Drawing_Corner_Radii</b> struct, the point is round corner radiusX and radiusY. 110 * 111 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 112 * @param OH_Drawing_RoundRect Indicates the pointer to an <b>OH_Drawing_RoundRect</b> object. 113 * @param pos Indicates the corner radii position. 114 * @return Returns the corner radii of <b>OH_Drawing_Corner_Radii</b> struct. 115 * @since 12 116 * @version 1.0 117 */ 118 OH_Drawing_Corner_Radii OH_Drawing_RoundRectGetCorner(OH_Drawing_RoundRect*, OH_Drawing_CornerPos pos); 119 120 /** 121 * @brief Destroys an <b>OH_Drawing_RoundRect</b> object and reclaims the memory occupied by the object. 122 * 123 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 124 * @param OH_Drawing_RoundRect Indicates the pointer to an <b>OH_Drawing_RoundRect</b> object. 125 * @since 11 126 * @version 1.0 127 */ 128 void OH_Drawing_RoundRectDestroy(OH_Drawing_RoundRect*); 129 130 /** 131 * @brief Translates round rect by (dx, dy). 132 * 133 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 134 * @param roundRect Indicates the pointer to an <b>OH_Drawing_RoundRect</b> object. 135 * @param dx Indicates the offsets added to rect left and rect right. 136 * @param dy Indicates the offsets added to rect top and rect bottom. 137 * @return Returns the error code. 138 * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 139 * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if roundRect is nullptr. 140 * @since 12 141 * @version 1.0 142 */ 143 OH_Drawing_ErrorCode OH_Drawing_RoundRectOffset(OH_Drawing_RoundRect* roundRect, float dx, float dy); 144 #ifdef __cplusplus 145 } 146 #endif 147 /** @} */ 148 #endif 149