openharmony 鸿蒙 capi-drawing-rect-h

2026-08-25 浏览 (1)

drawing_rect.h

Overview

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

Sample: NDKAPIDrawing (API Version 20)

File to include: <native_drawing/drawing_rect.h>

Library: libnative_drawing.so

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Related module: Drawing

Summary

Functions

NameDescription
OH_Drawing_Rect* OH_Drawing_RectCreate(float left, float top, float right, float bottom)Creates an OH_Drawing_Rect object, without sorting the coordinates passed in. This means that the coordinates of the upper left corner of the rectangle can be greater than those of the lower right corner.
bool OH_Drawing_RectIntersect(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other)Checks whether two rectangles intersect and if yes, sets rect to the area of intersection.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either rect or other is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
bool OH_Drawing_RectJoin(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other)Obtains the union of two rectangles.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either rect or other is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_RectSetLeft(OH_Drawing_Rect* rect, float left)Sets the horizontal coordinate of the upper left corner of a rectangle.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_RectSetTop(OH_Drawing_Rect* rect, float top)Sets the vertical coordinate of the upper left corner of a rectangle.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_RectSetRight(OH_Drawing_Rect* rect, float right)Sets the horizontal coordinate of the lower right corner of a rectangle.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_RectSetBottom(OH_Drawing_Rect* rect, float bottom)Sets the vertical coordinate of the lower right corner of a rectangle.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
float OH_Drawing_RectGetLeft(OH_Drawing_Rect* rect)Obtains the X coordinate of the upper left corner of a rectangle.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
float OH_Drawing_RectGetTop(OH_Drawing_Rect* rect)Obtains the Y coordinate of the upper left corner of a rectangle.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
float OH_Drawing_RectGetRight(OH_Drawing_Rect* rect)Obtains the X coordinate of the lower right corner of a rectangle.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
float OH_Drawing_RectGetBottom(OH_Drawing_Rect* rect)Obtains the Y coordinate of the lower right corner of a rectangle.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
float OH_Drawing_RectGetHeight(OH_Drawing_Rect* rect)Obtains the height of a rectangle. The height is calculated by using the Y coordinate of the lower right corner of the rectangle minus the Y coordinate of the upper left corner.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
float OH_Drawing_RectGetWidth(OH_Drawing_Rect* rect)Obtains the width of a rectangle. The width is calculated by using the X coordinate of the lower right corner of the rectangle minus the X coordinate of the upper left corner.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If rect is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_RectCopy(OH_Drawing_Rect* src, OH_Drawing_Rect* dst)Copies a source rectangle to create a new one.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either src or dst is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.
void OH_Drawing_RectDestroy(OH_Drawing_Rect* rect)Destroys an OH_Drawing_Rect object and reclaims the memory occupied by the object.
OH_Drawing_Array* OH_Drawing_RectCreateArray(size_t size)Creates a rectangle array object to store multiple rectangle objects. Release this pointer by calling OH_Drawing_RectDestroyArray when this object is no longer needed.
OH_Drawing_ErrorCode OH_Drawing_RectGetArraySize(OH_Drawing_Array* rectArray, size_t* pSize)Obtains the size of an OH_Drawing_Array object.
OH_Drawing_ErrorCode OH_Drawing_RectGetArrayElement(OH_Drawing_Array* rectArray, size_t index,OH_Drawing_Rect** rect)Obtains the rectangle with the specified index in a rectangle array.
OH_Drawing_ErrorCode OH_Drawing_RectDestroyArray(OH_Drawing_Array* rectArray)Destroys an OH_Drawing_Array object and reclaims the memory occupied by the object.
OH_Drawing_ErrorCode OH_Drawing_RectContains(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other, bool* isContains)Checks whether a rectangle completely contains another rectangle.
OH_Drawing_ErrorCode OH_Drawing_RectInset(OH_Drawing_Rect* rect, float left, float top, float right, float bottom)Adds a specified value to the bounds of a rectangle.
OH_Drawing_ErrorCode OH_Drawing_RectIsEmpty(const OH_Drawing_Rect* rect, bool* isEmpty)Checks whether a rectangle is empty.
OH_Drawing_ErrorCode OH_Drawing_RectOffset(OH_Drawing_Rect* rect, float dx, float dy)Offsets a rectangle along the X axis and Y axis.
OH_Drawing_ErrorCode OH_Drawing_RectOffsetTo(OH_Drawing_Rect* rect, float newLeft, float newTop)Offsets a rectangle to a specific position while keeping the width and height unchanged.
OH_Drawing_ErrorCode OH_Drawing_RectSetEmpty(OH_Drawing_Rect* rect)Clears a rectangle (by setting the X and Y coordinates of the upper left corner and lower right corner to 0).
OH_Drawing_ErrorCode OH_Drawing_RectSort(OH_Drawing_Rect* rect)Sorts the coordinates of a rectangle based on the actual position.
If the X coordinate of the upper left corner is greater than that of the lower right corner, the two coordinates are exchanged. If the Y coordinate of the upper left corner is greater than that of the lower right corner, the two coordinates are exchanged. If the coordinates are already in order, no operation is performed.
OH_Drawing_ErrorCode OH_Drawing_RectUnion(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other)Sets the current rectangle to the union of this rectangle and another rectangle.

