1 /* 2 * Copyright (c) 2021-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 #ifndef C_INCLUDE_DRAWING_BRUSH_H 17 #define C_INCLUDE_DRAWING_BRUSH_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_brush.h 33 * 34 * @brief Declares functions related to the <b>brush</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_Brush</b> object. 48 * 49 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 50 * @return Returns the pointer to the <b>OH_Drawing_Brush</b> object created. 51 * @since 8 52 * @version 1.0 53 */ 54 OH_Drawing_Brush* OH_Drawing_BrushCreate(void); 55 56 /** 57 * @brief Creates an <b>OH_Drawing_Brush</b> copy object. 58 * 59 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 60 * @param OH_Drawing_Brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object. 61 * @return Returns the pointer to the <b>OH_Drawing_Brush</b> object created. 62 * @since 12 63 * @version 1.0 64 */ 65 OH_Drawing_Brush* OH_Drawing_BrushCopy(OH_Drawing_Brush*); 66 67 /** 68 * @brief Destroys an <b>OH_Drawing_Brush</b> object and reclaims the memory occupied by the object. 69 * 70 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 71 * @param OH_Drawing_Brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object. 72 * @since 8 73 * @version 1.0 74 */ 75 void OH_Drawing_BrushDestroy(OH_Drawing_Brush*); 76 77 /** 78 * @brief Checks whether anti-aliasing is enabled for a brush. If anti-aliasing is enabled, 79 * edges will be drawn with partial transparency. 80 * 81 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 82 * @param OH_Drawing_Brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object. 83 * @return Returns <b>true</b> if anti-aliasing is enabled; returns <b>false</b> otherwise. 84 * @since 8 85 * @version 1.0 86 */ 87 bool OH_Drawing_BrushIsAntiAlias(const OH_Drawing_Brush*); 88 89 /** 90 * @brief Enables or disables anti-aliasing for a brush. If anti-aliasing is enabled, 91 * edges will be drawn with partial transparency. 92 * 93 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 94 * @param OH_Drawing_Brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object. 95 * @param bool Specifies whether to enable anti-aliasing. The value <b>true</b> means 96 * to enable anti-aliasing, and <b>false</b> means the opposite. 97 * @since 8 98 * @version 1.0 99 */ 100 void OH_Drawing_BrushSetAntiAlias(OH_Drawing_Brush*, bool); 101 102 /** 103 * @brief Obtains the color of a brush. The color is used by the brush to fill in a shape. 104 * 105 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 106 * @param OH_Drawing_Brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object. 107 * @return Returns a 32-bit (ARGB) variable that describes the color. 108 * @since 8 109 * @version 1.0 110 */ 111 uint32_t OH_Drawing_BrushGetColor(const OH_Drawing_Brush*); 112 113 /** 114 * @brief Sets the color for a brush. The color will be used by the brush to fill in a shape. 115 * 116 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 117 * @param OH_Drawing_Brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object. 118 * @param color Indicates the color to set, which is a 32-bit (ARGB) variable. 119 * @since 8 120 * @version 1.0 121 */ 122 void OH_Drawing_BrushSetColor(OH_Drawing_Brush*, uint32_t color); 123 124 /** 125 * @brief Obtains the alpha of a brush. The alpha is used by the brush to fill in a shape. 126 * 127 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 128 * @param OH_Drawing_Brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object. 129 * @return Returns a 8-bit variable that describes the alpha. 130 * @since 11 131 * @version 1.0 132 */ 133 uint8_t OH_Drawing_BrushGetAlpha(const OH_Drawing_Brush*); 134 135 /** 136 * @brief Sets the alpha for a brush. The alpha will be used by the brush to fill in a shape. 137 * 138 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 139 * @param OH_Drawing_Brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object. 140 * @param alpha Indicates the alpha to set, which is a 8-bit variable. 141 * @since 11 142 * @version 1.0 143 */ 144 void OH_Drawing_BrushSetAlpha(OH_Drawing_Brush*, uint8_t alpha); 145 146 /** 147 * @brief Sets the shaderEffect for a brush. 148 * 149 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 150 * @param OH_Drawing_Brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object. 151 * @param OH_Drawing_ShaderEffect Indicates the pointer to an <b>OH_Drawing_ShaderEffect</b> object. 152 * @since 11 153 * @version 1.0 154 */ 155 void OH_Drawing_BrushSetShaderEffect(OH_Drawing_Brush*, OH_Drawing_ShaderEffect*); 156 157 /** 158 * @brief Sets the shadowLayer for a brush. 159 * 160 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 161 * @param OH_Drawing_Brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object. 162 * @param OH_Drawing_ShadowLayer Indicates the pointer to an <b>OH_Drawing_ShadowLayer</b> object. 163 * @since 12 164 * @version 1.0 165 */ 166 void OH_Drawing_BrushSetShadowLayer(OH_Drawing_Brush*, OH_Drawing_ShadowLayer*); 167 168 /** 169 * @brief Sets the filter for a brush. 170 * 171 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 172 * @param OH_Drawing_Brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object. 173 * @param OH_Drawing_Filter Indicates the pointer to an <b>OH_Drawing_Filter</b> object. 174 * @since 11 175 * @version 1.0 176 */ 177 void OH_Drawing_BrushSetFilter(OH_Drawing_Brush*, OH_Drawing_Filter*); 178 179 /** 180 * @brief Gets the filter from a brush. 181 * 182 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 183 * @param OH_Drawing_Brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object. 184 * @param OH_Drawing_Filter Indicates the pointer to an <b>OH_Drawing_Filter</b> object. 185 * @since 12 186 * @version 1.0 187 */ 188 void OH_Drawing_BrushGetFilter(OH_Drawing_Brush*, OH_Drawing_Filter*); 189 190 /** 191 * @brief Sets a blender that implements the specified blendmode enum for a brush. 192 * 193 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 194 * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Brush</b> object. 195 * @param OH_Drawing_BlendMode Indicates the blend mode. 196 * @since 12 197 * @version 1.0 198 */ 199 void OH_Drawing_BrushSetBlendMode(OH_Drawing_Brush*, OH_Drawing_BlendMode); 200 201 /** 202 * @brief Resets all brush contents to their initial values. 203 * 204 * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing 205 * @param OH_Drawing_Brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object. 206 * @since 12 207 * @version 1.0 208 */ 209 void OH_Drawing_BrushReset(OH_Drawing_Brush*); 210 211 #ifdef __cplusplus 212 } 213 #endif 214 /** @} */ 215 #endif 216