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