Function Description

OH_Drawing_RectCreate()

OH_Drawing_Rect* OH_Drawing_RectCreate(float left, float top, float right, float bottom)

Description

Creates an OH_Drawing_Rect object, without sorting the coordinates passed in. This means that the coordinates of the upper left corner of the rectangle can be greater than those of the lower right corner.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

NameDescription
float leftX coordinate of the upper left corner of the rectangle.
float topY coordinate of the upper left corner of the rectangle.
float rightX coordinate of the lower right corner of the rectangle.
float bottomY coordinate of the lower right corner of the rectangle.

Returns

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

OH_Drawing_RectIntersect()

bool OH_Drawing_RectIntersect(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other)

Description

Checks whether two rectangles intersect and if yes, sets rect to the area of intersection.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either rect or other is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to an OH_Drawing_Rect object.
const OH_Drawing_Rect* otherPointer to an OH_Drawing_Rect object.

Returns

TypeDescription
boolReturns true if they intersect (rect is set to the intersection area); returns false otherwise (rect remains unchanged).

OH_Drawing_RectJoin()

bool OH_Drawing_RectJoin(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other)

Description

Obtains the union of two rectangles.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either rect or other is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to an OH_Drawing_Rect object.
const OH_Drawing_Rect* otherPointer to an OH_Drawing_Rect object.

Returns

TypeDescription
boolReturns true if the union is obtained; returns false otherwise. The possible failure cause is that at least one of the parameters rect and other is NULL or the size of the rectangle specified by other is empty.

OH_Drawing_RectSetLeft()

void OH_Drawing_RectSetLeft(OH_Drawing_Rect* rect, float left)

Description

Sets the horizontal coordinate of the upper left corner of a rectangle.
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: 12

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to an OH_Drawing_Rect object.
float leftX coordinate of the upper left corner of the rectangle.

OH_Drawing_RectSetTop()

void OH_Drawing_RectSetTop(OH_Drawing_Rect* rect, float top)

Description

Sets the vertical coordinate of the upper left corner of a rectangle.
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: 12

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to an OH_Drawing_Rect object.
float topY coordinate of the upper left corner of the rectangle.

OH_Drawing_RectSetRight()

void OH_Drawing_RectSetRight(OH_Drawing_Rect* rect, float right)

Description

Sets the horizontal coordinate of the lower right corner of a rectangle.
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: 12

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to an OH_Drawing_Rect object.
float rightX coordinate of the lower right corner of the rectangle.

OH_Drawing_RectSetBottom()

void OH_Drawing_RectSetBottom(OH_Drawing_Rect* rect, float bottom)

Description

Sets the vertical coordinate of the lower right corner of a rectangle.
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: 12

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to an OH_Drawing_Rect object.
float bottomY coordinate of the lower right corner of the rectangle.

OH_Drawing_RectGetLeft()

float OH_Drawing_RectGetLeft(OH_Drawing_Rect* rect)

Description

Obtains the X coordinate of the upper left corner of a rectangle.
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: 12

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to an OH_Drawing_Rect object.

Returns

TypeDescription
floatX coordinate of the upper left corner of the rectangle.

OH_Drawing_RectGetTop()

float OH_Drawing_RectGetTop(OH_Drawing_Rect* rect)

Description

Obtains the Y coordinate of the upper left corner of a rectangle.
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: 12

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to an OH_Drawing_Rect object.

Returns

TypeDescription
floatY coordinate of the upper left corner of the rectangle.

OH_Drawing_RectGetRight()

float OH_Drawing_RectGetRight(OH_Drawing_Rect* rect)

Description

Obtains the X coordinate of the lower right corner of a rectangle.
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: 12

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to an OH_Drawing_Rect object.

Returns

TypeDescription
floatX coordinate of the lower right corner of the rectangle.

OH_Drawing_RectGetBottom()

