• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2024 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 FRAMEWORKS_BRIDGE_CJ_FRONTEND_CPP_VIEW_CAVANS_PATH_H
17 #define FRAMEWORKS_BRIDGE_CJ_FRONTEND_CPP_VIEW_CAVANS_PATH_H
18 
19 #include "ffi_remote_data.h"
20 
21 #include "base/memory/referenced.h"
22 #include "core/components/common/properties/decoration.h"
23 #include "bridge/cj_frontend/cppview/matrix2d.h"
24 #include "frameworks/core/components/common/properties/paint_state.h"
25 
26 namespace OHOS::Ace::Framework {
27 
28 class ACE_EXPORT NativeCanvasPath : public OHOS::FFI::FFIData {
29 public:
30     NativeCanvasPath();
31     explicit NativeCanvasPath(const std::string& capStr);
32     ~NativeCanvasPath() override;
33 
34     void AddPath(const sptr<NativeCanvasPath>& path);
35     void AddPathWithMatrix(const sptr<NativeCanvasPath>& path, const sptr<NativeMatrix2d>& matrix2d);
36     void SetTransform(double scaleX, double skewX, double skewY, double scaleY, double translateX, double translateY);
37     void MoveTo(double x, double y);
38     void LineTo(double x, double y);
39     void Arc(double x, double y, double radius, double startAngle, double endAngle, bool anticlockwise);
40     void ArcTo(double x1, double y1, double x2, double y2, double radius);
41     void QuadraticCurveTo(double cpx, double cpy, double x, double y);
42     void BezierCurveTo(double cp1x, double cp1y, double cp2x, double cp2y, double x, double y);
43     void Ellipse(double x, double y, double radiusX, double radiusY, double rotation, double startAngle,
44         double endAngle, bool anticlockwise);
45     void Rect(double x, double y, double width, double height);
46     void ClosePath();
GetCanvasPath2d()47     RefPtr<CanvasPath2D> GetCanvasPath2d() const
48     {
49         return path2d_;
50     }
51 
SetUnit(CanvasUnit unit)52     void SetUnit(CanvasUnit unit)
53     {
54         unit_ = unit;
55     }
56 
GetUnit()57     CanvasUnit GetUnit()
58     {
59         return unit_;
60     }
61 
62     double GetDensity();
63 
64 protected:
65     RefPtr<CanvasPath2D> path2d_;
66 
67 private:
68     CanvasUnit unit_ = CanvasUnit::DEFAULT;
69 };
70 
71 } //  namespace OHOS::Ace::Framework
72 #endif // FRAMEWORKS_BRIDGE_CJ_FRONTEND_CPP_VIEW_CAVANS_PATH_H
73