17777dab0Sopenharmony_ci/* 27777dab0Sopenharmony_ci * Copyright (c) 2023-2024 Huawei Device Co., Ltd. 37777dab0Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License"); 47777dab0Sopenharmony_ci * you may not use this file except in compliance with the License. 57777dab0Sopenharmony_ci * You may obtain a copy of the License at 67777dab0Sopenharmony_ci * 77777dab0Sopenharmony_ci * http://www.apache.org/licenses/LICENSE-2.0 87777dab0Sopenharmony_ci * 97777dab0Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software 107777dab0Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS, 117777dab0Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 127777dab0Sopenharmony_ci * See the License for the specific language governing permissions and 137777dab0Sopenharmony_ci * limitations under the License. 147777dab0Sopenharmony_ci */ 157777dab0Sopenharmony_ci 167777dab0Sopenharmony_ci#ifndef C_INCLUDE_DRAWING_RECT_H 177777dab0Sopenharmony_ci#define C_INCLUDE_DRAWING_RECT_H 187777dab0Sopenharmony_ci 197777dab0Sopenharmony_ci/** 207777dab0Sopenharmony_ci * @addtogroup Drawing 217777dab0Sopenharmony_ci * @{ 227777dab0Sopenharmony_ci * 237777dab0Sopenharmony_ci * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. 247777dab0Sopenharmony_ci * 257777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 267777dab0Sopenharmony_ci * 277777dab0Sopenharmony_ci * @since 11 287777dab0Sopenharmony_ci * @version 1.0 297777dab0Sopenharmony_ci */ 307777dab0Sopenharmony_ci 317777dab0Sopenharmony_ci/** 327777dab0Sopenharmony_ci * @file drawing_rect.h 337777dab0Sopenharmony_ci * 347777dab0Sopenharmony_ci * @brief Declares functions related to the <b>rect</b> object in the drawing module. 357777dab0Sopenharmony_ci * 367777dab0Sopenharmony_ci * @kit ArkGraphics2D 377777dab0Sopenharmony_ci * @library libnative_drawing.so 387777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 397777dab0Sopenharmony_ci * @since 11 407777dab0Sopenharmony_ci * @version 1.0 417777dab0Sopenharmony_ci */ 427777dab0Sopenharmony_ci 437777dab0Sopenharmony_ci#include "drawing_types.h" 447777dab0Sopenharmony_ci 457777dab0Sopenharmony_ci#ifdef __cplusplus 467777dab0Sopenharmony_ciextern "C" { 477777dab0Sopenharmony_ci#endif 487777dab0Sopenharmony_ci 497777dab0Sopenharmony_ci/** 507777dab0Sopenharmony_ci * @brief Creates an <b>OH_Drawing_Rect</b> object. 517777dab0Sopenharmony_ci * 527777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 537777dab0Sopenharmony_ci * @param left Indicates the left position of the rect. 547777dab0Sopenharmony_ci * @param top Indicates the top position of the rect. 557777dab0Sopenharmony_ci * @param right Indicates the right position of the rect. 567777dab0Sopenharmony_ci * @param bottom Indicates the bottom position of the rect. 577777dab0Sopenharmony_ci * @return Returns the pointer to the <b>OH_Drawing_Rect</b> object created. 587777dab0Sopenharmony_ci * @since 11 597777dab0Sopenharmony_ci * @version 1.0 607777dab0Sopenharmony_ci */ 617777dab0Sopenharmony_ciOH_Drawing_Rect* OH_Drawing_RectCreate(float left, float top, float right, float bottom); 627777dab0Sopenharmony_ci 637777dab0Sopenharmony_ci/** 647777dab0Sopenharmony_ci * @brief If rect intersects other, sets rect to intersection. 657777dab0Sopenharmony_ci * 667777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 677777dab0Sopenharmony_ci * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 687777dab0Sopenharmony_ci * @param other Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 697777dab0Sopenharmony_ci * @return Returns true if have area in common. 707777dab0Sopenharmony_ci * @since 12 717777dab0Sopenharmony_ci * @version 1.0 727777dab0Sopenharmony_ci */ 737777dab0Sopenharmony_cibool OH_Drawing_RectIntersect(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other); 747777dab0Sopenharmony_ci 757777dab0Sopenharmony_ci/** 767777dab0Sopenharmony_ci * @brief Sets rect to the union of rect and other. 777777dab0Sopenharmony_ci * 787777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 797777dab0Sopenharmony_ci * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 807777dab0Sopenharmony_ci * @param other Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 817777dab0Sopenharmony_ci * @return Returns true if rect and other are not nullptr, and other is not empty; 827777dab0Sopenharmony_ci * false if rect or other is nullptr, or other is empty. 837777dab0Sopenharmony_ci * @since 12 847777dab0Sopenharmony_ci * @version 1.0 857777dab0Sopenharmony_ci */ 867777dab0Sopenharmony_cibool OH_Drawing_RectJoin(OH_Drawing_Rect* rect, const OH_Drawing_Rect* other); 877777dab0Sopenharmony_ci 887777dab0Sopenharmony_ci/** 897777dab0Sopenharmony_ci * @brief Set the left position of the rect. 907777dab0Sopenharmony_ci * 917777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 927777dab0Sopenharmony_ci * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 937777dab0Sopenharmony_ci * @param left Indicates the left position of the rect. 947777dab0Sopenharmony_ci * @since 12 957777dab0Sopenharmony_ci * @version 1.0 967777dab0Sopenharmony_ci */ 977777dab0Sopenharmony_civoid OH_Drawing_RectSetLeft(OH_Drawing_Rect* rect, float left); 987777dab0Sopenharmony_ci 997777dab0Sopenharmony_ci/** 1007777dab0Sopenharmony_ci * @brief Set the top position of the rect. 1017777dab0Sopenharmony_ci * 1027777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1037777dab0Sopenharmony_ci * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 1047777dab0Sopenharmony_ci * @param top Indicates the top position of the rect. 1057777dab0Sopenharmony_ci * @since 12 1067777dab0Sopenharmony_ci * @version 1.0 1077777dab0Sopenharmony_ci */ 1087777dab0Sopenharmony_civoid OH_Drawing_RectSetTop(OH_Drawing_Rect* rect, float top); 1097777dab0Sopenharmony_ci 1107777dab0Sopenharmony_ci/** 1117777dab0Sopenharmony_ci * @brief Set the right position of the rect. 1127777dab0Sopenharmony_ci * 1137777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1147777dab0Sopenharmony_ci * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 1157777dab0Sopenharmony_ci * @param right Indicates the right position of the rect. 1167777dab0Sopenharmony_ci * @since 12 1177777dab0Sopenharmony_ci * @version 1.0 1187777dab0Sopenharmony_ci */ 1197777dab0Sopenharmony_civoid OH_Drawing_RectSetRight(OH_Drawing_Rect* rect, float right); 1207777dab0Sopenharmony_ci 1217777dab0Sopenharmony_ci/** 1227777dab0Sopenharmony_ci * @brief Set the bottom position of the rect. 1237777dab0Sopenharmony_ci * 1247777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1257777dab0Sopenharmony_ci * @param rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 1267777dab0Sopenharmony_ci * @param bottom Indicates the bottom position of the rect. 1277777dab0Sopenharmony_ci * @since 12 1287777dab0Sopenharmony_ci * @version 1.0 1297777dab0Sopenharmony_ci */ 1307777dab0Sopenharmony_civoid OH_Drawing_RectSetBottom(OH_Drawing_Rect* rect, float bottom); 1317777dab0Sopenharmony_ci 1327777dab0Sopenharmony_ci/** 1337777dab0Sopenharmony_ci * @brief Get the left position of the rect. 1347777dab0Sopenharmony_ci * 1357777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1367777dab0Sopenharmony_ci * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 1377777dab0Sopenharmony_ci * @return Return the left position of the rect. 1387777dab0Sopenharmony_ci * @since 12 1397777dab0Sopenharmony_ci * @version 1.0 1407777dab0Sopenharmony_ci */ 1417777dab0Sopenharmony_cifloat OH_Drawing_RectGetLeft(OH_Drawing_Rect*); 1427777dab0Sopenharmony_ci 1437777dab0Sopenharmony_ci/** 1447777dab0Sopenharmony_ci * @brief Get the top position of the rect. 1457777dab0Sopenharmony_ci * 1467777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1477777dab0Sopenharmony_ci * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 1487777dab0Sopenharmony_ci * @return Return the top position of the rect. 1497777dab0Sopenharmony_ci * @since 12 1507777dab0Sopenharmony_ci * @version 1.0 1517777dab0Sopenharmony_ci */ 1527777dab0Sopenharmony_cifloat OH_Drawing_RectGetTop(OH_Drawing_Rect*); 1537777dab0Sopenharmony_ci 1547777dab0Sopenharmony_ci/** 1557777dab0Sopenharmony_ci * @brief Get the right position of the rect. 1567777dab0Sopenharmony_ci * 1577777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1587777dab0Sopenharmony_ci * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 1597777dab0Sopenharmony_ci * @return Return the right position of the rect. 1607777dab0Sopenharmony_ci * @since 12 1617777dab0Sopenharmony_ci * @version 1.0 1627777dab0Sopenharmony_ci */ 1637777dab0Sopenharmony_cifloat OH_Drawing_RectGetRight(OH_Drawing_Rect*); 1647777dab0Sopenharmony_ci 1657777dab0Sopenharmony_ci/** 1667777dab0Sopenharmony_ci * @brief Get the bottom position of the rect. 1677777dab0Sopenharmony_ci * 1687777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1697777dab0Sopenharmony_ci * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 1707777dab0Sopenharmony_ci * @return Return the bottom position of the rect. 1717777dab0Sopenharmony_ci * @since 12 1727777dab0Sopenharmony_ci * @version 1.0 1737777dab0Sopenharmony_ci */ 1747777dab0Sopenharmony_cifloat OH_Drawing_RectGetBottom(OH_Drawing_Rect*); 1757777dab0Sopenharmony_ci 1767777dab0Sopenharmony_ci/** 1777777dab0Sopenharmony_ci * @brief Get the height position of the rect. 1787777dab0Sopenharmony_ci * 1797777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1807777dab0Sopenharmony_ci * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 1817777dab0Sopenharmony_ci * @since 12 1827777dab0Sopenharmony_ci * @version 1.0 1837777dab0Sopenharmony_ci */ 1847777dab0Sopenharmony_cifloat OH_Drawing_RectGetHeight(OH_Drawing_Rect*); 1857777dab0Sopenharmony_ci 1867777dab0Sopenharmony_ci/* @brief Get the width position of the rect. 1877777dab0Sopenharmony_ci * 1887777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 1897777dab0Sopenharmony_ci * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 1907777dab0Sopenharmony_ci * @return Returns the width. 1917777dab0Sopenharmony_ci * @since 12 1927777dab0Sopenharmony_ci * @version 1.0 1937777dab0Sopenharmony_ci */ 1947777dab0Sopenharmony_cifloat OH_Drawing_RectGetWidth(OH_Drawing_Rect*); 1957777dab0Sopenharmony_ci 1967777dab0Sopenharmony_ci/** 1977777dab0Sopenharmony_ci * @brief Copy the original rectangular object to the destination rectangular object. 1987777dab0Sopenharmony_ci * 1997777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2007777dab0Sopenharmony_ci * @param src Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 2017777dab0Sopenharmony_ci * @param dst Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 2027777dab0Sopenharmony_ci * @since 12 2037777dab0Sopenharmony_ci * @version 1.0 2047777dab0Sopenharmony_ci */ 2057777dab0Sopenharmony_civoid OH_Drawing_RectCopy(OH_Drawing_Rect* src, OH_Drawing_Rect* dst); 2067777dab0Sopenharmony_ci 2077777dab0Sopenharmony_ci/** 2087777dab0Sopenharmony_ci * @brief Destroys an <b>OH_Drawing_Rect</b> object and reclaims the memory occupied by the object. 2097777dab0Sopenharmony_ci * 2107777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2117777dab0Sopenharmony_ci * @param OH_Drawing_Rect Indicates the pointer to an <b>OH_Drawing_Rect</b> object. 2127777dab0Sopenharmony_ci * @since 11 2137777dab0Sopenharmony_ci * @version 1.0 2147777dab0Sopenharmony_ci */ 2157777dab0Sopenharmony_civoid OH_Drawing_RectDestroy(OH_Drawing_Rect*); 2167777dab0Sopenharmony_ci 2177777dab0Sopenharmony_ci/** 2187777dab0Sopenharmony_ci * @brief Creates an <b>OH_Drawing_Array</b> object, which is used to store multiple <b>OH_Drawing_Rect</b> object. 2197777dab0Sopenharmony_ci * 2207777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2217777dab0Sopenharmony_ci * @param size Indicates the size of the array object. 2227777dab0Sopenharmony_ci * @return Returns the pointer to the <b>OH_Drawing_Array</b> object created. 2237777dab0Sopenharmony_ci * If nullptr is returned, the creation fails. 2247777dab0Sopenharmony_ci * The possible cause of the failure is that the available memory is empty, 2257777dab0Sopenharmony_ci * or size is invalid. 2267777dab0Sopenharmony_ci * @since 14 2277777dab0Sopenharmony_ci * @version 1.0 2287777dab0Sopenharmony_ci */ 2297777dab0Sopenharmony_ciOH_Drawing_Array* OH_Drawing_RectCreateArray(size_t size); 2307777dab0Sopenharmony_ci 2317777dab0Sopenharmony_ci/** 2327777dab0Sopenharmony_ci * @brief Gets the size of an <b>OH_Drawing_Array</b> object. 2337777dab0Sopenharmony_ci * 2347777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2357777dab0Sopenharmony_ci * @param rectArray Indicates the array object. 2367777dab0Sopenharmony_ci * @param pSize Indicates the size pointer. 2377777dab0Sopenharmony_ci * @return Returns the error code. 2387777dab0Sopenharmony_ci * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 2397777dab0Sopenharmony_ci * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if rectArray or pSize is nullptr. 2407777dab0Sopenharmony_ci * @since 14 2417777dab0Sopenharmony_ci * @version 1.0 2427777dab0Sopenharmony_ci */ 2437777dab0Sopenharmony_ciOH_Drawing_ErrorCode OH_Drawing_RectGetArraySize(OH_Drawing_Array* rectArray, size_t* pSize); 2447777dab0Sopenharmony_ci 2457777dab0Sopenharmony_ci/** 2467777dab0Sopenharmony_ci * @brief Gets the specified <b>OH_Drawing_Rect</b> object from <b>OH_Drawing_Array</b> object. 2477777dab0Sopenharmony_ci * 2487777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2497777dab0Sopenharmony_ci * @param rectArray Indicates the array object. 2507777dab0Sopenharmony_ci * @param index Indicates the index of array, caller must make sure the index is valid. 2517777dab0Sopenharmony_ci * @param rect Pointers to Pointer of <b>OH_Drawing_Rect</b> object, returned to the caller. 2527777dab0Sopenharmony_ci * @return Returns the error code. 2537777dab0Sopenharmony_ci * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 2547777dab0Sopenharmony_ci * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if rectArray or rect is nullptr, 2557777dab0Sopenharmony_ci * or index is valid. 2567777dab0Sopenharmony_ci * @since 14 2577777dab0Sopenharmony_ci * @version 1.0 2587777dab0Sopenharmony_ci */ 2597777dab0Sopenharmony_ciOH_Drawing_ErrorCode OH_Drawing_RectGetArrayElement(OH_Drawing_Array* rectArray, size_t index, 2607777dab0Sopenharmony_ci OH_Drawing_Rect** rect); 2617777dab0Sopenharmony_ci 2627777dab0Sopenharmony_ci/** 2637777dab0Sopenharmony_ci * @brief Destroys an array <b>OH_Drawing_Rect</b> object and reclaims the memory occupied by the object. 2647777dab0Sopenharmony_ci * 2657777dab0Sopenharmony_ci * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 2667777dab0Sopenharmony_ci * @param rectArray Indicates the pointer to an <b>OH_Drawing_Array</b> object. 2677777dab0Sopenharmony_ci * @return Returns the error code. 2687777dab0Sopenharmony_ci * Returns {@link OH_DRAWING_SUCCESS} if the operation is successful. 2697777dab0Sopenharmony_ci * Returns {@link OH_DRAWING_ERROR_INVALID_PARAMETER} if rectArray is nullptr. 2707777dab0Sopenharmony_ci * @since 14 2717777dab0Sopenharmony_ci * @version 1.0 2727777dab0Sopenharmony_ci */ 2737777dab0Sopenharmony_ciOH_Drawing_ErrorCode OH_Drawing_RectDestroyArray(OH_Drawing_Array* rectArray); 2747777dab0Sopenharmony_ci 2757777dab0Sopenharmony_ci#ifdef __cplusplus 2767777dab0Sopenharmony_ci} 2777777dab0Sopenharmony_ci#endif 2787777dab0Sopenharmony_ci/** @} */ 2797777dab0Sopenharmony_ci#endif 280