float OH_Drawing_RectGetBottom(OH_Drawing_Rect* rect)

Description

Obtains the Y coordinate of the lower right corner of a rectangle.
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: 12

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to an OH_Drawing_Rect object.

Returns

TypeDescription
floatY coordinate of the lower right corner of the rectangle.

OH_Drawing_RectGetHeight()

float OH_Drawing_RectGetHeight(OH_Drawing_Rect* rect)

Description

Obtains the height of a rectangle. The height is calculated by using the Y coordinate of the lower right corner of the rectangle minus the Y coordinate of the upper left corner.
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: 12

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to an OH_Drawing_Rect object.

Returns

TypeDescription
floatReturns the height of the rectangle, in pixels.

OH_Drawing_RectGetWidth()

float OH_Drawing_RectGetWidth(OH_Drawing_Rect* rect)

Description

Obtains the width of a rectangle. The width is calculated by using the X coordinate of the lower right corner of the rectangle minus the X coordinate of the upper left corner.
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: 12

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to an OH_Drawing_Rect object.

Returns

TypeDescription
floatReturns the weight of the rectangle, in pixels.

OH_Drawing_RectCopy()

void OH_Drawing_RectCopy(OH_Drawing_Rect* src, OH_Drawing_Rect* dst)

Description

Copies a source rectangle to create a new one.
This API may return an error code. For details, call OH_Drawing_ErrorCodeGet.
If either src or dst is NULL, OH_DRAWING_ERROR_INVALID_PARAMETER is returned.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 12

Parameters

NameDescription
OH_Drawing_Rect* srcPointer to a source rectangle, which is an OH_Drawing_Rect object.
OH_Drawing_Rect* dstPointer to a destination rectangle, which is an OH_Drawing_Rect object.

OH_Drawing_RectDestroy()

void OH_Drawing_RectDestroy(OH_Drawing_Rect* rect)

Description

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

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 11

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to an OH_Drawing_Rect object.

OH_Drawing_RectCreateArray()

OH_Drawing_Array* OH_Drawing_RectCreateArray(size_t size)

Description

Creates a rectangle array object to store multiple rectangle objects. Release this pointer by calling OH_Drawing_RectDestroyArray when this object is no longer needed.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
size_t sizeSize of the rectangle array. The value cannot exceed 65536, which is the maximum number of glyph indices.

Returns

TypeDescription
OH_Drawing_Array*Returns the pointer to the OH_Drawing_Array object created. If the returned object pointer is null, the creation fails.
Possible causes are that no memory is available or an input parameter is incorrect.

OH_Drawing_RectGetArraySize()

OH_Drawing_ErrorCode OH_Drawing_RectGetArraySize(OH_Drawing_Array* rectArray, size_t* pSize)

Description

Obtains the size of an OH_Drawing_Array object.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Array* rectArrayPointer to an OH_Drawing_Array object.
size_t* pSizePointer to the size_t type, which is used as an output parameter to store the size of the rectangle array.

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 either rectArray or pSize is NULL.

OH_Drawing_RectGetArrayElement()

OH_Drawing_ErrorCode OH_Drawing_RectGetArrayElement(OH_Drawing_Array* rectArray, size_t index,OH_Drawing_Rect** rect)

Description

Obtains the rectangle with the specified index in a rectangle array.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Array* rectArrayPointer to an OH_Drawing_Array object.
size_t indexIndex of the rectangle array.
OH_Drawing_Rect** rectDouble pointer to OH_Drawing_Rect, which is returned to the caller as an output parameter.

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 rectArray or rect is null or index is out of range.

OH_Drawing_RectDestroyArray()

OH_Drawing_ErrorCode OH_Drawing_RectDestroyArray(OH_Drawing_Array* rectArray)

Description

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

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 18

Parameters

NameDescription
OH_Drawing_Array* rectArrayPointer to an OH_Drawing_Array object.

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 rectArray is NULL.

OH_Drawing_RectContains()

OH_Drawing_ErrorCode OH_Drawing_RectContains(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other, bool* isContains)

Description

Checks whether a rectangle completely contains another rectangle.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 22

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to the OH_Drawing_Rect object. This rectangle is used to check whether another rectangle (other) is contained.
const OH_Drawing_Rect* otherPointer to the OH_Drawing_Rect object. This rectangle is used to check whether it is contained by another rectangle (rect).
bool* isContainsResult of whether a rectangle completely contains another rectangle. It is used as an output parameter. true indicates that rect completely contains other. false indicates that rect does not completely contain other.

Returns

TypeDescription
OH_Drawing_ErrorCodeReturns one of the following result codes:
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if the rect, other, or isContains parameter is empty.

