1 /* 2 * Copyright (c) 2021-2022 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 #ifndef C_INCLUDE_DRAWING_PATH_H 17 #define C_INCLUDE_DRAWING_PATH_H 18 19 /** 20 * @addtogroup Drawing 21 * @{ 22 * 23 * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. 24 * 25 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 26 * 27 * @since 8 28 * @version 1.0 29 */ 30 31 /** 32 * @file drawing_path.h 33 * 34 * @brief Declares functions related to the <b>path</b> object in the drawing module. 35 * 36 * @since 8 37 * @version 1.0 38 */ 39 40 #include "drawing_types.h" 41 42 #ifdef __cplusplus 43 extern "C" { 44 #endif 45 46 /** 47 * @brief Creates an <b>OH_Drawing_Path</b> object. 48 * 49 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 50 * @return Returns the pointer to the <b>OH_Drawing_Path</b> object created. 51 * @since 8 52 * @version 1.0 53 */ 54 OH_Drawing_Path* OH_Drawing_PathCreate(void); 55 56 /** 57 * @brief Destroys an <b>OH_Drawing_Path</b> object and reclaims the memory occupied by the object. 58 * 59 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 60 * @param OH_Drawing_Path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 61 * @since 8 62 * @version 1.0 63 */ 64 void OH_Drawing_PathDestroy(OH_Drawing_Path*); 65 66 /** 67 * @brief Sets the start point of a path. 68 * 69 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 70 * @param OH_Drawing_Path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 71 * @param x Indicates the x coordinate of the start point. 72 * @param y Indicates the y coordinate of the start point. 73 * @since 8 74 * @version 1.0 75 */ 76 void OH_Drawing_PathMoveTo(OH_Drawing_Path*, float x, float y); 77 78 /** 79 * @brief Draws a line segment from the last point of a path to the target point. 80 * 81 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 82 * @param OH_Drawing_Path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 83 * @param x Indicates the x coordinate of the target point. 84 * @param y Indicates the y coordinate of the target point. 85 * @since 8 86 * @version 1.0 87 */ 88 void OH_Drawing_PathLineTo(OH_Drawing_Path*, float x, float y); 89 90 /** 91 * @brief Draws an arc to a path. 92 * 93 * This is done by using angle arc mode. In this mode, a rectangle that encloses an ellipse is specified first, 94 * and then a start angle and a sweep angle are specified. 95 * The arc is a portion of the ellipse defined by the start angle and the sweep angle. 96 * By default, a line segment from the last point of the path to the start point of the arc is also added. 97 * 98 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 99 * @param OH_Drawing_Path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 100 * @param x1 Indicates the x coordinate of the upper left corner of the rectangle. 101 * @param y1 Indicates the y coordinate of the upper left corner of the rectangle. 102 * @param x2 Indicates the x coordinate of the lower right corner of the rectangle. 103 * @param y2 Indicates the y coordinate of the lower right corner of the rectangle. 104 * @param startDeg Indicates the start angle, in degrees. 105 * @param sweepDeg Indicates the angle to sweep, in degrees. 106 * @since 8 107 * @version 1.0 108 */ 109 void OH_Drawing_PathArcTo(OH_Drawing_Path*, float x1, float y1, float x2, float y2, float startDeg, float sweepDeg); 110 111 /** 112 * @brief Draws a quadratic Bezier curve from the last point of a path to the target point. 113 * 114 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 115 * @param OH_Drawing_Path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 116 * @param ctrlX Indicates the x coordinate of the control point. 117 * @param ctrlY Indicates the y coordinate of the control point. 118 * @param endX Indicates the x coordinate of the target point. 119 * @param endY Indicates the y coordinate of the target point. 120 * @since 8 121 * @version 1.0 122 */ 123 void OH_Drawing_PathQuadTo(OH_Drawing_Path*, float ctrlX, float ctrlY, float endX, float endY); 124 125 /** 126 * @brief Draws a cubic Bezier curve from the last point of a path to the target point. 127 * 128 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 129 * @param OH_Drawing_Path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 130 * @param ctrlX1 Indicates the x coordinate of the first control point. 131 * @param ctrlY1 Indicates the y coordinate of the first control point. 132 * @param ctrlX2 Indicates the x coordinate of the second control point. 133 * @param ctrlY2 Indicates the y coordinate of the second control point. 134 * @param endX Indicates the x coordinate of the target point. 135 * @param endY Indicates the y coordinate of the target point. 136 * @since 8 137 * @version 1.0 138 */ 139 void OH_Drawing_PathCubicTo( 140 OH_Drawing_Path*, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY); 141 142 /** 143 * @brief Closes a path. A line segment from the start point to the last point of the path is added. 144 * 145 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 146 * @param OH_Drawing_Path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 147 * @since 8 148 * @version 1.0 149 */ 150 void OH_Drawing_PathClose(OH_Drawing_Path*); 151 152 /** 153 * @brief Resets path data. 154 * 155 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 156 * @param OH_Drawing_Path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 157 * @since 8 158 * @version 1.0 159 */ 160 void OH_Drawing_PathReset(OH_Drawing_Path*); 161 162 #ifdef __cplusplus 163 } 164 #endif 165 /** @} */ 166 #endif 167