• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2021-2022 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 thickness of a pen. This thickness determines the width of the outline of 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 the thickness.
119  * @since 8
120  * @version 1.0
121  */
122 float OH_Drawing_PenGetWidth(const OH_Drawing_Pen*);
123 
124 /**
125  * @brief Sets the thickness for a pen. This thickness determines the width of the outline of 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 width Indicates the thickness to set, which is a variable.
130  * @since 8
131  * @version 1.0
132  */
133 void OH_Drawing_PenSetWidth(OH_Drawing_Pen*, float width);
134 
135 /**
136  * @brief Obtains the stroke miter limit of a polyline drawn by a pen.
137  *
138  * When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded,
139  * and a mitered corner is displayed if the miter limit is not exceeded.
140  *
141  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
142  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
143  * @return Returns the miter limit.
144  * @since 8
145  * @version 1.0
146  */
147 float OH_Drawing_PenGetMiterLimit(const OH_Drawing_Pen*);
148 
149 /**
150  * @brief Sets the stroke miter limit for a polyline drawn by a pen.
151  *
152  * When the corner type is bevel, a beveled corner is displayed if the miter limit is exceeded,
153  * and a mitered corner is displayed if the miter limit is not exceeded.
154  *
155  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
156  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
157  * @param miter Indicates a variable that describes the miter limit.
158  * @since 8
159  * @version 1.0
160  */
161 void OH_Drawing_PenSetMiterLimit(OH_Drawing_Pen*, float miter);
162 
163 /**
164  * @brief Enumerates line cap styles of a pen. The line cap style defines
165  * the style of both ends of a line segment drawn by the pen.
166  *
167  * @since 8
168  * @version 1.0
169  */
170 typedef enum {
171     /**
172      * There is no cap style. Both ends of the line segment are cut off square.
173      */
174     LINE_FLAT_CAP,
175     /**
176      * Square cap style. Both ends have a square, the height of which
177      * is half of the width of the line segment, with the same width.
178      */
179     LINE_SQUARE_CAP,
180     /**
181      * Round cap style. Both ends have a semicircle centered, the diameter of which
182      * is the same as the width of the line segment.
183      */
184     LINE_ROUND_CAP
185 } OH_Drawing_PenLineCapStyle;
186 
187 /**
188  * @brief Obtains the line cap style of a pen.
189  *
190  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
191  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
192  * @return Returns the line cap style.
193  * @since 8
194  * @version 1.0
195  */
196 OH_Drawing_PenLineCapStyle OH_Drawing_PenGetCap(const OH_Drawing_Pen*);
197 
198 /**
199  * @brief Sets the line cap style for a pen.
200  *
201  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
202  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
203  * @param OH_Drawing_PenLineCapStyle Indicates a variable that describes the line cap style.
204  * @since 8
205  * @version 1.0
206  */
207 void OH_Drawing_PenSetCap(OH_Drawing_Pen*, OH_Drawing_PenLineCapStyle);
208 
209 /**
210  * @brief Enumerates pen line join styles. The line join style defines
211  * the shape of the joints of a polyline segment drawn by the pen.
212  *
213  * @since 8
214  * @version 1.0
215  */
216 typedef enum {
217     /**
218      * Mitered corner. If the angle of a polyline is small, its miter length may be inappropriate.
219      * In this case, you need to use the miter limit to limit the miter length.
220      */
221     LINE_MITER_JOIN,
222     /** Round corner. */
223     LINE_ROUND_JOIN,
224     /** Beveled corner. */
225     LINE_BEVEL_JOIN
226 } OH_Drawing_PenLineJoinStyle;
227 
228 /**
229  * @brief Obtains the line join style of a pen.
230  *
231  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
232  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
233  * @return Returns the line join style.
234  * @since 8
235  * @version 1.0
236  */
237 OH_Drawing_PenLineJoinStyle OH_Drawing_PenGetJoin(const OH_Drawing_Pen*);
238 
239 /**
240  * @brief Sets the line join style for a pen.
241  *
242  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
243  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
244  * @param OH_Drawing_PenLineJoinStyle Indicates a variable that describes the line join style.
245  * @since 8
246  * @version 1.0
247  */
248 void OH_Drawing_PenSetJoin(OH_Drawing_Pen*, OH_Drawing_PenLineJoinStyle);
249 
250 #ifdef __cplusplus
251 }
252 #endif
253 /** @} */
254 #endif
255