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