1 /*
2 * Copyright (c) 2021 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 #include "c/drawing_path.h"
17
18 #include "draw/path.h"
19
20 using namespace OHOS;
21 using namespace Rosen;
22 using namespace Drawing;
23
CastToPath(OH_Drawing_Path * cPath)24 static Path* CastToPath(OH_Drawing_Path* cPath)
25 {
26 return reinterpret_cast<Path*>(cPath);
27 }
28
OH_Drawing_PathCreate()29 OH_Drawing_Path* OH_Drawing_PathCreate()
30 {
31 return (OH_Drawing_Path*)new Path;
32 }
33
OH_Drawing_PathDestroy(OH_Drawing_Path * cPath)34 void OH_Drawing_PathDestroy(OH_Drawing_Path* cPath)
35 {
36 delete CastToPath(cPath);
37 }
38
OH_Drawing_PathMoveTo(OH_Drawing_Path * cPath,float x,float y)39 void OH_Drawing_PathMoveTo(OH_Drawing_Path* cPath, float x, float y)
40 {
41 CastToPath(cPath)->MoveTo(x, y);
42 }
43
OH_Drawing_PathLineTo(OH_Drawing_Path * cPath,float x,float y)44 void OH_Drawing_PathLineTo(OH_Drawing_Path* cPath, float x, float y)
45 {
46 CastToPath(cPath)->LineTo(x, y);
47 }
48
OH_Drawing_PathArcTo(OH_Drawing_Path * cPath,float x1,float y1,float x2,float y2,float startDeg,float sweepDeg)49 void OH_Drawing_PathArcTo(
50 OH_Drawing_Path* cPath, float x1, float y1, float x2, float y2, float startDeg, float sweepDeg)
51 {
52 CastToPath(cPath)->ArcTo(x1, y1, x2, y2, startDeg, sweepDeg);
53 }
54
OH_Drawing_PathQuadTo(OH_Drawing_Path * cPath,float ctrlX,float ctrlY,float endX,float endY)55 void OH_Drawing_PathQuadTo(OH_Drawing_Path* cPath, float ctrlX, float ctrlY, float endX, float endY)
56 {
57 CastToPath(cPath)->QuadTo(ctrlX, ctrlY, endX, endY);
58 }
59
OH_Drawing_PathCubicTo(OH_Drawing_Path * cPath,float ctrlX1,float ctrlY1,float ctrlX2,float ctrlY2,float endX,float endY)60 void OH_Drawing_PathCubicTo(
61 OH_Drawing_Path* cPath, float ctrlX1, float ctrlY1, float ctrlX2, float ctrlY2, float endX, float endY)
62 {
63 CastToPath(cPath)->CubicTo(ctrlX1, ctrlY1, ctrlX2, ctrlY2, endX, endY);
64 }
65
OH_Drawing_PathClose(OH_Drawing_Path * cPath)66 void OH_Drawing_PathClose(OH_Drawing_Path* cPath)
67 {
68 CastToPath(cPath)->Close();
69 }
70
OH_Drawing_PathReset(OH_Drawing_Path * cPath)71 void OH_Drawing_PathReset(OH_Drawing_Path* cPath)
72 {
73 CastToPath(cPath)->Reset();
74 }
75