1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
#![allow(non_camel_case_types)]
#![allow(non_snake_case)]
use crate::drawing::types::{OH_Drawing_Matrix, OH_Drawing_Point2D, OH_Drawing_Rect};
impl OH_Drawing_ScaleToFit {
/// Scales in x and y to fill destination rect.
pub const SCALE_TO_FIT_FILL: OH_Drawing_ScaleToFit = OH_Drawing_ScaleToFit(0);
}
impl OH_Drawing_ScaleToFit {
/// Scales and aligns to left and top.
pub const SCALE_TO_FIT_START: OH_Drawing_ScaleToFit = OH_Drawing_ScaleToFit(1);
}
impl OH_Drawing_ScaleToFit {
/// Scales and aligns to center.
pub const SCALE_TO_FIT_CENTER: OH_Drawing_ScaleToFit = OH_Drawing_ScaleToFit(2);
}
impl OH_Drawing_ScaleToFit {
/// Scales and aligns to right and bottom.
pub const SCALE_TO_FIT_END: OH_Drawing_ScaleToFit = OH_Drawing_ScaleToFit(3);
}
#[repr(transparent)]
/** @brief Enumerates of scale to fit flags, how matrix is constructed to map one rect to another.
@since 12
@version 1.0*/
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
pub struct OH_Drawing_ScaleToFit(pub ::core::ffi::c_uint);
extern "C" {
/** @brief Creates an <b>OH_Drawing_Matrix</b> object with rotation. Sets matrix to
rotate by degrees about a pivot point at (px, py).
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param deg angle of axes relative to upright axes
@param x pivot on x-axis.
@param y pivot on y-axis.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixCreateRotation(deg: f32, x: f32, y: f32) -> *mut OH_Drawing_Matrix;
/** @brief Creates an <b>OH_Drawing_Matrix</b> object with scale. Sets matrix to scale
by sx and sy, about a pivot point at (px, py).
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param sx horizontal scale factor.
@param sy vertical scale factor.
@param px pivot on x-axis.
@param py pivot on y-axis.
@return Returns the pointer to the <b>OH_Drawing_Matrix</b> object created.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixCreateScale(
sx: f32,
sy: f32,
px: f32,
py: f32,
) -> *mut OH_Drawing_Matrix;
/** @brief Creates an <b>OH_Drawing_Matrix</b> object with translation.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param dx horizontal translation.
@param dy vertical translation.
@return Returns the pointer to the <b>OH_Drawing_Matrix</b> object created.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixCreateTranslation(dx: f32, dy: f32) -> *mut OH_Drawing_Matrix;
/** @brief Sets matrix to scale and translate src rect to dst rect.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param src Indicates the pointer to an <b>OH_Drawing_Rect</b> object rect to map from.
@param dst Indicates the pointer to an <b>OH_Drawing_Rect</b> object rect to map to.
@param stf Scales to fit enum method.
@return Returns true if dst is empty, and sets matrix to:
| 0 0 0 |
| 0 0 0 |
| 0 0 1 |
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixSetRectToRect(
arg1: *mut OH_Drawing_Matrix,
src: *const OH_Drawing_Rect,
dst: *const OH_Drawing_Rect,
stf: OH_Drawing_ScaleToFit,
) -> bool;
/** @brief Sets matrix to matrix multiplied by matrix constructed from rotating by degrees
about pivot point(px, py), positive degrees rotates clockwise.
Given:
| A B C | | c -s dx |
Matrix = | D E F |, R(degrees, px, py) = | s c dy |
| G H I | | 0 0 1 |
where:
c = cos(degrees)
s = sin(degrees)
dx = s * py + (1 - c) * px
dy = -s * px + (1 - c) * py
sets Matrix to:
| A B C | | c -s dx | | Ac+Bs -As+Bc A*dx+B*dy+C |
Matrix * R(degrees, px, py) = | D E F | | s c dy | = | Dc+Es -Ds+Ec D*dx+E*dy+F |
| G H I | | 0 0 1 | | Gc+Hs -Gs+Hc G*dx+H*dy+I |
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param degree Indicates the angle of axes relative to upright axes.
@param px Indicates the pivot on x-axis.
@param py Indicates the pivot on y-axis.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixPreRotate(arg1: *mut OH_Drawing_Matrix, degree: f32, px: f32, py: f32);
/** @brief Sets matrix to forward scale by sx and sy, about a pivot point at (px, py).
Given:
| A B C | | sx 0 dx |
Matrix =| D E F |, S(sx, sy, px, py) = | 0 sy dy |
| G H I | | 0 0 1 |
where:
dx = px - sx * px
dy = py - sy * py
sets Matrix to:
| A B C | | sx 0 dx | | A*sx B*sy A*dx+B*dy+C |
Matrix * S(sx, sy, px, py) = | D E F | | 0 sy dy | = | D*sx E*sy D*dx+E*dy+F |
| G H I | | 0 0 1 | | G*sx H*sy G*dx+H*dy+I |
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param sx Horizontal scale factor.
@param sy Vertical scale factor.
@param px Pivot on x-axis.
@param py Pivot on y-axis.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixPreScale(
arg1: *mut OH_Drawing_Matrix,
sx: f32,
sy: f32,
px: f32,
py: f32,
);
/** @brief Sets forward matrix to translate by dx and dy.
Given:
| A B C | | 1 0 dx |
Matrix = | D E F |, T(dx, dy) = | 0 1 dy |
| G H I | | 0 0 1 |
sets Matrix to:
| A B C | | 1 0 dx | | A B A*dx+B*dy+C |
Matrix * T(dx, dy) = | D E F | | 0 1 dy | = | D E D*dx+E*dy+F |
| G H I | | 0 0 1 | | G H G*dx+H*dy+I |
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param dx Indicates the horizontal translation.
@param dy Indicates the vertical translation.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixPreTranslate(arg1: *mut OH_Drawing_Matrix, dx: f32, dy: f32);
/** @brief Sets matrix to matrix constructed from rotating by degrees about pivot point(px, py),
multiplied by matrix, positive degrees rotates clockwise.
Given:
| J K L | | c -s dx |
Matrix = | M N O |, R(degrees, px, py) = | s c dy |
| P Q R | | 0 0 1 |
where:
c = cos(degrees)
s = sin(degrees)
dx = s * py + (1 - c) * px
dy = -s * px + (1 - c) * py
sets Matrix to:
|c -s dx| |J K L| |cJ-sM+dx*P cK-sN+dx*Q cL-sO+dx+R|
R(degrees, px, py) * Matrix = |s c dy| |M N O| = |sJ+cM+dy*P sK+cN+dy*Q sL+cO+dy*R|
|0 0 1| |P Q R| | P Q R|
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param degree Indicates the angle of axes relative to upright axes.
@param px Indicates the pivot on x-axis.
@param py Indicates the pivot on y-axis.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixPostRotate(arg1: *mut OH_Drawing_Matrix, degree: f32, px: f32, py: f32);
/** @brief Sets matrix to backward scale by sx and sy, about a pivot point at (px, py).
Given:
| J K L | | sx 0 dx |
Matrix = | M N O |, S(sx, sy, px, py) = | 0 sy dy |
| P Q R | | 0 0 1 |
where:
dx = px - sx * px
dy = py - sy * py
sets Matrix to:
| sx 0 dx | | J K L | | sx*J+dx*P sx*K+dx*Q sx*L+dx+R |
S(sx, sy, px, py) * Matrix = | 0 sy dy | | M N O | = | sy*M+dy*P sy*N+dy*Q sy*O+dy*R |
| 0 0 1 | | P Q R | | P Q R |
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param sx Horizontal scale factor.
@param sy Vertical scale factor.
@param px Pivot on x-axis.
@param py Pivot on y-axis.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixPostScale(
arg1: *mut OH_Drawing_Matrix,
sx: f32,
sy: f32,
px: f32,
py: f32,
);
/** @brief Sets backward matrix to translate by (dx, dy).
Given:
| J K L | | 1 0 dx |
Matrix = | M N O |, T(dx, dy) = | 0 1 dy |
| P Q R | | 0 0 1 |
sets Matrix to:
| 1 0 dx | | J K L | | J+dx*P K+dx*Q L+dx*R |
T(dx, dy) * Matrix = | 0 1 dy | | M N O | = | M+dy*P N+dy*Q O+dy*R |
| 0 0 1 | | P Q R | | P Q R |
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param dx Indicates the horizontal translation.
@param dy Indicates the vertical translation.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixPostTranslate(arg1: *mut OH_Drawing_Matrix, dx: f32, dy: f32);
/** @brief Reset matrix to identity, which has no effect on mapped point, sets matrix to:
| 1 0 0 |
| 0 1 0 |
| 0 0 1 |
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixReset(arg1: *mut OH_Drawing_Matrix);
/** @brief Sets matrix total to matrix a multiplied by matrix b.
Given:
| A B C | | J K L |
a = | D E F |, b = | M N O |
| G H I | | P Q R |
sets Matrix total to:
| A B C | | J K L | | AJ+BM+CP AK+BN+CQ AL+BO+CR |
total = a * b = | D E F | * | M N O | = | DJ+EM+FP DK+EN+FQ DL+EO+FR |
| G H I | | P Q R | | GJ+HM+IP GK+HN+IQ GL+HO+IR |
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param total Indicates the pointer to an <b>OH_Drawing_Matrix</b> object that a * b.
@param a Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param b Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixConcat(
total: *mut OH_Drawing_Matrix,
a: *const OH_Drawing_Matrix,
b: *const OH_Drawing_Matrix,
);
/** @brief Get one matrix value. Index is between the range of 0-8.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param index one of 0-8.
@return Returns value corresponding to index.Returns 0 if out of range.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixGetValue(
arg1: *mut OH_Drawing_Matrix,
index: ::core::ffi::c_int,
) -> f32;
/** @brief Sets matrix to rotate by degrees about a pivot point at (px, py). The pivot point is unchanged
when mapped with matrix. Positive degrees rotates clockwise.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param degree Indicates the angle of axes relative to upright axes.
@param px Indicates the pivot on x-axis.
@param py Indicates the pivot on y-axis.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixRotate(arg1: *mut OH_Drawing_Matrix, degree: f32, px: f32, py: f32);
/** @brief Sets matrix to translate by (dx, dy)
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param dx Indicates the horizontal translation.
@param dy Indicates the vertical translation.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixTranslate(arg1: *mut OH_Drawing_Matrix, dx: f32, dy: f32);
/** @brief Sets matrix to scale by sx and sy, about a pivot point at (px, py).
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param sx Indicates the horizontal scale factor.
@param sy Indicates the vertical scale factor.
@param px Indicates the pivot on x-axis.
@param py Indicates the pivot on y-axis.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixScale(arg1: *mut OH_Drawing_Matrix, sx: f32, sy: f32, px: f32, py: f32);
/** @brief Sets inverse to reciprocal matrix, returning true if matrix can be inverted.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param inverse Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@return Returns true if the matrix is not nullptr and can be inverted;
returns false if the matrix is nullptr or cannot be inverted.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixInvert(
arg1: *mut OH_Drawing_Matrix,
inverse: *mut OH_Drawing_Matrix,
) -> bool;
/** @brief Sets the params of matrix to map src to dst.
Count must greater than or equal to zero, and less than or equal to four.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param src Points to map from.
@param dst Points to map to.
@param count Number of point in src and dst.
@return Returns true if matrix is constructed successfully.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixSetPolyToPoly(
arg1: *mut OH_Drawing_Matrix,
src: *const OH_Drawing_Point2D,
dst: *const OH_Drawing_Point2D,
count: u32,
) -> bool;
/** @brief Maps the src point array to the dst point array by matrix transformation.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param src Points to map from.
@param dst Points to map to.
@param count Number of point in src and dst.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixMapPoints(
arg1: *const OH_Drawing_Matrix,
src: *const OH_Drawing_Point2D,
dst: *mut OH_Drawing_Point2D,
count: ::core::ffi::c_int,
);
/** @brief Sets dst to bounds of src corners mapped by matrix transformation.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param src Rect to map from.
@param dst Rect to map to.
@return Returns true if the mapped src is equal to the dst; returns false is not equal.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixMapRect(
arg1: *const OH_Drawing_Matrix,
src: *const OH_Drawing_Rect,
dst: *mut OH_Drawing_Rect,
) -> bool;
/** @brief Returns true if the first matrix equals the second matrix.
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@param other Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@return Returns true if the two matrices are equal; returns false if not equal.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixIsEqual(
arg1: *mut OH_Drawing_Matrix,
other: *mut OH_Drawing_Matrix,
) -> bool;
/** @brief Returns true if matrix is identity.
Identity matrix is : | 1 0 0 |
| 0 1 0 |
| 0 0 1 |
@syscap SystemCapability.Graphic.Graphic2D.NativeDrawing
@param OH_Drawing_Matrix Indicates the pointer to an <b>OH_Drawing_Matrix</b> object.
@return Returns true if matrix is identity; returns false if not identity.
@since 12
@version 1.0*/
pub fn OH_Drawing_MatrixIsIdentity(arg1: *mut OH_Drawing_Matrix) -> bool;
}