• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2023 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_PEN_H
17 #define C_INCLUDE_DRAWING_PEN_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_pen.h
33  *
34  * @brief Declares functions related to the <b>pen</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_Pen</b> object.
48  *
49  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
50  * @return Returns the pointer to the <b>OH_Drawing_Pen</b> object created.
51  * @since 8
52  * @version 1.0
53  */
54 OH_Drawing_Pen* OH_Drawing_PenCreate(void);
55 
56 /**
57  * @brief Destroys an <b>OH_Drawing_Pen</b> object and reclaims the memory occupied by the object.
58  *
59  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
60  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
61  * @since 8
62  * @version 1.0
63  */
64 void OH_Drawing_PenDestroy(OH_Drawing_Pen*);
65 
66 /**
67  * @brief Checks whether anti-aliasing is enabled for a pen. If anti-aliasing is enabled,
68  * edges will be drawn with partial transparency.
69  *
70  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
71  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
72  * @return Returns <b>true</b> if anti-aliasing is enabled; returns <b>false</b> otherwise.
73  * @since 8
74  * @version 1.0
75  */
76 bool OH_Drawing_PenIsAntiAlias(const OH_Drawing_Pen*);
77 
78 /**
79  * @brief Enables or disables anti-aliasing for a pen. If anti-aliasing is enabled,
80  * edges will be drawn with partial transparency.
81  *
82  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
83  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
84  * @param bool Specifies whether to enable anti-aliasing. The value <b>true</b> means
85  *             to enable anti-aliasing, and <b>false</b> means the opposite.
86  * @since 8
87  * @version 1.0
88  */
89 void OH_Drawing_PenSetAntiAlias(OH_Drawing_Pen*, bool);
90 
91 /**
92  * @brief Obtains the color of a pen. The color is used by the pen to outline a shape.
93  *
94  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
95  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
96  * @return Returns a 32-bit (ARGB) variable that describes the color.
97  * @since 8
98  * @version 1.0
99  */
100 uint32_t OH_Drawing_PenGetColor(const OH_Drawing_Pen*);
101 
102 /**
103  * @brief Sets the color for a pen. The color is used by the pen to outline a shape.
104  *
105  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
106  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
107  * @param color Indicates the color to set, which is a 32-bit (ARGB) variable.
108  * @since 8
109  * @version 1.0
110  */
111 void OH_Drawing_PenSetColor(OH_Drawing_Pen*, uint32_t color);
112 
113 /**
114  * @brief Obtains the alpha of a pen. The alpha is used by the pen to outline a shape.
115  *
116  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
117  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
118  * @return Returns a 8-bit variable that describes the alpha.
119  * @since 11
120  * @version 1.0
121  */
122 uint8_t OH_Drawing_PenGetAlpha(const OH_Drawing_Pen*);
123 
124 /**
125  * @brief Sets the alpha for a pen. The alpha is used by the pen to outline a shape.
126  *
127  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
128  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
129  * @param alpha Indicates the alpha to set, which is a 8-bit variable.
130  * @since 11
131  * @version 1.0
132  */
133 void OH_Drawing_PenSetAlpha(OH_Drawing_Pen*, uint8_t alpha);
134 
135 /**
136  * @brief Obtains the thickness of a pen. This thickness determines the width of the outline of a shape.
137  *
138  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
139  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
140  * @return Returns the thickness.
141  * @since 8
142  * @version 1.0
143  */
144 float OH_Drawing_PenGetWidth(const OH_Drawing_Pen*);
145 
146 /**
147  * @brief Sets the thickness for a pen. This thickness determines the width of the outline of a shape.
148  *
149  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
150  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
151  * @param width Indicates the thickness to set, which is a variable.
152  * @since 8
153  * @version 1.0
154  */
155 void OH_Drawing_PenSetWidth(OH_Drawing_Pen*, float width);
156 
157 /**
158  * @brief Obtains the stroke miter limit of a polyline drawn by a pen.
159  *
160  * When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded,
161  * and a mitered corner is displayed if the miter limit is not exceeded.
162  *
163  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
164  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
165  * @return Returns the miter limit.
166  * @since 8
167  * @version 1.0
168  */
169 float OH_Drawing_PenGetMiterLimit(const OH_Drawing_Pen*);
170 
171 /**
172  * @brief Sets the stroke miter limit for a polyline drawn by a pen.
173  *
174  * When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded,
175  * and a mitered corner is displayed if the miter limit is not exceeded.
176  *
177  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
178  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
179  * @param miter Indicates a variable that describes the miter limit.
180  * @since 8
181  * @version 1.0
182  */
183 void OH_Drawing_PenSetMiterLimit(OH_Drawing_Pen*, float miter);
184 
185 /**
186  * @brief Enumerates line cap styles of a pen. The line cap style defines
187  * the style of both ends of a line segment drawn by the pen.
188  *
189  * @since 8
190  * @version 1.0
191  */
192 typedef enum {
193     /**
194      * There is no cap style. Both ends of the line segment are cut off square.
195      */
196     LINE_FLAT_CAP,
197     /**
198      * Square cap style. Both ends have a square, the height of which
199      * is half of the width of the line segment, with the same width.
200      */
201     LINE_SQUARE_CAP,
202     /**
203      * Round cap style. Both ends have a semicircle centered, the diameter of which
204      * is the same as the width of the line segment.
205      */
206     LINE_ROUND_CAP
207 } OH_Drawing_PenLineCapStyle;
208 
209 /**
210  * @brief Obtains the line cap style of a pen.
211  *
212  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
213  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
214  * @return Returns the line cap style.
215  * @since 8
216  * @version 1.0
217  */
218 OH_Drawing_PenLineCapStyle OH_Drawing_PenGetCap(const OH_Drawing_Pen*);
219 
220 /**
221  * @brief Sets the line cap style for a pen.
222  *
223  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
224  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
225  * @param OH_Drawing_PenLineCapStyle Indicates a variable that describes the line cap style.
226  * @since 8
227  * @version 1.0
228  */
229 void OH_Drawing_PenSetCap(OH_Drawing_Pen*, OH_Drawing_PenLineCapStyle);
230 
231 /**
232  * @brief Enumerates pen line join styles. The line join style defines
233  * the shape of the joints of a polyline segment drawn by the pen.
234  *
235  * @since 8
236  * @version 1.0
237  */
238 typedef enum {
239     /**
240      * Mitered corner. If the angle of a polyline is small, its miter length may be inappropriate.
241      * In this case, you need to use the miter limit to limit the miter length.
242      */
243     LINE_MITER_JOIN,
244     /** Round corner. */
245     LINE_ROUND_JOIN,
246     /** Beveled corner. */
247     LINE_BEVEL_JOIN
248 } OH_Drawing_PenLineJoinStyle;
249 
250 /**
251  * @brief Obtains the line join style of a pen.
252  *
253  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
254  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
255  * @return Returns the line join style.
256  * @since 8
257  * @version 1.0
258  */
259 OH_Drawing_PenLineJoinStyle OH_Drawing_PenGetJoin(const OH_Drawing_Pen*);
260 
261 /**
262  * @brief Sets the line join style for a pen.
263  *
264  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
265  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
266  * @param OH_Drawing_PenLineJoinStyle Indicates a variable that describes the line join style.
267  * @since 8
268  * @version 1.0
269  */
270 void OH_Drawing_PenSetJoin(OH_Drawing_Pen*, OH_Drawing_PenLineJoinStyle);
271 
272 /**
273  * @brief Sets the shaderEffect for a pen.
274  *
275  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
276  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
277  * @param OH_Drawing_ShaderEffect Indicates the pointer to an <b>OH_Drawing_ShaderEffect</b> object.
278  * @since 11
279  * @version 1.0
280  */
281 void OH_Drawing_PenSetShaderEffect(OH_Drawing_Pen*, OH_Drawing_ShaderEffect*);
282 
283 /**
284  * @brief Sets the filter for a pen.
285  *
286  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
287  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
288  * @param OH_Drawing_Filter Indicates the pointer to an <b>OH_Drawing_Filter</b> object.
289  * @since 11
290  * @version 1.0
291  */
292 void OH_Drawing_PenSetFilter(OH_Drawing_Pen*, OH_Drawing_Filter*);
293 
294 /**
295  * @brief Sets a blender that implements the specified blendmode enum for a pen.
296  *
297  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
298  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
299  * @param OH_Drawing_BlendMode Indicates the blend mode.
300  * @since 12
301  * @version 1.0
302  */
303 void OH_Drawing_PenSetBlendMode(OH_Drawing_Pen*, OH_Drawing_BlendMode);
304 
305 #ifdef __cplusplus
306 }
307 #endif
308 /** @} */
309 #endif
310