1 /* 2 * Copyright (c) 2023-2024 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 /** 17 * @addtogroup Drawing 18 * @{ 19 * 20 * @brief Provides functions such as 2D graphics rendering, text drawing, and image display. 21 * 22 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 23 * 24 * @since 12 25 * @version 1.0 26 */ 27 28 /** 29 * @file drawing_path_effect.h 30 * 31 * @brief Declares functions related to the <b>pathEffect</b> object in the drawing module. 32 * 33 * @kit ArkGraphics2D 34 * @library libnative_drawing.so 35 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 36 * @since 12 37 * @version 1.0 38 */ 39 40 #ifndef C_INCLUDE_DRAWING_PATH_EFFECT_H 41 #define C_INCLUDE_DRAWING_PATH_EFFECT_H 42 43 #include "drawing_types.h" 44 45 #ifdef __cplusplus 46 extern "C" { 47 #endif 48 49 /** 50 * @brief Enumerate path dash style. 51 * 52 * @since 18 53 * @version 1.0 54 */ 55 typedef enum { 56 /** Indicates translation effect. */ 57 DRAWING_PATH_DASH_STYLE_TRANSLATE, 58 /** Indicates rotation effect. */ 59 DRAWING_PATH_DASH_STYLE_ROTATE, 60 /** Indicates morph effect. */ 61 DRAWING_PATH_DASH_STYLE_MORPH, 62 } OH_Drawing_PathDashStyle; 63 64 /** 65 * @brief Creates an <b>OH_Drawing_PathEffect</b> object that is a combination of paths, 66 * applying the inner path effect first and then the outer path effect. 67 * 68 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 69 * @param outer Indicates an <b>OH_Drawing_PathEffect</b> object 70 * @param inner Indicates an <b>OH_Drawing_PathEffect</b> object 71 * @return Returns the pointer to the <b>OH_Drawing_PathEffect</b> object created. 72 * @since 18 73 * @version 1.0 74 */ 75 OH_Drawing_PathEffect* OH_Drawing_CreateComposePathEffect(OH_Drawing_PathEffect* outer, OH_Drawing_PathEffect* inner); 76 77 /** 78 * @brief Creates an <b>OH_Drawing_PathEffect</b> object 79 * that turns the included angle of the path into a fillet of a specified radius. 80 * 81 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 82 * @param radius Indicates the degree of curvature of the arc, the radius must be greater than zero. 83 * @return Returns the pointer to the <b>OH_Drawing_PathEffect</b> object created. 84 * If nullptr is returned, the creation fails. 85 * The possible cause of the failure is radius is zero or less. 86 * @since 18 87 * @version 1.0 88 */ 89 OH_Drawing_PathEffect* OH_Drawing_CreateCornerPathEffect(float radius); 90 91 /** 92 * @brief Creates an <b>OH_Drawing_PathEffect</b> object. 93 * 94 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 95 * @param intervals Indicates a array which contain an even number of entries. 96 * @param count Indicates the number of elements of the intervals array. 97 * @param phase Indicates the offset into intervals array. 98 * @return Returns the pointer to the <b>OH_Drawing_PathEffect</b> object created. 99 * @since 12 100 * @version 1.0 101 */ 102 OH_Drawing_PathEffect* OH_Drawing_CreateDashPathEffect(float* intervals, int count, float phase); 103 104 /** 105 * @brief Creates an <b>OH_Drawing_PathEffect</b> object 106 * that breaks the path and creates an irregular distribution on the path. 107 * 108 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 109 * @param segLength Indicates the maximum segment length of the path. 110 * @param deviation Indicates the deviation during drawing. 111 * @return Returns the pointer to the <b>OH_Drawing_PathEffect</b> object created. 112 * @since 18 113 * @version 1.0 114 */ 115 OH_Drawing_PathEffect* OH_Drawing_CreateDiscretePathEffect(float segLength, float deviation); 116 117 /** 118 * @brief Creates an <b>OH_Drawing_PathEffect</b> object and sets the path effect to a dash effect. 119 * 120 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 121 * @param path Indicates the pointer to an <b>OH_Drawing_Path</b> object. 122 * @param advance Indicates the distance between the dashed segments. 123 * @param phase Indicates the offset into intervals array. 124 * @param type Indicates the type of the path dash effect. 125 * @return Returns the pointer to the <b>OH_Drawing_PathEffect</b> object created. 126 * If nullptr is returned, the creation fails. 127 * The possible cause of the failure is advance and phase are zero or less. 128 * @since 18 129 * @version 1.0 130 */ 131 OH_Drawing_PathEffect* OH_Drawing_CreatePathDashEffect(const OH_Drawing_Path* path, float advance, float phase, 132 OH_Drawing_PathDashStyle type); 133 134 /** 135 * @brief Creates an <b>OH_Drawing_PathEffect</b> object by overlaying two path effects. 136 * 137 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 138 * @param firstPathEffect Indicates the pointer to an <b>OH_Drawing_PathEffect</b> object. 139 * @param secondPathEffect Indicates the pointer to an <b>OH_Drawing_PathEffect</b> object. 140 * @return Returns the pointer to the <b>OH_Drawing_PathEffect</b> object created. 141 * @since 18 142 * @version 1.0 143 */ 144 OH_Drawing_PathEffect* OH_Drawing_CreateSumPathEffect(OH_Drawing_PathEffect* firstPathEffect, 145 OH_Drawing_PathEffect* secondPathEffect); 146 147 /** 148 * @brief Destroys an <b>OH_Drawing_PathEffect</b> object and reclaims the memory occupied by the object. 149 * 150 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 151 * @param pathEffect Indicates the pointer to an <b>OH_Drawing_PathEffect</b> object. 152 * @since 12 153 * @version 1.0 154 */ 155 void OH_Drawing_PathEffectDestroy(OH_Drawing_PathEffect* pathEffect); 156 157 #ifdef __cplusplus 158 } 159 #endif 160 /** @} */ 161 #endif 162