OH_Drawing_RectInset()

OH_Drawing_ErrorCode OH_Drawing_RectInset(OH_Drawing_Rect* rect, float left, float top, float right, float bottom)

Description

Adds a specified value to the bounds of a rectangle.

System capability: SystemCapability.Graphic.Graphic2D.NativeDrawing

Since: 22

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to the OH_Drawing_Rect object.
float leftValue to be added to the left bound of the rectangle (X coordinate of the upper left corner of the rectangle).
float topValue to be added to the top bound of the rectangle (Y coordinate of the upper left corner of the rectangle).
float rightValue to be added to the right bound of the rectangle (X coordinate of the lower right corner of the rectangle).
float bottomValue to be added to the bottom bound of the rectangle (Y coordinate of the lower right corner of the rectangle).

Returns

TypeDescription
OH_Drawing_ErrorCodeReturns one of the following result codes:
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if the rect parameter is empty.

OH_Drawing_RectIsEmpty()

OH_Drawing_ErrorCode OH_Drawing_RectIsEmpty(const OH_Drawing_Rect* rect, bool* isEmpty)

Description

Checks whether a rectangle is empty.

Since: 23

Parameters

NameDescription
const OH_Drawing_Rect* rectPointer to the OH_Drawing_Rect object.
bool* isEmptyWhether a rectangle is empty. It is used as an output parameter. true means yes; false otherwise.

Returns

TypeDescription
OH_Drawing_ErrorCodeExecution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if rect or isEmpty is a null pointer.

OH_Drawing_RectOffset()

OH_Drawing_ErrorCode OH_Drawing_RectOffset(OH_Drawing_Rect* rect, float dx, float dy)

Description

Offsets a rectangle along the X axis and Y axis.

Since: 23

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to the OH_Drawing_Rect object.
float dxOffset on the X axis. A positive number indicates an offset towards the positive direction of the X axis, and a negative number indicates an offset towards the negative direction of the X axis.
float dyOffset on the Y axis. A positive number indicates an offset towards the positive direction of the Y axis, and a negative number indicates an offset towards the negative direction of the Y axis.

Returns

TypeDescription
OH_Drawing_ErrorCodeExecution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if rect is a null pointer.

OH_Drawing_RectOffsetTo()

OH_Drawing_ErrorCode OH_Drawing_RectOffsetTo(OH_Drawing_Rect* rect, float newLeft, float newTop)

Description

Offsets a rectangle to a specific position while keeping the width and height unchanged.

Since: 23

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to the OH_Drawing_Rect object.
float newLeftX coordinate of the upper left corner of the rectangle after the offset.
float newTopY coordinate of the upper left corner of the rectangle after the offset.

Returns

TypeDescription
OH_Drawing_ErrorCodeExecution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if rect is a null pointer.

OH_Drawing_RectSetEmpty()

OH_Drawing_ErrorCode OH_Drawing_RectSetEmpty(OH_Drawing_Rect* rect)

Description

Clears a rectangle (by setting the X and Y coordinates of the upper left corner and lower right corner to 0).

Since: 23

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to the OH_Drawing_Rect object.

Returns

TypeDescription
OH_Drawing_ErrorCodeExecution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if rect is a null pointer.

OH_Drawing_RectSort()

OH_Drawing_ErrorCode OH_Drawing_RectSort(OH_Drawing_Rect* rect)

Description

Sorts the coordinates of a rectangle based on the actual position.

If the X coordinate of the upper left corner is greater than that of the lower right corner, the two coordinates are exchanged. If the Y coordinate of the upper left corner is greater than that of the lower right corner, the two coordinates are exchanged. If the coordinates are already in order, no operation is performed.

Since: 23

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to the OH_Drawing_Rect object.

Returns

TypeDescription
OH_Drawing_ErrorCodeExecution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if rect is a null pointer.

OH_Drawing_RectUnion()

OH_Drawing_ErrorCode OH_Drawing_RectUnion(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other)

Description

Sets the current rectangle to the union of this rectangle and another rectangle.

Since: 23

Parameters

NameDescription
OH_Drawing_Rect* rectPointer to this OH_Drawing_Rect object.
const OH_Drawing_Rect* otherPointer to another OH_Drawing_Rect object.

Returns

TypeDescription
OH_Drawing_ErrorCodeExecution result.
OH_DRAWING_SUCCESS if the operation is successful.
OH_DRAWING_ERROR_INCORRECT_PARAMETER if rect or other is a null pointer.

你可能感兴趣的鸿蒙文章

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/n5ZgWcVR