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 y3 Indicates the y coordinate of the lower right corner of the rectangle. 104 * @since 8 105 * @version 1.0 106 */ 107 void OH_Drawing_PathArcTo(OH_Drawing_Path*, float x1, float y1, float x2, float y2, float startDeg, float sweepDeg); 108 109 /** 110 * @brief Draws a quadratic Bezier curve from the last point of a path to the target point. 111 * 112 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 113 * @param OH_Drawing_Path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 114 * @param ctrlX Indicates the x coordinate of the control point. 115 * @param ctrlY Indicates the y coordinate of the control point. 116 * @param endX Indicates the x coordinate of the target point. 117 * @param endY Indicates the y coordinate of the target point. 118 * @since 8 119 * @version 1.0 120 */ 121 void OH_Drawing_PathQuadTo(OH_Drawing_Path*, float ctrlX, float ctrlY, float endX, float endY); 122 123 /** 124 * @brief Draws a cubic Bezier curve from the last point of a path to the target point. 125 * 126 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 127 * @param OH_Drawing_Path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 128 * @param ctrlX1 Indicates the x coordinate of the first control point. 129 * @param ctrlY1 Indicates the y coordinate of the first control point. 130 * @param ctrlX2 Indicates the x coordinate of the second control point. 131 * @param ctrlY2 Indicates the y coordinate of the second control point. 132 * @param endX Indicates the x coordinate of the target point. 133 * @param endY Indicates the y coordinate of the target point. 134 * @since 8 135 * @version 1.0 136 */ 137 void OH_Drawing_PathCubicTo( 138 OH_Drawing_Path*, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY); 139 140 /** 141 * @brief Closes a path. A line segment from the start point to the last point of the path is added. 142 * 143 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 144 * @param OH_Drawing_Path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 145 * @since 8 146 * @version 1.0 147 */ 148 void OH_Drawing_PathClose(OH_Drawing_Path*); 149 150 /** 151 * @brief Resets path data. 152 * 153 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 154 * @param OH_Drawing_Path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 155 * @since 8 156 * @version 1.0 157 */ 158 void OH_Drawing_PathReset(OH_Drawing_Path*); 159 160 #ifdef __cplusplus 161 } 162 #endif 163 /** @} */ 164 #endif 165