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