• 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_H
17 #define C_INCLUDE_DRAWING_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_canvas.h
33  *
34  * @brief Declares functions related to the <b>canvas</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_Canvas</b> object.
48  *
49  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
50  * @return Returns the pointer to the <b>OH_Drawing_Canvas</b> object created.
51  * @since 8
52  * @version 1.0
53  */
54 OH_Drawing_Canvas* OH_Drawing_CanvasCreate(void);
55 
56 /**
57  * @brief Destroys an <b>OH_Drawing_Canvas</b> object and reclaims the memory occupied by the object.
58  *
59  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
60  * @param OH_Drawing_Canvas Indicates the pointer to an <b>OH_Drawing_Canvas</b> object.
61  * @since 8
62  * @version 1.0
63  */
64 void OH_Drawing_CanvasDestroy(OH_Drawing_Canvas*);
65 
66 /**
67  * @brief Binds a bitmap to a canvas so that the content drawn on the canvas
68  * is output to the bitmap (this process is called CPU rendering).
69  *
70  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
71  * @param OH_Drawing_Canvas Indicates the pointer to an <b>OH_Drawing_Canvas</b> object.
72  * @param OH_Drawing_Bitmap Indicates the pointer to an <b>OH_Drawing_Bitmap</b> object.
73  * @since 8
74  * @version 1.0
75  */
76 void OH_Drawing_CanvasBind(OH_Drawing_Canvas*, OH_Drawing_Bitmap*);
77 
78 /**
79  * @brief Attaches a pen to a canvas so that the canvas will use the style and color of the pen to outline a shape.
80  *
81  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
82  * @param OH_Drawing_Canvas Indicates the pointer to an <b>OH_Drawing_Canvas</b> object.
83  * @param OH_Drawing_Pen Indicates the pointer to an <b>OH_Drawing_Pen</b> object.
84  * @since 8
85  * @version 1.0
86  */
87 void OH_Drawing_CanvasAttachPen(OH_Drawing_Canvas*, const OH_Drawing_Pen*);
88 
89 /**
90  * @brief Detaches the pen from a canvas so that the canvas will not use the style
91  * and color of the pen to outline a shape.
92  *
93  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
94  * @param OH_Drawing_Canvas Indicates the pointer to an <b>OH_Drawing_Canvas</b> object.
95  * @since 8
96  * @version 1.0
97  */
98 void OH_Drawing_CanvasDetachPen(OH_Drawing_Canvas*);
99 
100 /**
101  * @brief Attaches a brush to a canvas so that the canvas will use the style and color of the brush to fill in a shape.
102  *
103  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
104  * @param OH_Drawing_Canvas Indicates the pointer to an <b>OH_Drawing_Canvas</b> object.
105  * @param OH_Drawing_Brush Indicates the pointer to an <b>OH_Drawing_Brush</b> object.
106  * @since 8
107  * @version 1.0
108  */
109 void OH_Drawing_CanvasAttachBrush(OH_Drawing_Canvas*, const OH_Drawing_Brush*);
110 
111 /**
112  * @brief Detaches the brush from a canvas so that the canvas will not use the style
113  * and color of the brush to fill in a shape.
114  *
115  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
116  * @param OH_Drawing_Canvas Indicates the pointer to an <b>OH_Drawing_Canvas</b> object.
117  * @since 8
118  * @version 1.0
119  */
120 void OH_Drawing_CanvasDetachBrush(OH_Drawing_Canvas*);
121 
122 /**
123  * @brief Saves the current canvas status (canvas matrix) to the top of the stack.
124  *
125  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
126  * @param OH_Drawing_Canvas Indicates the pointer to an <b>OH_Drawing_Canvas</b> object.
127  * @since 8
128  * @version 1.0
129  */
130 void OH_Drawing_CanvasSave(OH_Drawing_Canvas*);
131 
132 /**
133  * @brief Restores the canvas status (canvas matrix) saved on the top of the stack.
134  *
135  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
136  * @param OH_Drawing_Canvas Indicates the pointer to an <b>OH_Drawing_Canvas</b> object.
137  * @since 8
138  * @version 1.0
139  */
140 void OH_Drawing_CanvasRestore(OH_Drawing_Canvas*);
141 
142 /**
143  * @brief Draws a line segment.
144  *
145  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
146  * @param OH_Drawing_Canvas Indicates the pointer to an <b>OH_Drawing_Canvas</b> object.
147  * @param x1 Indicates the x coordinate of the start point of the line segment.
148  * @param y1 Indicates the y coordinate of the start point of the line segment.
149  * @param x2 Indicates the x coordinate of the end point of the line segment.
150  * @param y2 Indicates the y coordinate of the end point of the line segment.
151  * @since 8
152  * @version 1.0
153  */
154 void OH_Drawing_CanvasDrawLine(OH_Drawing_Canvas*, float x1, float y1, float x2, float y2);
155 
156 /**
157  * @brief Draws a path.
158  *
159  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
160  * @param OH_Drawing_Canvas Indicates the pointer to an <b>OH_Drawing_Canvas</b> object.
161  * @param OH_Drawing_Path Indicates the pointer to an <b>OH_Drawing_Path</b> object.
162  * @since 8
163  * @version 1.0
164  */
165 void OH_Drawing_CanvasDrawPath(OH_Drawing_Canvas*, const OH_Drawing_Path*);
166 
167 /**
168  * @brief Clears a canvas by using a specified color.
169  *
170  * @syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
171  * @param OH_Drawing_Canvas Indicates the pointer to an <b>OH_Drawing_Canvas</b> object.
172  * @param color Indicates the color, which is a 32-bit (ARGB) variable.
173  * @since 8
174  * @version 1.0
175  */
176 void OH_Drawing_CanvasClear(OH_Drawing_Canvas*, uint32_t color);
177 
178 #ifdef __cplusplus
179 }
180 #endif
181 /** @} */
182 #endif
183