1# drawing_round_rect.h 2 3## 概述 4 5文件中定义了与圆角矩形相关的功能函数。 6 7**引用文件:** <native_drawing/drawing_round_rect.h> 8 9**库:** libnative_drawing.so 10 11**起始版本:** 11 12 13**相关模块:** [Drawing](capi-drawing.md) 14 15## 汇总 16 17### 枚举 18 19| 名称 | typedef关键字 | 描述 | 20| -- | -- | -- | 21| [OH_Drawing_CornerPos](#oh_drawing_cornerpos) | OH_Drawing_CornerPos | 用于描述圆角位置的枚举。 | 22 23### 函数 24 25| 名称 | 描述 | 26| -- | -- | 27| [OH_Drawing_RoundRect* OH_Drawing_RoundRectCreate(const OH_Drawing_Rect* rect, float xRad, float yRad)](#oh_drawing_roundrectcreate) | 用于创建一个圆角矩形对象。本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 | 28| [OH_Drawing_RoundRect* OH_Drawing_RoundRectCopy(const OH_Drawing_RoundRect* roundRect)](#oh_drawing_roundrectcopy) | 用于创建圆角矩形的拷贝。 | 29| [void OH_Drawing_RoundRectSetCorner(OH_Drawing_RoundRect* roundRect,OH_Drawing_CornerPos pos, OH_Drawing_Corner_Radii radii)](#oh_drawing_roundrectsetcorner) | 用于设置圆角矩形中指定圆角位置的圆角半径。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>roundRect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 | 30| [OH_Drawing_Corner_Radii OH_Drawing_RoundRectGetCorner(OH_Drawing_RoundRect* roundRect, OH_Drawing_CornerPos pos)](#oh_drawing_roundrectgetcorner) | 用于获取圆角矩形中指定圆角位置的圆角半径。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>roundRect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 | 31| [void OH_Drawing_RoundRectDestroy(OH_Drawing_RoundRect* roundRect)](#oh_drawing_roundrectdestroy) | 用于销毁圆角矩形对象并回收该对象占有的内存。 | 32| [OH_Drawing_ErrorCode OH_Drawing_RoundRectOffset(OH_Drawing_RoundRect* roundRect, float dx, float dy)](#oh_drawing_roundrectoffset) | 用于将圆角矩形沿x轴方向和y轴方向平移指定距离。 | 33 34## 枚举类型说明 35 36### OH_Drawing_CornerPos 37 38``` 39enum OH_Drawing_CornerPos 40``` 41 42**描述** 43 44用于描述圆角位置的枚举。 45 46**起始版本:** 12 47 48| 枚举项 | 描述 | 49| -- | -- | 50| CORNER_POS_TOP_LEFT | 左上角圆角位置。 | 51| CORNER_POS_TOP_RIGHT | 右上角圆角位置。 | 52| CORNER_POS_BOTTOM_RIGHT | 右下角圆角位置。 | 53| CORNER_POS_BOTTOM_LEFT | 左下角圆角位置。 | 54 55 56## 函数说明 57 58### OH_Drawing_RoundRectCreate() 59 60``` 61OH_Drawing_RoundRect* OH_Drawing_RoundRectCreate(const OH_Drawing_Rect* rect, float xRad, float yRad) 62``` 63 64**描述** 65 66用于创建一个圆角矩形对象。本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>rect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 67 68**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 69 70**起始版本:** 11 71 72 73**参数:** 74 75| 参数项 | 描述 | 76| -- | -- | 77| const [OH_Drawing_Rect](capi-drawing-oh-drawing-rect.md)* rect | 指向矩形对象的指针。 | 78| float xRad | X轴上的圆角半径,小于或等于0时无效。 | 79| float yRad | Y轴上的圆角半径,小于或等于0时无效。 | 80 81**返回:** 82 83| 类型 | 说明 | 84| -- | -- | 85| [OH_Drawing_RoundRect](capi-drawing-oh-drawing-roundrect.md)* | 函数会返回一个指针,指针指向创建的圆角矩形对象。 | 86 87### OH_Drawing_RoundRectCopy() 88 89``` 90OH_Drawing_RoundRect* OH_Drawing_RoundRectCopy(const OH_Drawing_RoundRect* roundRect) 91``` 92 93**描述** 94 95用于创建圆角矩形的拷贝。 96 97**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 98 99**起始版本:** 20 100 101 102**参数:** 103 104| 参数项 | 描述 | 105| -- | -- | 106| const [OH_Drawing_RoundRect](capi-drawing-oh-drawing-roundrect.md)* roundRect | 指向用于拷贝的圆角矩形对象[OH_Drawing_RoundRect](capi-drawing-oh-drawing-roundrect.md)的指针。 | 107 108**返回:** 109 110| 类型 | 说明 | 111| -- | -- | 112| [OH_Drawing_RoundRect](capi-drawing-oh-drawing-roundrect.md)* | 函数会返回一个指针,指针指向创建的新圆角矩形对象。 | 113 114### OH_Drawing_RoundRectSetCorner() 115 116``` 117void OH_Drawing_RoundRectSetCorner(OH_Drawing_RoundRect* roundRect,OH_Drawing_CornerPos pos, OH_Drawing_Corner_Radii radii) 118``` 119 120**描述** 121 122用于设置圆角矩形中指定圆角位置的圆角半径。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>roundRect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 123 124**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 125 126**起始版本:** 12 127 128 129**参数:** 130 131| 参数项 | 描述 | 132| -- | -- | 133| [OH_Drawing_RoundRect](capi-drawing-oh-drawing-roundrect.md)* roundRect | 指向圆角矩形对象的指针。 | 134| [OH_Drawing_CornerPos](#oh_drawing_cornerpos) pos | 圆角位置的枚举,支持类型可见[OH_Drawing_CornerPos](capi-drawing-round-rect-h.md#oh_drawing_cornerpos)。 | 135| OH_Drawing_Corner_Radii radii | 圆角半径结构体OH_Drawing_Corner_Radii,其中包含x轴方向和y轴方向上的半径,半径小于等于0时无效。 | 136 137### OH_Drawing_RoundRectGetCorner() 138 139``` 140OH_Drawing_Corner_Radii OH_Drawing_RoundRectGetCorner(OH_Drawing_RoundRect* roundRect, OH_Drawing_CornerPos pos) 141``` 142 143**描述** 144 145用于获取圆角矩形中指定圆角位置的圆角半径。<br>本接口会产生错误码,可以通过[OH_Drawing_ErrorCodeGet](capi-drawing-error-code-h.md#oh_drawing_errorcodeget)查看错误码的取值。<br>roundRect为NULL时返回OH_DRAWING_ERROR_INVALID_PARAMETER。 146 147**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 148 149**起始版本:** 12 150 151 152**参数:** 153 154| 参数项 | 描述 | 155| -- | -- | 156| [OH_Drawing_RoundRect](capi-drawing-oh-drawing-roundrect.md)* roundRect | 指向圆角矩形对象的指针。 | 157| [OH_Drawing_CornerPos](#oh_drawing_cornerpos) pos | 圆角位置的枚举,支持类型可见[OH_Drawing_CornerPos](capi-drawing-round-rect-h.md#oh_drawing_cornerpos)。 | 158 159**返回:** 160 161| 类型 | 说明 | 162| -- | -- | 163| OH_Drawing_Corner_Radii | 返回指定圆角位置的圆角半径结构体OH_Drawing_Corner_Radii,其中包含x轴方向和y轴方向上的半径。 | 164 165### OH_Drawing_RoundRectDestroy() 166 167``` 168void OH_Drawing_RoundRectDestroy(OH_Drawing_RoundRect* roundRect) 169``` 170 171**描述** 172 173用于销毁圆角矩形对象并回收该对象占有的内存。 174 175**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 176 177**起始版本:** 11 178 179 180**参数:** 181 182| 参数项 | 描述 | 183| -- | -- | 184| [OH_Drawing_RoundRect](capi-drawing-oh-drawing-roundrect.md)* roundRect | 指向圆角矩形对象的指针。 | 185 186### OH_Drawing_RoundRectOffset() 187 188``` 189OH_Drawing_ErrorCode OH_Drawing_RoundRectOffset(OH_Drawing_RoundRect* roundRect, float dx, float dy) 190``` 191 192**描述** 193 194用于将圆角矩形沿x轴方向和y轴方向平移指定距离。 195 196**系统能力:** SystemCapability.Graphic.Graphic2D.NativeDrawing 197 198**起始版本:** 12 199 200 201**参数:** 202 203| 参数项 | 描述 | 204| -- | -- | 205| [OH_Drawing_RoundRect](capi-drawing-oh-drawing-roundrect.md)* roundRect | 指向圆角矩形对象[OH_Drawing_Point2D](capi-drawing-oh-drawing-point2d.md)的指针。 | 206| float dx | 轴方向偏移量。 | 207| float dy | 轴方向偏移量。 | 208 209**返回:** 210 211| 类型 | 说明 | 212| -- | -- | 213| [OH_Drawing_ErrorCode](capi-drawing-error-code-h.md#oh_drawing_errorcode) | 函数返回执行错误码。<br> 返回OH_DRAWING_SUCCESS,表示执行成功。<br> 返回OH_DRAWING_ERROR_INVALID_PARAMETER,表示参数roundRect为空。 | 214 215 216