@react-native-ohos/react-native-clippathview 1.1.9-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +15 -0
- package/harmony/clipPath/BuildProfile.ets +6 -0
- package/harmony/clipPath/LICENSE +21 -0
- package/harmony/clipPath/OAT.xml +39 -0
- package/harmony/clipPath/README.OpenSource +11 -0
- package/harmony/clipPath/ResourceTable.txt +0 -0
- package/harmony/clipPath/build-profile.json5 +11 -0
- package/harmony/clipPath/consumer-rules.txt +0 -0
- package/harmony/clipPath/hvigorfile.ts +6 -0
- package/harmony/clipPath/index.ets +15 -0
- package/harmony/clipPath/obfuscation-rules.txt +18 -0
- package/harmony/clipPath/oh-package.json5 +14 -0
- package/harmony/clipPath/src/main/cpp/CMakeLists.txt +7 -0
- package/harmony/clipPath/src/main/cpp/ClipPathProps.h +127 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewComponentInstance.cpp +102 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewComponentInstance.h +33 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewJSIBinder.h +60 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewNapiBinder.h +79 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewNoneComponentInstance.cpp +102 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewNoneComponentInstance.h +38 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewNoneJSIBinder.h +61 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewNoneNapiBinder.h +80 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewNoneNode.cpp +381 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewNoneNode.h +98 -0
- package/harmony/clipPath/src/main/cpp/ClipPathViewPackage.h +85 -0
- package/harmony/clipPath/src/main/cpp/ComponentDescriptors.h +30 -0
- package/harmony/clipPath/src/main/cpp/ModUtil.cpp +47 -0
- package/harmony/clipPath/src/main/cpp/ModUtil.h +36 -0
- package/harmony/clipPath/src/main/cpp/Props.cpp +95 -0
- package/harmony/clipPath/src/main/cpp/Props.h +108 -0
- package/harmony/clipPath/src/main/cpp/RNCClipPathTurboModule.cpp +38 -0
- package/harmony/clipPath/src/main/cpp/RNCClipPathTurboModule.h +37 -0
- package/harmony/clipPath/src/main/cpp/SVGPathParser.cpp +617 -0
- package/harmony/clipPath/src/main/cpp/SVGPathParser.h +71 -0
- package/harmony/clipPath/src/main/cpp/SVGViewBox.cpp +94 -0
- package/harmony/clipPath/src/main/cpp/SVGViewBox.h +32 -0
- package/harmony/clipPath/src/main/cpp/ShadowNodes.cpp +22 -0
- package/harmony/clipPath/src/main/cpp/ShadowNodes.h +41 -0
- package/harmony/clipPath/src/main/cpp/pen_style_node.h +10 -0
- package/harmony/clipPath/src/main/ets/ClipPathPackage.ts +46 -0
- package/harmony/clipPath/src/main/ets/ClipPathTurboModule.ts +32 -0
- package/harmony/clipPath/src/main/module.json5 +7 -0
- package/harmony/clipPath/src/main/resources/base/element/string.json +8 -0
- package/harmony/clipPath/src/main/resources/en_US/element/string.json +8 -0
- package/harmony/clipPath/src/main/resources/zh_CN/element/string.json +8 -0
- package/harmony/clipPath/ts.ts +26 -0
- package/harmony/clipPath.har +0 -0
- package/index.d.ts +58 -0
- package/index.js +5 -0
- package/package.json +64 -0
- package/react-native-clippath.podspec +30 -0
- package/src/ClipPath.android.js +7 -0
- package/src/ClipPath.ios.js +5 -0
- package/src/ClipPath.web.js +5 -0
- package/src/ClipPathH.android.js +6 -0
- package/src/ClipPathH.ios.js +5 -0
- package/src/ClipPathH.web.js +5 -0
- package/src/ClipPathMobile.js +6 -0
- package/src/ClipPathMobileN.js +6 -0
- package/src/ClipPathNativeComponent.ts +48 -0
- package/src/ClipPathWeb.js +345 -0
- package/src/demo.jpg +0 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
//
|
|
2
|
+
// Created on 2024/6/25.
|
|
3
|
+
//
|
|
4
|
+
// Node APIs are not fully supported. To solve the compilation error of the interface cannot be found,
|
|
5
|
+
// please include "napi/native_api.h".
|
|
6
|
+
#pragma once
|
|
7
|
+
|
|
8
|
+
#include "RNOH/arkui/ArkUINode.h"
|
|
9
|
+
#include <native_drawing/drawing_matrix.h>
|
|
10
|
+
#include <native_drawing/drawing_pen.h>
|
|
11
|
+
#include <native_drawing/drawing_rect.h>
|
|
12
|
+
#include <native_drawing/drawing_types.h>
|
|
13
|
+
#include "ClipPathProps.h"
|
|
14
|
+
#include "SVGViewBox.h"
|
|
15
|
+
namespace rnoh {
|
|
16
|
+
|
|
17
|
+
struct CanvasCallback {
|
|
18
|
+
std::function<void(ArkUI_NodeCustomEvent *event)> callback;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
class ClipPathViewNoneNode : public ArkUINode {
|
|
22
|
+
public:
|
|
23
|
+
ClipPathViewNoneNode();
|
|
24
|
+
~ClipPathViewNoneNode() override;
|
|
25
|
+
void insertChild(ArkUINode &child, std::size_t index);
|
|
26
|
+
void removeChild(ArkUINode &child);
|
|
27
|
+
void setD(const std::string d);
|
|
28
|
+
void setStrokeWidth(float const width);
|
|
29
|
+
void setStrokeCap(std::string const cap);
|
|
30
|
+
void setStrokeJoin(std::string const join);
|
|
31
|
+
void setStrokeMiter(float const miter);
|
|
32
|
+
void setStrokeStart(float const start);
|
|
33
|
+
void setStrokeEnd(float const end);
|
|
34
|
+
void setViewBox(std::vector<float> viewBox);
|
|
35
|
+
void setAlign(std::string v);
|
|
36
|
+
void setAspect(std::string v);
|
|
37
|
+
void setFillRule(std::string v);
|
|
38
|
+
// transFrom
|
|
39
|
+
void setTransX(float v);
|
|
40
|
+
void setTransY(float v);
|
|
41
|
+
void setTransPercentageValue(bool v);
|
|
42
|
+
void setRot(float v);
|
|
43
|
+
void setRotO(float v);
|
|
44
|
+
void setRotOx(float v);
|
|
45
|
+
void setRotOy(float v);
|
|
46
|
+
void setRotPercentageValue(bool v);
|
|
47
|
+
void setSc(float v);
|
|
48
|
+
void setScX(float v);
|
|
49
|
+
void setScY(float v);
|
|
50
|
+
void setScO(float v);
|
|
51
|
+
void setScOx(float v);
|
|
52
|
+
void setScOy(float v);
|
|
53
|
+
void setTranslateZ(float z);
|
|
54
|
+
void setScPercentageValue(bool v);
|
|
55
|
+
private:
|
|
56
|
+
void (*eventReceiver)(ArkUI_NodeCustomEvent *event);
|
|
57
|
+
void OnDraw(ArkUI_NodeCustomEvent *event);
|
|
58
|
+
void setupPath(OH_Drawing_Canvas *canvas);
|
|
59
|
+
void viewBoxTransform();
|
|
60
|
+
bool validateViewBox();
|
|
61
|
+
void setRect(OH_Drawing_Rect *target, OH_Drawing_Rect *src);
|
|
62
|
+
void setRectF(OH_Drawing_Rect *target, float left, float top, float right, float bottom);
|
|
63
|
+
void setPaintStrokeProps();
|
|
64
|
+
float toDip(float value);
|
|
65
|
+
void canvasTransform();
|
|
66
|
+
void drawPath(OH_Drawing_Canvas *canvas);
|
|
67
|
+
void setPanStyleMode(OH_Drawing_Canvas *canvas,int type);
|
|
68
|
+
|
|
69
|
+
private:
|
|
70
|
+
std::string mD{""};
|
|
71
|
+
std::string mAlign{"xMinYMin"};
|
|
72
|
+
CanvasCallback *canvasCallback_{nullptr};
|
|
73
|
+
int mAspect{SVGViewBox::MOS_MEET};
|
|
74
|
+
ClipPathProps *mProps{new ClipPathProps()};
|
|
75
|
+
OH_Drawing_Rect *mRectVb{OH_Drawing_RectCreate(0.0f, 0.0f, -1.0f, -1.0f)};
|
|
76
|
+
OH_Drawing_Rect *mRectVbDensity{OH_Drawing_RectCreate(0.0f, 0.0f, -1.0f, -1.0f)};
|
|
77
|
+
OH_Drawing_Rect *mRectPath{OH_Drawing_RectCreate(0.0f, 0.0f, 0.0f, 0.0f)};
|
|
78
|
+
OH_Drawing_Rect *mBounds{OH_Drawing_RectCreate(0.0f, 0.0f, 0.0f, 0.0f)};
|
|
79
|
+
OH_Drawing_Matrix *mMatrix{OH_Drawing_MatrixCreate()};
|
|
80
|
+
OH_Drawing_Path *mPath{};
|
|
81
|
+
OH_Drawing_Path *mPath2{OH_Drawing_PathCreate()};
|
|
82
|
+
OH_Drawing_Pen *mPaint{OH_Drawing_PenCreate()};
|
|
83
|
+
OH_Drawing_Pen *mPaintStroke{OH_Drawing_PenCreate()};
|
|
84
|
+
OH_Drawing_Canvas *canvas{nullptr};
|
|
85
|
+
float mTranslationX{0.0f};
|
|
86
|
+
float mTranslationY{0.0f};
|
|
87
|
+
bool mTranslationIsPercent{false};
|
|
88
|
+
float mRotation{0.0f};
|
|
89
|
+
float mRotationOx{0.0f};
|
|
90
|
+
float mRotationOy{0.0f};
|
|
91
|
+
bool mRotationIsPercent{false};
|
|
92
|
+
float mScaleX{1.0f};
|
|
93
|
+
float mScaleY{1.0f};
|
|
94
|
+
float mScaleOriginX{0.0f};
|
|
95
|
+
float mScaleOriginY{0.0f};
|
|
96
|
+
bool mScaleIsPercent{false};
|
|
97
|
+
};
|
|
98
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 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 HARMONY_CLIP_PATH_VIEW_SRC_MAIN_CPP_CLIPPATHVIEWPACKAGE_H
|
|
17
|
+
#define HARMONY_CLIP_PATH_VIEW_SRC_MAIN_CPP_CLIPPATHVIEWPACKAGE_H
|
|
18
|
+
|
|
19
|
+
#include "RNCClipPathTurboModule.h"
|
|
20
|
+
#include "RNOH/Package.h"
|
|
21
|
+
#include "ComponentDescriptors.h"
|
|
22
|
+
#include "ClipPathViewNoneJSIBinder.h"
|
|
23
|
+
#include "ClipPathViewNoneNapiBinder.h"
|
|
24
|
+
#include "ClipPathViewJSIBinder.h"
|
|
25
|
+
#include "ClipPathViewNapiBinder.h"
|
|
26
|
+
#include "ClipPathViewNoneComponentInstance.h"
|
|
27
|
+
#include "ClipPathViewComponentInstance.h"
|
|
28
|
+
|
|
29
|
+
namespace rnoh {
|
|
30
|
+
class ClipPathViewPackageComponentInstanceFactoryDelegate : public ComponentInstanceFactoryDelegate {
|
|
31
|
+
public:
|
|
32
|
+
using ComponentInstanceFactoryDelegate::ComponentInstanceFactoryDelegate;
|
|
33
|
+
|
|
34
|
+
ComponentInstance::Shared create(ComponentInstance::Context ctx) override {
|
|
35
|
+
if (ctx.componentName == "RNCClipPathView") {
|
|
36
|
+
return std::make_shared<ClipPathViewComponentInstance>(std::move(ctx));
|
|
37
|
+
} else if (ctx.componentName == "RNCClipPathViewNone") {
|
|
38
|
+
return std::make_shared<ClipPathViewNoneComponentInstance>(std::move(ctx));
|
|
39
|
+
}
|
|
40
|
+
return nullptr;
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
class RNCClipPathFactoryDelegate : public TurboModuleFactoryDelegate {
|
|
45
|
+
public:
|
|
46
|
+
SharedTurboModule createTurboModule(Context ctx, const std::string &name) const override {
|
|
47
|
+
if (name == "RNCClipPathContext") {
|
|
48
|
+
return std::make_shared<RNCClipPathTurboModule>(ctx, name);
|
|
49
|
+
}
|
|
50
|
+
return nullptr;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
class ClipPathViewPackage : public Package {
|
|
55
|
+
public:
|
|
56
|
+
ClipPathViewPackage(Package::Context ctx) : Package(ctx) {}
|
|
57
|
+
|
|
58
|
+
ComponentInstanceFactoryDelegate::Shared createComponentInstanceFactoryDelegate() override {
|
|
59
|
+
return std::make_shared<ClipPathViewPackageComponentInstanceFactoryDelegate>();
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
std::vector<facebook::react::ComponentDescriptorProvider> createComponentDescriptorProviders() override {
|
|
63
|
+
return {facebook::react::concreteComponentDescriptorProvider<
|
|
64
|
+
facebook::react::RNCClipPathViewNoneComponentDescriptor>()};
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
std::unique_ptr<TurboModuleFactoryDelegate> createTurboModuleFactoryDelegate() override {
|
|
68
|
+
return std::make_unique<RNCClipPathFactoryDelegate>();
|
|
69
|
+
}
|
|
70
|
+
ComponentJSIBinderByString createComponentJSIBinderByName() override {
|
|
71
|
+
return {
|
|
72
|
+
{"RNCClipPathViewNone", std::make_shared<ClipPathViewNoneJSIBinder>()},
|
|
73
|
+
{"RNCClipPathView", std::make_shared<ClipPathViewJSIBinder>()},
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
ComponentNapiBinderByString createComponentNapiBinderByName() override {
|
|
78
|
+
return {
|
|
79
|
+
{"RNCClipPathViewNone", std::make_shared<ClipPathViewNoneNapiBinder>()},
|
|
80
|
+
{"RNCClipPathView", std::make_shared<ClipPathViewNapiBinder>()},
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
} // namespace rnoh
|
|
85
|
+
#endif
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 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 HARMONY_CLIP_PATH_VIEW_SRC_MAIN_CPP_COMPONENTDESCRIPTOR_H
|
|
17
|
+
#define HARMONY_CLIP_PATH_VIEW_SRC_MAIN_CPP_COMPONENTDESCRIPTOR_H
|
|
18
|
+
|
|
19
|
+
#include <react/renderer/core/ConcreteComponentDescriptor.h>
|
|
20
|
+
#include "ShadowNodes.h"
|
|
21
|
+
|
|
22
|
+
namespace facebook {
|
|
23
|
+
namespace react {
|
|
24
|
+
|
|
25
|
+
using RNCClipPathViewComponentDescriptor = ConcreteComponentDescriptor<RNCClipPathViewShadowNode>;
|
|
26
|
+
using RNCClipPathViewNoneComponentDescriptor = ConcreteComponentDescriptor<RNCClipPathViewNoneShadowNode>;
|
|
27
|
+
|
|
28
|
+
} // namespace react
|
|
29
|
+
} // namespace facebook
|
|
30
|
+
#endif
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 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
|
+
#include "ModUtil.h"
|
|
17
|
+
#include <native_drawing/drawing_rect.h>
|
|
18
|
+
namespace rnoh {
|
|
19
|
+
float ModUtil::mScreenDensity = 2.5f;
|
|
20
|
+
|
|
21
|
+
float ModUtil::clamp(float v) { return v > 1 ? 1 : (v < 0 ? 0 : v); }
|
|
22
|
+
|
|
23
|
+
float ModUtil::uClamp(float v) { return v < 0 ? 0 : v; }
|
|
24
|
+
|
|
25
|
+
float ModUtil::uClamp(float v, float optional) { return v < 0 ? optional : v; }
|
|
26
|
+
|
|
27
|
+
float ModUtil::viewBoxEvaluator(float value, float start, float end) { return (value - start) / (end - start); }
|
|
28
|
+
|
|
29
|
+
float ModUtil::viewBoxToWidth(float value, OH_Drawing_Rect *rectF, float w) {
|
|
30
|
+
return viewBoxEvaluator(value, OH_Drawing_RectGetLeft(rectF), OH_Drawing_RectGetRight(rectF)) * w;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
float ModUtil::viewBoxToHeight(float value, OH_Drawing_Rect *rectF, float h) {
|
|
34
|
+
return viewBoxEvaluator(value, OH_Drawing_RectGetTop(rectF), OH_Drawing_RectGetBottom(rectF)) * h;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
float ModUtil::viewBoxToMax(float value, OH_Drawing_Rect *rectF, float w, float h) {
|
|
38
|
+
float size = OH_Drawing_RectGetWidth(rectF) > OH_Drawing_RectGetHeight(rectF) ? OH_Drawing_RectGetWidth(rectF)
|
|
39
|
+
: OH_Drawing_RectGetHeight(rectF);
|
|
40
|
+
float maxVb = w > h ? OH_Drawing_RectGetWidth(rectF) : OH_Drawing_RectGetHeight(rectF);
|
|
41
|
+
return (value / maxVb) * size;
|
|
42
|
+
}
|
|
43
|
+
void ModUtil::setDensity(float density) { mScreenDensity = density; }
|
|
44
|
+
|
|
45
|
+
float ModUtil::getDensity() { return mScreenDensity; }
|
|
46
|
+
|
|
47
|
+
} // namespace rnoh
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 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
|
+
#ifndef HARMONY_MODUTIL_H
|
|
16
|
+
#define HARMONY_MODUTIL_H
|
|
17
|
+
#include <native_drawing/drawing_types.h>
|
|
18
|
+
namespace rnoh {
|
|
19
|
+
class ModUtil {
|
|
20
|
+
public:
|
|
21
|
+
static float clamp(float v);
|
|
22
|
+
static float uClamp(float v);
|
|
23
|
+
static float uClamp(float v, float optional);
|
|
24
|
+
static float viewBoxEvaluator(float value, float start, float end);
|
|
25
|
+
static float viewBoxToWidth(float value, OH_Drawing_Rect *rectF, float w);
|
|
26
|
+
static float viewBoxToHeight(float value, OH_Drawing_Rect *rectF, float h);
|
|
27
|
+
static float viewBoxToMax(float value, OH_Drawing_Rect *rectF, float w, float h);
|
|
28
|
+
static void setDensity(float density);
|
|
29
|
+
static float getDensity();
|
|
30
|
+
|
|
31
|
+
private:
|
|
32
|
+
static float mScreenDensity;
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
}; // namespace rnoh
|
|
36
|
+
#endif // HARMONY_MODUTIL_H
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 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
|
+
#include "Props.h"
|
|
17
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
18
|
+
#include <react/renderer/core/propsConversions.h>
|
|
19
|
+
|
|
20
|
+
namespace facebook {
|
|
21
|
+
namespace react {
|
|
22
|
+
|
|
23
|
+
RNCClipPathViewProps::RNCClipPathViewProps(const PropsParserContext &context, const RNCClipPathViewProps &sourceProps,
|
|
24
|
+
const RawProps &rawProps)
|
|
25
|
+
: ViewProps(context, sourceProps, rawProps),
|
|
26
|
+
d(convertRawProp(context, rawProps, "d", sourceProps.d, "/0")),
|
|
27
|
+
aspect(convertRawProp(context, rawProps, "aspect", sourceProps.aspect, "meet")),
|
|
28
|
+
fillRule(convertRawProp(context, rawProps, "fillRule", sourceProps.fillRule, "/0")),
|
|
29
|
+
translateZ(convertRawProp(context, rawProps, "translateZ", sourceProps.translateZ, {0.0})),
|
|
30
|
+
strokeWidth(convertRawProp(context, rawProps, "strokeWidth", sourceProps.strokeWidth, {1.0})),
|
|
31
|
+
strokeCap(convertRawProp(context, rawProps, "strokeCap", sourceProps.strokeCap, {"none"})),
|
|
32
|
+
strokeJoin(convertRawProp(context, rawProps, "strokeJoin", sourceProps.strokeJoin, {"none"})),
|
|
33
|
+
strokeMiter(convertRawProp(context, rawProps, "strokeMiter", sourceProps.strokeMiter, {4.0})),
|
|
34
|
+
strokeStart(convertRawProp(context, rawProps, "strokeStart", sourceProps.strokeStart, {0.0})),
|
|
35
|
+
strokeEnd(convertRawProp(context, rawProps, "strokeEnd", sourceProps.strokeEnd, {1.0})),
|
|
36
|
+
transX(convertRawProp(context, rawProps, "transX", sourceProps.transX, {0.0})),
|
|
37
|
+
transY(convertRawProp(context, rawProps, "transY", sourceProps.transY, {0.0})),
|
|
38
|
+
transPercentageValue(
|
|
39
|
+
convertRawProp(context, rawProps, "transPercentageValue", sourceProps.transPercentageValue, {false})),
|
|
40
|
+
rot(convertRawProp(context, rawProps, "rot", sourceProps.rot, {0.0})),
|
|
41
|
+
rotO(convertRawProp(context, rawProps, "rotO", sourceProps.rotO, {0.0})),
|
|
42
|
+
rotOx(convertRawProp(context, rawProps, "rotOx", sourceProps.rotOx, {0.0})),
|
|
43
|
+
rotOy(convertRawProp(context, rawProps, "rotOy", sourceProps.rotOy, {0.0})),
|
|
44
|
+
rotPercentageValue(
|
|
45
|
+
convertRawProp(context, rawProps, "rotPercentageValue", sourceProps.rotPercentageValue, {false})),
|
|
46
|
+
sc(convertRawProp(context, rawProps, "sc", sourceProps.sc, {1.0})),
|
|
47
|
+
|
|
48
|
+
scX(convertRawProp(context, rawProps, "scX", sourceProps.scX, {1.0})),
|
|
49
|
+
scY(convertRawProp(context, rawProps, "scY", sourceProps.scY, {1.0})),
|
|
50
|
+
scO(convertRawProp(context, rawProps, "scO", sourceProps.scO, {0.0})),
|
|
51
|
+
scOx(convertRawProp(context, rawProps, "scOx", sourceProps.scOx, {0.0})),
|
|
52
|
+
scOy(convertRawProp(context, rawProps, "scOy", sourceProps.scOy, {0.0})),
|
|
53
|
+
scPercentageValue(convertRawProp(context, rawProps, "scPercentageValue", sourceProps.scPercentageValue, {false})),
|
|
54
|
+
|
|
55
|
+
align(convertRawProp(context, rawProps, "align", sourceProps.align, {"xMidYMid"})),
|
|
56
|
+
viewBox(convertRawProp(context, rawProps, "viewBox", sourceProps.viewBox, {})) {}
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
RNCClipPathViewNoneProps::RNCClipPathViewNoneProps(const PropsParserContext &context,
|
|
60
|
+
const RNCClipPathViewNoneProps &sourceProps,
|
|
61
|
+
const RawProps &rawProps)
|
|
62
|
+
: ViewProps(context, sourceProps, rawProps),
|
|
63
|
+
d(convertRawProp(context, rawProps, "d", sourceProps.d, "/0")),
|
|
64
|
+
aspect(convertRawProp(context, rawProps, "aspect", sourceProps.aspect, "meet")),
|
|
65
|
+
fillRule(convertRawProp(context, rawProps, "fillRule", sourceProps.fillRule, "/0")),
|
|
66
|
+
translateZ(convertRawProp(context, rawProps, "translateZ", sourceProps.translateZ, {0.0})),
|
|
67
|
+
strokeWidth(convertRawProp(context, rawProps, "strokeWidth", sourceProps.strokeWidth, {1.0})),
|
|
68
|
+
strokeCap(convertRawProp(context, rawProps, "strokeCap", sourceProps.strokeCap, {"none"})),
|
|
69
|
+
strokeJoin(convertRawProp(context, rawProps, "strokeJoin", sourceProps.strokeJoin, {"none"})),
|
|
70
|
+
strokeMiter(convertRawProp(context, rawProps, "strokeMiter", sourceProps.strokeMiter, {4.0})),
|
|
71
|
+
strokeStart(convertRawProp(context, rawProps, "strokeStart", sourceProps.strokeStart, {0.0})),
|
|
72
|
+
strokeEnd(convertRawProp(context, rawProps, "strokeEnd", sourceProps.strokeEnd, {1.0})),
|
|
73
|
+
transX(convertRawProp(context, rawProps, "transX", sourceProps.transX, {0.0})),
|
|
74
|
+
transY(convertRawProp(context, rawProps, "transY", sourceProps.transY, {0.0})),
|
|
75
|
+
transPercentageValue(
|
|
76
|
+
convertRawProp(context, rawProps, "transPercentageValue", sourceProps.transPercentageValue, {false})),
|
|
77
|
+
rot(convertRawProp(context, rawProps, "rot", sourceProps.rot, {0.0})),
|
|
78
|
+
rotO(convertRawProp(context, rawProps, "rotO", sourceProps.rotO, {0.0})),
|
|
79
|
+
rotOx(convertRawProp(context, rawProps, "rotOx", sourceProps.rotOx, {0.0})),
|
|
80
|
+
rotOy(convertRawProp(context, rawProps, "rotOy", sourceProps.rotOy, {0.0})),
|
|
81
|
+
rotPercentageValue(
|
|
82
|
+
convertRawProp(context, rawProps, "rotPercentageValue", sourceProps.rotPercentageValue, {false})),
|
|
83
|
+
|
|
84
|
+
sc(convertRawProp(context, rawProps, "sc", sourceProps.sc, {1.0})),
|
|
85
|
+
scX(convertRawProp(context, rawProps, "scX", sourceProps.scX, {1.0})),
|
|
86
|
+
scY(convertRawProp(context, rawProps, "scY", sourceProps.scY, {1.0})),
|
|
87
|
+
scO(convertRawProp(context, rawProps, "scO", sourceProps.scO, {0.0})),
|
|
88
|
+
scOx(convertRawProp(context, rawProps, "scOx", sourceProps.scOx, {0.0})),
|
|
89
|
+
scOy(convertRawProp(context, rawProps, "scOy", sourceProps.scOy, {0.0})),
|
|
90
|
+
scPercentageValue(convertRawProp(context, rawProps, "scPercentageValue", sourceProps.scPercentageValue, {false})),
|
|
91
|
+
|
|
92
|
+
align(convertRawProp(context, rawProps, "align", sourceProps.align, {"xMidYMid"})),
|
|
93
|
+
viewBox(convertRawProp(context, rawProps, "viewBox", sourceProps.viewBox, {})) {}
|
|
94
|
+
} // namespace react
|
|
95
|
+
} // namespace facebook
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 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 HARMONY_CLIP_PATH_VIEW_SRC_MAIN_CPP_PROPS_H
|
|
17
|
+
#define HARMONY_CLIP_PATH_VIEW_SRC_MAIN_CPP_PROPS_H
|
|
18
|
+
|
|
19
|
+
#include <jsi/jsi.h>
|
|
20
|
+
#include <react/renderer/components/view/ViewProps.h>
|
|
21
|
+
#include <react/renderer/core/PropsParserContext.h>
|
|
22
|
+
#include <react/renderer/core/propsConversions.h>
|
|
23
|
+
|
|
24
|
+
#include <vector>
|
|
25
|
+
namespace facebook {
|
|
26
|
+
namespace react {
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class JSI_EXPORT RNCClipPathViewProps final : public ViewProps {
|
|
30
|
+
public:
|
|
31
|
+
RNCClipPathViewProps() = default;
|
|
32
|
+
RNCClipPathViewProps(const PropsParserContext &context, const RNCClipPathViewProps &sourceProps,
|
|
33
|
+
const RawProps &rawProps);
|
|
34
|
+
|
|
35
|
+
#pragma mark - Props
|
|
36
|
+
std::string d;
|
|
37
|
+
std::string aspect;
|
|
38
|
+
std::string align{"xMidYMid"};
|
|
39
|
+
std::string fillRule{"evenodd"};
|
|
40
|
+
float strokeWidth{1.0};
|
|
41
|
+
std::string strokeCap{"round"};
|
|
42
|
+
std::string strokeJoin{"miter"};
|
|
43
|
+
float strokeMiter{4.0};
|
|
44
|
+
float strokeStart{0.0};
|
|
45
|
+
float strokeEnd{1.0};
|
|
46
|
+
|
|
47
|
+
float translateZ{0.0f};
|
|
48
|
+
float transX = 0.f;
|
|
49
|
+
float transY = 0.f;
|
|
50
|
+
bool transPercentageValue = false;
|
|
51
|
+
|
|
52
|
+
float rot = 0.f;
|
|
53
|
+
float rotO = 0.f;
|
|
54
|
+
float rotOx = 0.f;
|
|
55
|
+
float rotOy = 0.f;
|
|
56
|
+
bool rotPercentageValue = false;
|
|
57
|
+
|
|
58
|
+
float sc = 1.f;
|
|
59
|
+
float scX = 1.f;
|
|
60
|
+
float scY = 1.f;
|
|
61
|
+
float scO = 0.f;
|
|
62
|
+
float scOx = 0.f;
|
|
63
|
+
float scOy = 0.f;
|
|
64
|
+
bool scPercentageValue = false;
|
|
65
|
+
std::vector<float> viewBox{};
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
class JSI_EXPORT RNCClipPathViewNoneProps final : public ViewProps {
|
|
69
|
+
public:
|
|
70
|
+
RNCClipPathViewNoneProps() = default;
|
|
71
|
+
RNCClipPathViewNoneProps(const PropsParserContext &context, const RNCClipPathViewNoneProps &sourceProps,
|
|
72
|
+
const RawProps &rawProps);
|
|
73
|
+
#pragma mark - Props
|
|
74
|
+
std::string d;
|
|
75
|
+
std::string aspect;
|
|
76
|
+
std::string align{"xMidYMid"};
|
|
77
|
+
std::string fillRule{"evenodd"};
|
|
78
|
+
float strokeWidth{1.0};
|
|
79
|
+
std::string strokeCap{"round"};
|
|
80
|
+
std::string strokeJoin{"miter"};
|
|
81
|
+
float strokeMiter{4.0};
|
|
82
|
+
float strokeStart{0.0};
|
|
83
|
+
float strokeEnd{1.0};
|
|
84
|
+
|
|
85
|
+
float translateZ{0.0f};
|
|
86
|
+
float transX = 0.f;
|
|
87
|
+
float transY = 0.f;
|
|
88
|
+
bool transPercentageValue = false;
|
|
89
|
+
|
|
90
|
+
float rot = 0.f;
|
|
91
|
+
float rotO = 0.f;
|
|
92
|
+
float rotOx = 0.f;
|
|
93
|
+
float rotOy = 0.f;
|
|
94
|
+
bool rotPercentageValue = false;
|
|
95
|
+
|
|
96
|
+
float sc = 1.f;
|
|
97
|
+
float scX = 1.f;
|
|
98
|
+
float scY = 1.f;
|
|
99
|
+
float scO = 0.f;
|
|
100
|
+
float scOx = 0.f;
|
|
101
|
+
float scOy = 0.f;
|
|
102
|
+
bool scPercentageValue = false;
|
|
103
|
+
std::vector<float> viewBox{};
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
} // namespace react
|
|
107
|
+
} // namespace facebook
|
|
108
|
+
#endif
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#include "RNCClipPathTurboModule.h"
|
|
26
|
+
|
|
27
|
+
using namespace rnoh;
|
|
28
|
+
using namespace facebook;
|
|
29
|
+
|
|
30
|
+
static jsi::Value __hostFunction_RNCClipPathTurboModule_getDensity(jsi::Runtime &rt, react::TurboModule &turboModule,
|
|
31
|
+
const jsi::Value *args, size_t count) {
|
|
32
|
+
return static_cast<ArkTSTurboModule &>(turboModule).call(rt, "getDensity", args, count);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
RNCClipPathTurboModule::RNCClipPathTurboModule(const ArkTSTurboModule::Context ctx, const std::string name)
|
|
36
|
+
: ArkTSTurboModule(ctx, name) {
|
|
37
|
+
methodMap_["getDensity"] = MethodMetadata{0, __hostFunction_RNCClipPathTurboModule_getDensity};
|
|
38
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MIT License
|
|
3
|
+
*
|
|
4
|
+
* Copyright (C) 2023 Huawei Device Co., Ltd.
|
|
5
|
+
*
|
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
7
|
+
* of this software and associated documentation files (the "Software"), to deal
|
|
8
|
+
* in the Software without restriction, including without limitation the rights
|
|
9
|
+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
10
|
+
* copies of the Software, and to permit persons to whom the Software is
|
|
11
|
+
* furnished to do so, subject to the following conditions:
|
|
12
|
+
*
|
|
13
|
+
* The above copyright notice and this permission notice shall be included in all
|
|
14
|
+
* copies or substantial portions of the Software.
|
|
15
|
+
*
|
|
16
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
17
|
+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
18
|
+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
19
|
+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
20
|
+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
21
|
+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
22
|
+
* SOFTWARE.
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
#pragma once
|
|
26
|
+
|
|
27
|
+
#include <ReactCommon/TurboModule.h>
|
|
28
|
+
#include "RNOH/ArkTSTurboModule.h"
|
|
29
|
+
|
|
30
|
+
namespace rnoh {
|
|
31
|
+
|
|
32
|
+
class JSI_EXPORT RNCClipPathTurboModule : public ArkTSTurboModule {
|
|
33
|
+
public:
|
|
34
|
+
RNCClipPathTurboModule(const ArkTSTurboModule::Context ctx, const std::string name);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
} // namespace rnoh
|