openharmony 鸿蒙 capi-drawing-round-rect-h

2026-08-25 浏览 (1)

drawing_round_rect.h

Overview

This file declares the functions related to the rounded rectangle in the drawing module.

File to include: <native_drawing/drawing_round_rect.h>

Library: libnative_drawing.so

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Related module: Drawing

Summary

Enumerated value

Nametypedef KeywordDescription
OH_Drawing_CornerPosOH_Drawing_CornerPosDefines an enum for the corner positions of a rounded rectangle.

Functions

NameDescription
OH_Drawing_RoundRect* OH_Drawing_RoundRectCreate(const OH_Drawing_Rect* rect, float xRad, float yRad)Creates an OH_Drawing_RoundRect object. This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
OH_Drawing_RoundRect* OH_Drawing_RoundRectCopy(const OH_Drawing_RoundRect* roundRect)Creates a copy of a rounded rectangle.
void OH_Drawing_RoundRectSetCorner(OH_Drawing_RoundRect* roundRect,OH_Drawing_CornerPos pos, OH_Drawing_Corner_Radii radii)Sets the radii of the specified rounded corner in this rounded rectangle.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If roundRect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
OH_Drawing_Corner_Radii OH_Drawing_RoundRectGetCorner(OH_Drawing_RoundRect* roundRect, OH_Drawing_CornerPos pos)Obtains the radii of the specified rounded corner in a rounded rectangle.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If roundRect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_RoundRectDestroy(OH_Drawing_RoundRect* roundRect)Destroys an OH_Drawing_RoundRect object and reclaims the memory occupied by the object.
OH_Drawing_ErrorCode OH_Drawing_RoundRectOffset(OH_Drawing_RoundRect* roundRect, float dx, float dy)Translates a rounded rectangle by an offset along the X axis and Y axis.

Enum Description

OH_Drawing_CornerPos

enum OH_Drawing_CornerPos

Description

Defines an enum for the corner positions of a rounded rectangle.

Since: 12

ValueDescription
CORNER_POS_TOP_LEFTTop left corner of the rounded rectangle.
CORNER_POS_TOP_RIGHTTop right corner of the rounded rectangle.
CORNER_POS_BOTTOM_RIGHTBottom right corner of the rounded rectangle.
CORNER_POS_BOTTOM_LEFTBottom left corner of the rounded rectangle.

Function Description

OH_Drawing_RoundRectCreate()

OH_Drawing_RoundRect* OH_Drawing_RoundRectCreate(const OH_Drawing_Rect* rect, float xRad, float yRad)

Description

Creates an OH_Drawing_RoundRect object. This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

NameDescription
const OH_Drawing_Rect* rectPointer to an OH_Drawing_Rect object.
float xRadRadius of the rounded corner on the X axis. A negative number is invalid.
float yRadRadius of the rounded corner on the Y axis. A negative number is invalid.

Returns

TypeDescription
OH_Drawing_RoundRect*Returns the pointer to the OH_Drawing_RoundRect object created.

OH_Drawing_RoundRectCopy()

OH_Drawing_RoundRect* OH_Drawing_RoundRectCopy(const OH_Drawing_RoundRect* roundRect)

Description

Creates a copy of a rounded rectangle.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 20

Parameters

NameDescription
const OH_Drawing_RoundRect* roundRectPointer to an OH_Drawing_RoundRect object.

Returns

TypeDescription
OH_Drawing_RoundRect*Returns the pointer to the new OH_Drawing_RoundRect object created.

OH_Drawing_RoundRectSetCorner()

void OH_Drawing_RoundRectSetCorner(OH_Drawing_RoundRect* roundRect,OH_Drawing_CornerPos pos, OH_Drawing_Corner_Radii radii)

Description

Sets the radii of the specified rounded corner in this rounded rectangle.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If roundRect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_RoundRect* roundRectPointer to an OH_Drawing_RoundRect object.
OH_Drawing_CornerPos posPosition of the rounded corner. For details about the available options, see OH_Drawing_CornerPos.
OH_Drawing_Corner_Radii radiiOH_Drawing_Corner_Radii struct, including the radii on the X axis and Y axis. A radius less than or equal to 0 is invalid.

OH_Drawing_RoundRectGetCorner()

OH_Drawing_Corner_Radii OH_Drawing_RoundRectGetCorner(OH_Drawing_RoundRect* roundRect, OH_Drawing_CornerPos pos)

Description

Obtains the radii of the specified rounded corner in a rounded rectangle.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If roundRect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_RoundRect* roundRectPointer to an OH_Drawing_RoundRect object.
OH_Drawing_CornerPos posPosition of the rounded corner. For details about the available options, see OH_Drawing_CornerPos.

Returns

TypeDescription
OH_Drawing_Corner_RadiiReturns an OH_Drawing_Corner_Radii struct, including the radii on the X axis and Y axis.

OH_Drawing_RoundRectDestroy()

void OH_Drawing_RoundRectDestroy(OH_Drawing_RoundRect* roundRect)

Description

Destroys an OH_Drawing_RoundRect object and reclaims the memory occupied by the object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

NameDescription
OH_Drawing_RoundRect* roundRectPointer to an OH_Drawing_RoundRect object.

OH_Drawing_RoundRectOffset()

OH_Drawing_ErrorCode OH_Drawing_RoundRectOffset(OH_Drawing_RoundRect* roundRect, float dx, float dy)

Description

Translates a rounded rectangle by an offset along the X axis and Y axis.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_RoundRect* roundRectPointer to an OH_Drawing_Point2D object.
float dxX offset.
float dyY offset.

Returns

TypeDescription
OH_Drawing_ErrorCodeReturns one of the following result codes:
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INVALID_PARAMETER if roundRect is NULL.

你可能感兴趣的鸿蒙文章

openharmony 鸿蒙 capi-drawing-gpu-context-h

openharmony 鸿蒙 capi-drawing-nativepixelmap-

openharmony 鸿蒙 capi-nativevsync-oh-nativevsync-expectedraterange

openharmony 鸿蒙 capi-drawing-oh-drawing-brush

openharmony 鸿蒙 capi-drawing-oh-drawing-image-info

openharmony 鸿蒙 capi-drawing-text-linetypography-h

openharmony 鸿蒙 capi-oh-nativeimage-oh-nativeimage

openharmony 鸿蒙 capi-drawing-typeface-h

openharmony 鸿蒙 capi-drawing-brush-h

openharmony 鸿蒙 capi-nativewindow

  • 所属分类: 后端技术
  • 本文标签: 软件 鸿蒙
  • 版权声明: 本文链接 https://seaxiang.com/blog/kAP5arcL