@shopify/react-native-skia 0.1.142 → 0.1.143
Sign up to get free protection for your applications and to get access to all the features.
- package/cpp/api/JsiSkPathFactory.h +1 -1
- package/cpp/api/JsiSkPicture.h +7 -1
- package/cpp/rnskia/RNSkDrawView.cpp +4 -4
- package/cpp/rnskia/RNSkDrawView.h +1 -1
- package/lib/commonjs/renderer/components/Blend.js +20 -5
- package/lib/commonjs/renderer/components/Blend.js.map +1 -1
- package/lib/commonjs/renderer/components/imageFilters/Morphology.js +1 -1
- package/lib/commonjs/renderer/components/imageFilters/Morphology.js.map +1 -1
- package/lib/commonjs/renderer/components/imageFilters/Shadow.js +1 -1
- package/lib/commonjs/renderer/components/imageFilters/Shadow.js.map +1 -1
- package/lib/commonjs/skia/web/Host.js +12 -21
- package/lib/commonjs/skia/web/Host.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkCanvas.js +46 -26
- package/lib/commonjs/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js +4 -4
- package/lib/commonjs/skia/web/JsiSkColorFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkFont.js +7 -3
- package/lib/commonjs/skia/web/JsiSkFont.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.js +4 -2
- package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +4 -2
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js +61 -19
- package/lib/commonjs/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkMatrix.js +1 -1
- package/lib/commonjs/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPaint.js +15 -6
- package/lib/commonjs/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPath.js +9 -55
- package/lib/commonjs/skia/web/JsiSkPath.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js +7 -3
- package/lib/commonjs/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPicture.js +5 -1
- package/lib/commonjs/skia/web/JsiSkPicture.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPictureRecorder.js +3 -1
- package/lib/commonjs/skia/web/JsiSkPictureRecorder.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkPoint.js +9 -1
- package/lib/commonjs/skia/web/JsiSkPoint.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRRect.js +1 -1
- package/lib/commonjs/skia/web/JsiSkRRect.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRSXform.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRect.js +1 -1
- package/lib/commonjs/skia/web/JsiSkRect.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkRuntimeEffect.js +4 -2
- package/lib/commonjs/skia/web/JsiSkRuntimeEffect.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkShaderFactory.js +10 -6
- package/lib/commonjs/skia/web/JsiSkShaderFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkSurface.js +3 -1
- package/lib/commonjs/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js +8 -4
- package/lib/commonjs/skia/web/JsiSkTextBlobFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkTypefaceFactory.js +1 -1
- package/lib/commonjs/skia/web/JsiSkTypefaceFactory.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkia.js +12 -6
- package/lib/commonjs/skia/web/JsiSkia.js.map +1 -1
- package/lib/module/renderer/components/Blend.js +21 -5
- package/lib/module/renderer/components/Blend.js.map +1 -1
- package/lib/module/renderer/components/imageFilters/Morphology.js +1 -1
- package/lib/module/renderer/components/imageFilters/Morphology.js.map +1 -1
- package/lib/module/renderer/components/imageFilters/Shadow.js +1 -1
- package/lib/module/renderer/components/imageFilters/Shadow.js.map +1 -1
- package/lib/module/skia/web/Host.js +9 -9
- package/lib/module/skia/web/Host.js.map +1 -1
- package/lib/module/skia/web/JsiSkCanvas.js +37 -27
- package/lib/module/skia/web/JsiSkCanvas.js.map +1 -1
- package/lib/module/skia/web/JsiSkColorFilterFactory.js +5 -5
- package/lib/module/skia/web/JsiSkColorFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkFont.js +6 -4
- package/lib/module/skia/web/JsiSkFont.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.js +4 -3
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.js +4 -3
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFilterFactory.js +61 -20
- package/lib/module/skia/web/JsiSkImageFilterFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkMatrix.js +2 -2
- package/lib/module/skia/web/JsiSkMatrix.js.map +1 -1
- package/lib/module/skia/web/JsiSkPaint.js +11 -7
- package/lib/module/skia/web/JsiSkPaint.js.map +1 -1
- package/lib/module/skia/web/JsiSkPath.js +9 -57
- package/lib/module/skia/web/JsiSkPath.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathEffectFactory.js +6 -4
- package/lib/module/skia/web/JsiSkPathEffectFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPathFactory.js +2 -2
- package/lib/module/skia/web/JsiSkPathFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkPicture.js +4 -2
- package/lib/module/skia/web/JsiSkPicture.js.map +1 -1
- package/lib/module/skia/web/JsiSkPictureRecorder.js +3 -2
- package/lib/module/skia/web/JsiSkPictureRecorder.js.map +1 -1
- package/lib/module/skia/web/JsiSkPoint.js +10 -2
- package/lib/module/skia/web/JsiSkPoint.js.map +1 -1
- package/lib/module/skia/web/JsiSkRRect.js +2 -2
- package/lib/module/skia/web/JsiSkRRect.js.map +1 -1
- package/lib/module/skia/web/JsiSkRSXform.js.map +1 -1
- package/lib/module/skia/web/JsiSkRect.js +2 -2
- package/lib/module/skia/web/JsiSkRect.js.map +1 -1
- package/lib/module/skia/web/JsiSkRuntimeEffect.js +4 -3
- package/lib/module/skia/web/JsiSkRuntimeEffect.js.map +1 -1
- package/lib/module/skia/web/JsiSkShaderFactory.js +9 -7
- package/lib/module/skia/web/JsiSkShaderFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkSurface.js +3 -2
- package/lib/module/skia/web/JsiSkSurface.js.map +1 -1
- package/lib/module/skia/web/JsiSkTextBlobFactory.js +7 -5
- package/lib/module/skia/web/JsiSkTextBlobFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkTypefaceFactory.js +2 -2
- package/lib/module/skia/web/JsiSkTypefaceFactory.js.map +1 -1
- package/lib/module/skia/web/JsiSkia.js +10 -5
- package/lib/module/skia/web/JsiSkia.js.map +1 -1
- package/lib/typescript/src/skia/types/Picture/Picture.d.ts +2 -1
- package/lib/typescript/src/skia/web/Host.d.ts +5 -7
- package/lib/typescript/src/skia/web/JsiSkImageFilterFactory.d.ts +8 -8
- package/lib/typescript/src/skia/web/JsiSkPoint.d.ts +3 -2
- package/lib/typescript/src/skia/web/JsiSkRRect.d.ts +2 -2
- package/lib/typescript/src/skia/web/JsiSkRSXform.d.ts +1 -2
- package/lib/typescript/src/skia/web/JsiSkRect.d.ts +2 -2
- package/lib/typescript/src/skia/web/JsiSkTextBlobFactory.d.ts +2 -1
- package/package.json +2 -2
- package/src/renderer/components/Blend.tsx +25 -5
- package/src/renderer/components/imageFilters/Morphology.tsx +2 -2
- package/src/renderer/components/imageFilters/Shadow.tsx +2 -2
- package/src/skia/types/Picture/Picture.ts +2 -1
- package/src/skia/web/Host.ts +11 -21
- package/src/skia/web/JsiSkCanvas.ts +78 -47
- package/src/skia/web/JsiSkColorFilterFactory.ts +15 -5
- package/src/skia/web/JsiSkFont.ts +11 -4
- package/src/skia/web/JsiSkImage.ts +4 -3
- package/src/skia/web/JsiSkImageFactory.ts +6 -3
- package/src/skia/web/JsiSkImageFilterFactory.ts +124 -52
- package/src/skia/web/JsiSkMatrix.ts +4 -2
- package/src/skia/web/JsiSkPaint.ts +11 -7
- package/src/skia/web/JsiSkPath.ts +16 -51
- package/src/skia/web/JsiSkPathEffectFactory.ts +10 -5
- package/src/skia/web/JsiSkPathFactory.ts +3 -3
- package/src/skia/web/JsiSkPicture.ts +5 -3
- package/src/skia/web/JsiSkPictureRecorder.ts +3 -2
- package/src/skia/web/JsiSkPoint.ts +12 -2
- package/src/skia/web/JsiSkRRect.ts +5 -2
- package/src/skia/web/JsiSkRSXform.ts +1 -1
- package/src/skia/web/JsiSkRect.ts +2 -2
- package/src/skia/web/JsiSkRuntimeEffect.ts +9 -4
- package/src/skia/web/JsiSkShaderFactory.ts +24 -15
- package/src/skia/web/JsiSkSurface.ts +7 -2
- package/src/skia/web/JsiSkTextBlobFactory.ts +14 -8
- package/src/skia/web/JsiSkTypefaceFactory.tsx +4 -2
- package/src/skia/web/JsiSkia.ts +17 -5
@@ -165,7 +165,7 @@ public:
|
|
165
165
|
JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromCmds),
|
166
166
|
JSI_EXPORT_FUNC(JsiSkPathFactory, MakeFromText))
|
167
167
|
|
168
|
-
|
168
|
+
JsiSkPathFactory(std::shared_ptr<RNSkPlatformContext> context)
|
169
169
|
: JsiSkHostObject(std::move(context)) {}
|
170
170
|
};
|
171
171
|
|
package/cpp/api/JsiSkPicture.h
CHANGED
@@ -21,7 +21,13 @@ public:
|
|
21
21
|
|
22
22
|
JsiSkPicture(std::shared_ptr<RNSkPlatformContext> context, const sk_sp<SkPicture> picture)
|
23
23
|
: JsiSkWrappingSkPtrHostObject<SkPicture>(context, picture) {};
|
24
|
-
|
24
|
+
|
25
|
+
JSI_PROPERTY_GET(__typename__) {
|
26
|
+
return jsi::String::createFromUtf8(runtime, "Picture");
|
27
|
+
}
|
28
|
+
|
29
|
+
JSI_EXPORT_PROPERTY_GETTERS(JSI_EXPORT_PROP_GET(JsiSkPicture, __typename__))
|
30
|
+
|
25
31
|
JSI_HOST_FUNCTION(makeShader) {
|
26
32
|
auto tmx = (SkTileMode)arguments[0].asNumber();
|
27
33
|
auto tmy = (SkTileMode)arguments[1].asNumber();
|
@@ -54,7 +54,7 @@ void RNSkDrawView::setNativeId(size_t nativeId) {
|
|
54
54
|
beginDrawingLoop();
|
55
55
|
}
|
56
56
|
|
57
|
-
void RNSkDrawView::callJsDrawCallback(int width, int height, double timestamp) {
|
57
|
+
void RNSkDrawView::callJsDrawCallback(std::shared_ptr<JsiSkCanvas> canvas, int width, int height, double timestamp) {
|
58
58
|
if(_drawCallback == nullptr) {
|
59
59
|
return;
|
60
60
|
}
|
@@ -70,7 +70,7 @@ void RNSkDrawView::callJsDrawCallback(int width, int height, double timestamp) {
|
|
70
70
|
|
71
71
|
// Set up arguments array
|
72
72
|
std::vector<jsi::Value> args(2);
|
73
|
-
args[0] = jsi::Object::createFromHostObject(*runtime,
|
73
|
+
args[0] = jsi::Object::createFromHostObject(*runtime, canvas);
|
74
74
|
args[1] = jsi::Object::createFromHostObject(*runtime, _infoObject);
|
75
75
|
|
76
76
|
// To be able to call the drawing function we'll wrap it once again
|
@@ -104,7 +104,7 @@ void RNSkDrawView::callJsDrawCallback(int width, int height, double timestamp) {
|
|
104
104
|
font.setSize(14);
|
105
105
|
auto paint = SkPaint();
|
106
106
|
paint.setColor(SkColors::kRed);
|
107
|
-
|
107
|
+
canvas->getCanvas()->drawSimpleText(
|
108
108
|
debugString.c_str(), debugString.size(), SkTextEncoding::kUTF8, 8,
|
109
109
|
18, font, paint);
|
110
110
|
}
|
@@ -140,7 +140,7 @@ void RNSkDrawView::drawInCanvas(std::shared_ptr<JsiSkCanvas> canvas,
|
|
140
140
|
skCanvas->scale(pd, pd);
|
141
141
|
|
142
142
|
// Call draw function.
|
143
|
-
callJsDrawCallback(width / pd, height / pd, time);
|
143
|
+
callJsDrawCallback(canvas, width / pd, height / pd, time);
|
144
144
|
|
145
145
|
// Restore and flush canvas
|
146
146
|
skCanvas->restore();
|
@@ -131,7 +131,7 @@ private:
|
|
131
131
|
* Calls the JS draw callback. This is the JS function that does the actual drawing so this
|
132
132
|
* method must be called from the JS thread.
|
133
133
|
*/
|
134
|
-
void callJsDrawCallback(int width, int height, double timestamp);
|
134
|
+
void callJsDrawCallback(std::shared_ptr<JsiSkCanvas> canvas, int width, int height, double timestamp);
|
135
135
|
|
136
136
|
/**
|
137
137
|
Starts beginDrawCallback loop if the drawing mode is continuous
|
@@ -17,6 +17,10 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
17
17
|
|
18
18
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
19
19
|
|
20
|
+
const childrenAreImageFilters = children => children.every(child => (0, _types.isImageFilter)(child));
|
21
|
+
|
22
|
+
const childrenAreShaders = children => children.every(child => (0, _types.isShader)(child));
|
23
|
+
|
20
24
|
const onDeclare = (0, _nodes.createDeclaration)((_ref, children, _ref2) => {
|
21
25
|
let {
|
22
26
|
mode
|
@@ -24,14 +28,25 @@ const onDeclare = (0, _nodes.createDeclaration)((_ref, children, _ref2) => {
|
|
24
28
|
let {
|
25
29
|
Skia
|
26
30
|
} = _ref2;
|
27
|
-
const [inner, outer] = children;
|
28
31
|
|
29
32
|
const blend = _types.BlendMode[(0, _Paint.enumKey)(mode)];
|
30
33
|
|
31
|
-
if ((
|
32
|
-
return
|
33
|
-
|
34
|
-
|
34
|
+
if (childrenAreImageFilters(children)) {
|
35
|
+
return children.reverse().reduce((inner, outer) => {
|
36
|
+
if (inner === null) {
|
37
|
+
return outer;
|
38
|
+
}
|
39
|
+
|
40
|
+
return Skia.ImageFilter.MakeBlend(blend, outer, inner);
|
41
|
+
}, null);
|
42
|
+
} else if (childrenAreShaders(children)) {
|
43
|
+
return children.reverse().reduce((inner, outer) => {
|
44
|
+
if (inner === null) {
|
45
|
+
return outer;
|
46
|
+
}
|
47
|
+
|
48
|
+
return Skia.Shader.MakeBlend(blend, outer, inner);
|
49
|
+
}, null);
|
35
50
|
}
|
36
51
|
|
37
52
|
throw new Error("<Blend /> can only blend Shaders or ImageFilters");
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Blend.tsx"],"names":["
|
1
|
+
{"version":3,"sources":["Blend.tsx"],"names":["childrenAreImageFilters","children","every","child","childrenAreShaders","onDeclare","mode","Skia","blend","BlendMode","reverse","reduce","inner","outer","ImageFilter","MakeBlend","Shader","Error","Blend","props"],"mappings":";;;;;;;AACA;;AAGA;;AACA;;AAEA;;;;;;AAGA,MAAMA,uBAAuB,GAC3BC,QAD8B,IAG9BA,QAAQ,CAACC,KAAT,CAAgBC,KAAD,IAAW,0BAAcA,KAAd,CAA1B,CAHF;;AAKA,MAAMC,kBAAkB,GACtBH,QADyB,IAEEA,QAAQ,CAACC,KAAT,CAAgBC,KAAD,IAAW,qBAASA,KAAT,CAA1B,CAF7B;;AASA,MAAME,SAAS,GAAG,8BAChB,OAAWJ,QAAX,YAAkC;AAAA,MAAjC;AAAEK,IAAAA;AAAF,GAAiC;AAAA,MAAb;AAAEC,IAAAA;AAAF,GAAa;;AAChC,QAAMC,KAAK,GAAGC,iBAAU,oBAAQH,IAAR,CAAV,CAAd;;AACA,MAAIN,uBAAuB,CAACC,QAAD,CAA3B,EAAuC;AACrC,WAAOA,QAAQ,CAACS,OAAT,GAAmBC,MAAnB,CAAgD,CAACC,KAAD,EAAQC,KAAR,KAAkB;AACvE,UAAID,KAAK,KAAK,IAAd,EAAoB;AAClB,eAAOC,KAAP;AACD;;AACD,aAAON,IAAI,CAACO,WAAL,CAAiBC,SAAjB,CAA2BP,KAA3B,EAAkCK,KAAlC,EAAyCD,KAAzC,CAAP;AACD,KALM,EAKJ,IALI,CAAP;AAMD,GAPD,MAOO,IAAIR,kBAAkB,CAACH,QAAD,CAAtB,EAAkC;AACvC,WAAOA,QAAQ,CAACS,OAAT,GAAmBC,MAAnB,CAA2C,CAACC,KAAD,EAAQC,KAAR,KAAkB;AAClE,UAAID,KAAK,KAAK,IAAd,EAAoB;AAClB,eAAOC,KAAP;AACD;;AACD,aAAON,IAAI,CAACS,MAAL,CAAYD,SAAZ,CAAsBP,KAAtB,EAA6BK,KAA7B,EAAoCD,KAApC,CAAP;AACD,KALM,EAKJ,IALI,CAAP;AAMD;;AACD,QAAM,IAAIK,KAAJ,CAAU,kDAAV,CAAN;AACD,CAnBe,CAAlB;;AAsBO,MAAMC,KAAK,GAAIC,KAAD,IAAsC;AACzD,sBAAO;AAAe,IAAA,SAAS,EAAEd;AAA1B,KAAyCc,KAAzC,EAAP;AACD,CAFM","sourcesContent":["import type { ReactNode } from \"react\";\nimport React from \"react\";\n\nimport type { SkImageFilter, SkShader } from \"../../skia/types\";\nimport { isImageFilter, BlendMode, isShader } from \"../../skia/types\";\nimport { createDeclaration } from \"../nodes\";\nimport type { AnimatedProps, SkEnum } from \"../processors\";\nimport { enumKey } from \"../processors/Paint\";\nimport type { DeclarationResult } from \"../nodes/Declaration\";\n\nconst childrenAreImageFilters = (\n children: DeclarationResult[]\n): children is SkImageFilter[] =>\n children.every((child) => isImageFilter(child));\n\nconst childrenAreShaders = (\n children: DeclarationResult[]\n): children is SkShader[] => children.every((child) => isShader(child));\n\ninterface BlendProps {\n mode: SkEnum<typeof BlendMode>;\n children?: ReactNode | ReactNode[];\n}\n\nconst onDeclare = createDeclaration<BlendProps>(\n ({ mode }, children, { Skia }) => {\n const blend = BlendMode[enumKey(mode)];\n if (childrenAreImageFilters(children)) {\n return children.reverse().reduce<SkImageFilter | null>((inner, outer) => {\n if (inner === null) {\n return outer;\n }\n return Skia.ImageFilter.MakeBlend(blend, outer, inner);\n }, null);\n } else if (childrenAreShaders(children)) {\n return children.reverse().reduce<SkShader | null>((inner, outer) => {\n if (inner === null) {\n return outer;\n }\n return Skia.Shader.MakeBlend(blend, outer, inner);\n }, null);\n }\n throw new Error(\"<Blend /> can only blend Shaders or ImageFilters\");\n }\n);\n\nexport const Blend = (props: AnimatedProps<BlendProps>) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n"]}
|
@@ -27,7 +27,7 @@ const onDeclare = (0, _Declaration.createDeclaration)((_ref, children, _ref2) =>
|
|
27
27
|
} = _ref2;
|
28
28
|
const input = (0, _getInput.getInput)(Skia, children);
|
29
29
|
const r = (0, _Radius.processRadius)(Skia, radius);
|
30
|
-
const factory = operator === "dilate" ? Skia.ImageFilter.MakeDilate : Skia.ImageFilter.MakeErode;
|
30
|
+
const factory = operator === "dilate" ? Skia.ImageFilter.MakeDilate.bind(Skia.ImageFilter) : Skia.ImageFilter.MakeErode.bind(Skia.ImageFilter);
|
31
31
|
return factory(r.x, r.y, input);
|
32
32
|
});
|
33
33
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Morphology.tsx"],"names":["onDeclare","children","radius","operator","Skia","input","r","factory","ImageFilter","MakeDilate","MakeErode","x","y","Morphology","props","defaultProps"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AAEA;;;;;;AAQA,MAAMA,SAAS,GAAG,oCAChB,OAAuBC,QAAvB,YAA8C;AAAA,MAA7C;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAA6C;AAAA,MAAb;AAAEC,IAAAA;AAAF,GAAa;AAC5C,QAAMC,KAAK,GAAG,wBAASD,IAAT,EAAeH,QAAf,CAAd;AACA,QAAMK,CAAC,GAAG,2BAAcF,IAAd,EAAoBF,MAApB,CAAV;AACA,QAAMK,OAAO,GACXJ,QAAQ,KAAK,QAAb,GACIC,IAAI,CAACI,WAAL,CAAiBC,
|
1
|
+
{"version":3,"sources":["Morphology.tsx"],"names":["onDeclare","children","radius","operator","Skia","input","r","factory","ImageFilter","MakeDilate","bind","MakeErode","x","y","Morphology","props","defaultProps"],"mappings":";;;;;;;AAAA;;AAEA;;AAEA;;AAEA;;;;;;AAQA,MAAMA,SAAS,GAAG,oCAChB,OAAuBC,QAAvB,YAA8C;AAAA,MAA7C;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAA6C;AAAA,MAAb;AAAEC,IAAAA;AAAF,GAAa;AAC5C,QAAMC,KAAK,GAAG,wBAASD,IAAT,EAAeH,QAAf,CAAd;AACA,QAAMK,CAAC,GAAG,2BAAcF,IAAd,EAAoBF,MAApB,CAAV;AACA,QAAMK,OAAO,GACXJ,QAAQ,KAAK,QAAb,GACIC,IAAI,CAACI,WAAL,CAAiBC,UAAjB,CAA4BC,IAA5B,CAAiCN,IAAI,CAACI,WAAtC,CADJ,GAEIJ,IAAI,CAACI,WAAL,CAAiBG,SAAjB,CAA2BD,IAA3B,CAAgCN,IAAI,CAACI,WAArC,CAHN;AAIA,SAAOD,OAAO,CAACD,CAAC,CAACM,CAAH,EAAMN,CAAC,CAACO,CAAR,EAAWR,KAAX,CAAd;AACD,CATe,CAAlB;;AAYO,MAAMS,UAAU,GAAIC,KAAD,IAA2C;AACnE,sBAAO;AAAe,IAAA,SAAS,EAAEf;AAA1B,KAAyCe,KAAzC,EAAP;AACD,CAFM;;;AAIPD,UAAU,CAACE,YAAX,GAA0B;AACxBb,EAAAA,QAAQ,EAAE;AADc,CAA1B","sourcesContent":["import React from \"react\";\n\nimport { createDeclaration } from \"../../nodes/Declaration\";\nimport type { AnimatedProps, Radius } from \"../../processors\";\nimport { processRadius } from \"../../processors/Radius\";\n\nimport { getInput } from \"./getInput\";\n\nexport interface MorphologyProps {\n operator: \"erode\" | \"dilate\";\n radius: Radius;\n children?: React.ReactNode | React.ReactNode[];\n}\n\nconst onDeclare = createDeclaration<MorphologyProps>(\n ({ radius, operator }, children, { Skia }) => {\n const input = getInput(Skia, children);\n const r = processRadius(Skia, radius);\n const factory =\n operator === \"dilate\"\n ? Skia.ImageFilter.MakeDilate.bind(Skia.ImageFilter)\n : Skia.ImageFilter.MakeErode.bind(Skia.ImageFilter);\n return factory(r.x, r.y, input);\n }\n);\n\nexport const Morphology = (props: AnimatedProps<MorphologyProps>) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n\nMorphology.defaultProps = {\n operator: \"dilate\",\n};\n"]}
|
@@ -39,7 +39,7 @@ const onDeclare = (0, _Declaration.createDeclaration)((_ref, children, _ref2) =>
|
|
39
39
|
if (inner) {
|
40
40
|
factory = _InnerShadow.MakeInnerShadow.bind(null, Skia, shadowOnly);
|
41
41
|
} else {
|
42
|
-
factory = shadowOnly ? Skia.ImageFilter.MakeDropShadowOnly : Skia.ImageFilter.MakeDropShadow;
|
42
|
+
factory = shadowOnly ? Skia.ImageFilter.MakeDropShadowOnly.bind(Skia.ImageFilter) : Skia.ImageFilter.MakeDropShadow.bind(Skia.ImageFilter);
|
43
43
|
}
|
44
44
|
|
45
45
|
return factory(dx, dy, blur, blur, color, input);
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Shadow.tsx"],"names":["onDeclare","children","dx","dy","blur","color","cl","shadowOnly","inner","opacity","Skia","input","factory","MakeInnerShadow","bind","ImageFilter","MakeDropShadowOnly","MakeDropShadow","Shadow","props"],"mappings":";;;;;;;AAAA;;AAEA;;AAGA;;AAEA;;AACA;;;;;;AAWA,MAAMA,SAAS,GAAG,oCAChB,OAEEC,QAFF,YAIK;AAAA,MAHH;AAAEC,IAAAA,EAAF;AAAMC,IAAAA,EAAN;AAAUC,IAAAA,IAAV;AAAgBC,IAAAA,KAAK,EAAEC,EAAvB;AAA2BC,IAAAA,UAA3B;AAAuCC,IAAAA;AAAvC,GAGG;AAAA,MADH;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,GACG;AACH,QAAMC,KAAK,GAAG,wBAASD,IAAT,EAAeT,QAAf,CAAd;AACA,QAAMI,KAAK,GAAG,yBAAaK,IAAb,EAAmBJ,EAAnB,EAAuBG,OAAvB,CAAd;AACA,MAAIG,OAAJ;;AACA,MAAIJ,KAAJ,EAAW;AACTI,IAAAA,OAAO,GAAGC,6BAAgBC,IAAhB,CAAqB,IAArB,EAA2BJ,IAA3B,EAAiCH,UAAjC,CAAV;AACD,GAFD,MAEO;AACLK,IAAAA,OAAO,GAAGL,UAAU,GAChBG,IAAI,CAACK,WAAL,CAAiBC,
|
1
|
+
{"version":3,"sources":["Shadow.tsx"],"names":["onDeclare","children","dx","dy","blur","color","cl","shadowOnly","inner","opacity","Skia","input","factory","MakeInnerShadow","bind","ImageFilter","MakeDropShadowOnly","MakeDropShadow","Shadow","props"],"mappings":";;;;;;;AAAA;;AAEA;;AAGA;;AAEA;;AACA;;;;;;AAWA,MAAMA,SAAS,GAAG,oCAChB,OAEEC,QAFF,YAIK;AAAA,MAHH;AAAEC,IAAAA,EAAF;AAAMC,IAAAA,EAAN;AAAUC,IAAAA,IAAV;AAAgBC,IAAAA,KAAK,EAAEC,EAAvB;AAA2BC,IAAAA,UAA3B;AAAuCC,IAAAA;AAAvC,GAGG;AAAA,MADH;AAAEC,IAAAA,OAAF;AAAWC,IAAAA;AAAX,GACG;AACH,QAAMC,KAAK,GAAG,wBAASD,IAAT,EAAeT,QAAf,CAAd;AACA,QAAMI,KAAK,GAAG,yBAAaK,IAAb,EAAmBJ,EAAnB,EAAuBG,OAAvB,CAAd;AACA,MAAIG,OAAJ;;AACA,MAAIJ,KAAJ,EAAW;AACTI,IAAAA,OAAO,GAAGC,6BAAgBC,IAAhB,CAAqB,IAArB,EAA2BJ,IAA3B,EAAiCH,UAAjC,CAAV;AACD,GAFD,MAEO;AACLK,IAAAA,OAAO,GAAGL,UAAU,GAChBG,IAAI,CAACK,WAAL,CAAiBC,kBAAjB,CAAoCF,IAApC,CAAyCJ,IAAI,CAACK,WAA9C,CADgB,GAEhBL,IAAI,CAACK,WAAL,CAAiBE,cAAjB,CAAgCH,IAAhC,CAAqCJ,IAAI,CAACK,WAA1C,CAFJ;AAGD;;AACD,SAAOH,OAAO,CAACV,EAAD,EAAKC,EAAL,EAASC,IAAT,EAAeA,IAAf,EAAqBC,KAArB,EAA4BM,KAA5B,CAAd;AACD,CAjBe,CAAlB;;AAoBO,MAAMO,MAAM,GAAIC,KAAD,IAAuC;AAC3D,sBAAO;AAAe,IAAA,SAAS,EAAEnB;AAA1B,KAAyCmB,KAAzC,EAAP;AACD,CAFM","sourcesContent":["import React from \"react\";\n\nimport { createDeclaration } from \"../../nodes/Declaration\";\nimport type { AnimatedProps } from \"../../processors/Animations/Animations\";\nimport type { Color } from \"../../../skia/types\";\nimport { processColor } from \"../../processors/Color\";\n\nimport { getInput } from \"./getInput\";\nimport { MakeInnerShadow } from \"./InnerShadow\";\n\nexport interface ShadowProps {\n dx: number;\n dy: number;\n blur: number;\n color: Color;\n inner?: boolean;\n shadowOnly?: boolean;\n}\n\nconst onDeclare = createDeclaration<ShadowProps>(\n (\n { dx, dy, blur, color: cl, shadowOnly, inner },\n children,\n { opacity, Skia }\n ) => {\n const input = getInput(Skia, children);\n const color = processColor(Skia, cl, opacity);\n let factory;\n if (inner) {\n factory = MakeInnerShadow.bind(null, Skia, shadowOnly);\n } else {\n factory = shadowOnly\n ? Skia.ImageFilter.MakeDropShadowOnly.bind(Skia.ImageFilter)\n : Skia.ImageFilter.MakeDropShadow.bind(Skia.ImageFilter);\n }\n return factory(dx, dy, blur, blur, color, input);\n }\n);\n\nexport const Shadow = (props: AnimatedProps<ShadowProps>) => {\n return <skDeclaration onDeclare={onDeclare} {...props} />;\n};\n"]}
|
@@ -3,14 +3,13 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.
|
6
|
+
exports.optEnum = exports.ckEnum = exports.NotImplementedOnRNWeb = exports.HostObject = exports.Host = exports.BaseHostObject = void 0;
|
7
7
|
|
8
8
|
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
9
9
|
|
10
|
-
/* eslint-disable no-nested-ternary */
|
11
10
|
class NotImplementedOnRNWeb extends Error {
|
12
|
-
constructor() {
|
13
|
-
super("Not implemented on React Native Web");
|
11
|
+
constructor(msg) {
|
12
|
+
super(msg !== null && msg !== void 0 ? msg : "Not implemented on React Native Web");
|
14
13
|
}
|
15
14
|
|
16
15
|
}
|
@@ -28,7 +27,7 @@ class Host {
|
|
28
27
|
|
29
28
|
exports.Host = Host;
|
30
29
|
|
31
|
-
class
|
30
|
+
class BaseHostObject extends Host {
|
32
31
|
constructor(CanvasKit, ref, typename) {
|
33
32
|
super(CanvasKit);
|
34
33
|
|
@@ -40,26 +39,18 @@ class HostObject extends Host {
|
|
40
39
|
this.__typename__ = typename;
|
41
40
|
}
|
42
41
|
|
43
|
-
}
|
44
|
-
|
45
|
-
|
46
|
-
exports.HostObject = HostObject;
|
47
|
-
|
48
|
-
const toOptionalValue = value => value === undefined ? undefined : value === null ? null : toValue(value);
|
49
|
-
|
50
|
-
exports.toOptionalValue = toOptionalValue;
|
51
|
-
|
52
|
-
const toUndefinedableValue = value => value === undefined ? undefined : toValue(value);
|
53
|
-
|
54
|
-
exports.toUndefinedableValue = toUndefinedableValue;
|
42
|
+
}
|
55
43
|
|
56
|
-
|
44
|
+
exports.BaseHostObject = BaseHostObject;
|
57
45
|
|
58
|
-
|
46
|
+
class HostObject extends BaseHostObject {
|
47
|
+
static fromValue(value) {
|
48
|
+
return value.ref;
|
49
|
+
}
|
59
50
|
|
60
|
-
|
51
|
+
}
|
61
52
|
|
62
|
-
exports.
|
53
|
+
exports.HostObject = HostObject;
|
63
54
|
|
64
55
|
const ckEnum = value => ({
|
65
56
|
value
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["Host.ts"],"names":["NotImplementedOnRNWeb","Error","constructor","Host","CanvasKit","
|
1
|
+
{"version":3,"sources":["Host.ts"],"names":["NotImplementedOnRNWeb","Error","constructor","msg","Host","CanvasKit","BaseHostObject","ref","typename","__typename__","HostObject","fromValue","value","ckEnum","optEnum","undefined"],"mappings":";;;;;;;;;AAIO,MAAMA,qBAAN,SAAoCC,KAApC,CAA0C;AAC/CC,EAAAA,WAAW,CAACC,GAAD,EAAe;AACxB,UAAMA,GAAN,aAAMA,GAAN,cAAMA,GAAN,GAAa,qCAAb;AACD;;AAH8C;;;;AAM1C,MAAeC,IAAf,CAAoB;AAGzBF,EAAAA,WAAW,CAACG,SAAD,EAAuB;AAAA;;AAChC,SAAKA,SAAL,GAAiBA,SAAjB;AACD;;AALwB;;;;AAQpB,MAAeC,cAAf,SACGF,IADH,CAGP;AAIEF,EAAAA,WAAW,CAACG,SAAD,EAAuBE,GAAvB,EAA+BC,QAA/B,EAA4C;AACrD,UAAMH,SAAN;;AADqD;;AAAA;;AAErD,SAAKE,GAAL,GAAWA,GAAX;AACA,SAAKE,YAAL,GAAoBD,QAApB;AACD;;AARH;;;;AAWO,MAAeE,UAAf,SAAuDJ,cAAvD,CAGL;AACgB,SAATK,SAAS,CAAIC,KAAJ,EAAkC;AAChD,WAAQA,KAAD,CAAiCL,GAAxC;AACD;;AAHD;;;;AAMK,MAAMM,MAAM,GAAID,KAAD,KAAsC;AAAEA,EAAAA;AAAF,CAAtC,CAAf;;;;AACA,MAAME,OAAO,GAClBF,KADqB,IAGrBA,KAAK,KAAKG,SAAV,GAAsBA,SAAtB,GAAkC;AAAEH,EAAAA;AAAF,CAH7B","sourcesContent":["import type { CanvasKit, EmbindEnumEntity } from \"canvaskit-wasm\";\n\nimport type { SkJSIInstance } from \"../types\";\n\nexport class NotImplementedOnRNWeb extends Error {\n constructor(msg?: string) {\n super(msg ?? \"Not implemented on React Native Web\");\n }\n}\n\nexport abstract class Host {\n readonly CanvasKit: CanvasKit;\n\n constructor(CanvasKit: CanvasKit) {\n this.CanvasKit = CanvasKit;\n }\n}\n\nexport abstract class BaseHostObject<T, N extends string>\n extends Host\n implements SkJSIInstance<N>\n{\n readonly __typename__: N;\n readonly ref: T;\n\n constructor(CanvasKit: CanvasKit, ref: T, typename: N) {\n super(CanvasKit);\n this.ref = ref;\n this.__typename__ = typename;\n }\n}\n\nexport abstract class HostObject<T, N extends string> extends BaseHostObject<\n T,\n N\n> {\n static fromValue<T>(value: SkJSIInstance<string>) {\n return (value as HostObject<T, string>).ref;\n }\n}\n\nexport const ckEnum = (value: number): EmbindEnumEntity => ({ value });\nexport const optEnum = (\n value: number | undefined\n): EmbindEnumEntity | undefined =>\n value === undefined ? undefined : { value };\n"]}
|
@@ -7,61 +7,81 @@ exports.JsiSkCanvas = void 0;
|
|
7
7
|
|
8
8
|
var _Host = require("./Host");
|
9
9
|
|
10
|
+
var _JsiSkPaint = require("./JsiSkPaint");
|
11
|
+
|
10
12
|
var _JsiSkRect = require("./JsiSkRect");
|
11
13
|
|
12
14
|
var _JsiSkRRect = require("./JsiSkRRect");
|
13
15
|
|
16
|
+
var _JsiSkImage = require("./JsiSkImage");
|
17
|
+
|
18
|
+
var _JsiSkVertices = require("./JsiSkVertices");
|
19
|
+
|
20
|
+
var _JsiSkPath = require("./JsiSkPath");
|
21
|
+
|
22
|
+
var _JsiSkFont = require("./JsiSkFont");
|
23
|
+
|
24
|
+
var _JsiSkTextBlob = require("./JsiSkTextBlob");
|
25
|
+
|
26
|
+
var _JsiSkPicture = require("./JsiSkPicture");
|
27
|
+
|
28
|
+
var _JsiSkMatrix = require("./JsiSkMatrix");
|
29
|
+
|
30
|
+
var _JsiSkImageFilter = require("./JsiSkImageFilter");
|
31
|
+
|
32
|
+
var _JsiSkPoint = require("./JsiSkPoint");
|
33
|
+
|
14
34
|
class JsiSkCanvas extends _Host.HostObject {
|
15
35
|
constructor(CanvasKit, ref) {
|
16
36
|
super(CanvasKit, ref, "Canvas");
|
17
37
|
}
|
18
38
|
|
19
39
|
drawRect(rect, paint) {
|
20
|
-
this.ref.drawRect(_JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, rect),
|
40
|
+
this.ref.drawRect(_JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, rect), _JsiSkPaint.JsiSkPaint.fromValue(paint));
|
21
41
|
}
|
22
42
|
|
23
43
|
drawImage(image, x, y, paint) {
|
24
|
-
this.ref.drawImage(
|
44
|
+
this.ref.drawImage(_JsiSkImage.JsiSkImage.fromValue(image), x, y, paint ? _JsiSkPaint.JsiSkPaint.fromValue(paint) : paint);
|
25
45
|
}
|
26
46
|
|
27
47
|
drawImageRect(img, src, dest, paint, fastSample) {
|
28
|
-
this.ref.drawImageRect(
|
48
|
+
this.ref.drawImageRect(_JsiSkImage.JsiSkImage.fromValue(img), _JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, src), _JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, dest), _JsiSkPaint.JsiSkPaint.fromValue(paint), fastSample);
|
29
49
|
}
|
30
50
|
|
31
51
|
drawImageCubic(img, left, top, B, C, paint) {
|
32
|
-
this.ref.drawImageCubic(
|
52
|
+
this.ref.drawImageCubic(_JsiSkImage.JsiSkImage.fromValue(img), left, top, B, C, paint ? _JsiSkPaint.JsiSkPaint.fromValue(paint) : paint);
|
33
53
|
}
|
34
54
|
|
35
55
|
drawImageOptions(img, left, top, fm, mm, paint) {
|
36
|
-
this.ref.drawImageOptions(
|
56
|
+
this.ref.drawImageOptions(_JsiSkImage.JsiSkImage.fromValue(img), left, top, (0, _Host.ckEnum)(fm), (0, _Host.ckEnum)(mm), paint ? _JsiSkPaint.JsiSkPaint.fromValue(paint) : paint);
|
37
57
|
}
|
38
58
|
|
39
59
|
drawImageNine(img, center, dest, filter, paint) {
|
40
|
-
this.ref.drawImageNine(
|
60
|
+
this.ref.drawImageNine(_JsiSkImage.JsiSkImage.fromValue(img), Array.from(_JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, center)), _JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, dest), (0, _Host.ckEnum)(filter), paint ? _JsiSkPaint.JsiSkPaint.fromValue(paint) : paint);
|
41
61
|
}
|
42
62
|
|
43
63
|
drawImageRectCubic(img, src, dest, B, C, paint) {
|
44
|
-
this.ref.drawImageRectCubic(
|
64
|
+
this.ref.drawImageRectCubic(_JsiSkImage.JsiSkImage.fromValue(img), _JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, src), _JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, dest), B, C, paint ? _JsiSkPaint.JsiSkPaint.fromValue(paint) : paint);
|
45
65
|
}
|
46
66
|
|
47
67
|
drawImageRectOptions(img, src, dest, fm, mm, paint) {
|
48
|
-
this.ref.drawImageRectOptions(
|
68
|
+
this.ref.drawImageRectOptions(_JsiSkImage.JsiSkImage.fromValue(img), _JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, src), _JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, dest), (0, _Host.ckEnum)(fm), (0, _Host.ckEnum)(mm), paint ? _JsiSkPaint.JsiSkPaint.fromValue(paint) : paint);
|
49
69
|
}
|
50
70
|
|
51
71
|
drawPaint(paint) {
|
52
|
-
this.ref.drawPaint(
|
72
|
+
this.ref.drawPaint(_JsiSkPaint.JsiSkPaint.fromValue(paint));
|
53
73
|
}
|
54
74
|
|
55
75
|
drawLine(x0, y0, x1, y1, paint) {
|
56
|
-
this.ref.drawLine(x0, y0, x1, y1,
|
76
|
+
this.ref.drawLine(x0, y0, x1, y1, _JsiSkPaint.JsiSkPaint.fromValue(paint));
|
57
77
|
}
|
58
78
|
|
59
79
|
drawCircle(cx, cy, radius, paint) {
|
60
|
-
this.ref.drawCircle(cx, cy, radius,
|
80
|
+
this.ref.drawCircle(cx, cy, radius, _JsiSkPaint.JsiSkPaint.fromValue(paint));
|
61
81
|
}
|
62
82
|
|
63
83
|
drawVertices(verts, mode, paint) {
|
64
|
-
this.ref.drawVertices(
|
84
|
+
this.ref.drawVertices(_JsiSkVertices.JsiSkVertices.fromValue(verts), (0, _Host.ckEnum)(mode), _JsiSkPaint.JsiSkPaint.fromValue(paint));
|
65
85
|
}
|
66
86
|
|
67
87
|
drawPatch(cubics, colors, texs, mode, paint) {
|
@@ -71,7 +91,7 @@ class JsiSkCanvas extends _Host.HostObject {
|
|
71
91
|
y
|
72
92
|
} = _ref;
|
73
93
|
return [x, y];
|
74
|
-
}).flat(), colors, (
|
94
|
+
}).flat(), colors, texs ? texs.flatMap(p => Array.from(_JsiSkPoint.JsiSkPoint.fromValue(p))) : texs, mode ? (0, _Host.ckEnum)(mode) : null, paint ? _JsiSkPaint.JsiSkPaint.fromValue(paint) : undefined);
|
75
95
|
}
|
76
96
|
|
77
97
|
restoreToCount(saveCount) {
|
@@ -85,39 +105,39 @@ class JsiSkCanvas extends _Host.HostObject {
|
|
85
105
|
y
|
86
106
|
} = _ref2;
|
87
107
|
return [x, y];
|
88
|
-
}).flat(),
|
108
|
+
}).flat(), _JsiSkPaint.JsiSkPaint.fromValue(paint));
|
89
109
|
}
|
90
110
|
|
91
111
|
drawArc(oval, startAngle, sweepAngle, useCenter, paint) {
|
92
|
-
this.ref.drawArc((
|
112
|
+
this.ref.drawArc(_JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, oval), startAngle, sweepAngle, useCenter, _JsiSkPaint.JsiSkPaint.fromValue(paint));
|
93
113
|
}
|
94
114
|
|
95
115
|
drawRRect(rrect, paint) {
|
96
|
-
this.ref.drawRRect(_JsiSkRRect.JsiSkRRect.fromValue(this.CanvasKit, rrect),
|
116
|
+
this.ref.drawRRect(_JsiSkRRect.JsiSkRRect.fromValue(this.CanvasKit, rrect), _JsiSkPaint.JsiSkPaint.fromValue(paint));
|
97
117
|
}
|
98
118
|
|
99
119
|
drawDRRect(outer, inner, paint) {
|
100
|
-
this.ref.drawDRRect((
|
120
|
+
this.ref.drawDRRect(_JsiSkRRect.JsiSkRRect.fromValue(this.CanvasKit, outer), _JsiSkRRect.JsiSkRRect.fromValue(this.CanvasKit, inner), _JsiSkPaint.JsiSkPaint.fromValue(paint));
|
101
121
|
}
|
102
122
|
|
103
123
|
drawOval(oval, paint) {
|
104
|
-
this.ref.drawOval((
|
124
|
+
this.ref.drawOval(_JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, oval), _JsiSkPaint.JsiSkPaint.fromValue(paint));
|
105
125
|
}
|
106
126
|
|
107
127
|
drawPath(path, paint) {
|
108
|
-
this.ref.drawPath(
|
128
|
+
this.ref.drawPath(_JsiSkPath.JsiSkPath.fromValue(path), _JsiSkPaint.JsiSkPaint.fromValue(paint));
|
109
129
|
}
|
110
130
|
|
111
131
|
drawText(str, x, y, paint, font) {
|
112
|
-
this.ref.drawText(str, x, y,
|
132
|
+
this.ref.drawText(str, x, y, _JsiSkPaint.JsiSkPaint.fromValue(paint), _JsiSkFont.JsiSkFont.fromValue(font));
|
113
133
|
}
|
114
134
|
|
115
135
|
drawTextBlob(blob, x, y, paint) {
|
116
|
-
this.ref.drawTextBlob(
|
136
|
+
this.ref.drawTextBlob(_JsiSkTextBlob.JsiSkTextBlob.fromValue(blob), x, y, _JsiSkPaint.JsiSkPaint.fromValue(paint));
|
117
137
|
}
|
118
138
|
|
119
139
|
drawGlyphs(glyphs, positions, x, y, font, paint) {
|
120
|
-
this.ref.drawGlyphs(glyphs, positions.map(p => [p.x, p.y]).flat(), x, y,
|
140
|
+
this.ref.drawGlyphs(glyphs, positions.map(p => [p.x, p.y]).flat(), x, y, _JsiSkFont.JsiSkFont.fromValue(font), _JsiSkPaint.JsiSkPaint.fromValue(paint));
|
121
141
|
}
|
122
142
|
|
123
143
|
drawSvg(_svgDom, _width, _height) {
|
@@ -129,7 +149,7 @@ class JsiSkCanvas extends _Host.HostObject {
|
|
129
149
|
}
|
130
150
|
|
131
151
|
saveLayer(paint, bounds, backdrop, flags) {
|
132
|
-
return this.ref.saveLayer(
|
152
|
+
return this.ref.saveLayer(paint ? _JsiSkPaint.JsiSkPaint.fromValue(paint) : undefined, bounds ? _JsiSkRect.JsiSkRect.fromValue(this.CanvasKit, bounds) : bounds, backdrop ? _JsiSkImageFilter.JsiSkImageFilter.fromValue(backdrop) : backdrop, flags);
|
133
153
|
}
|
134
154
|
|
135
155
|
restore() {
|
@@ -161,7 +181,7 @@ class JsiSkCanvas extends _Host.HostObject {
|
|
161
181
|
}
|
162
182
|
|
163
183
|
clipPath(path, op, doAntiAlias) {
|
164
|
-
this.ref.clipPath(
|
184
|
+
this.ref.clipPath(_JsiSkPath.JsiSkPath.fromValue(path), (0, _Host.ckEnum)(op), doAntiAlias);
|
165
185
|
}
|
166
186
|
|
167
187
|
clipRect(rect, op, doAntiAlias) {
|
@@ -173,11 +193,11 @@ class JsiSkCanvas extends _Host.HostObject {
|
|
173
193
|
}
|
174
194
|
|
175
195
|
concat(m) {
|
176
|
-
this.ref.concat(
|
196
|
+
this.ref.concat(_JsiSkMatrix.JsiSkMatrix.fromValue(m));
|
177
197
|
}
|
178
198
|
|
179
199
|
drawPicture(skp) {
|
180
|
-
this.ref.drawPicture(
|
200
|
+
this.ref.drawPicture(_JsiSkPicture.JsiSkPicture.fromValue(skp));
|
181
201
|
}
|
182
202
|
|
183
203
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["JsiSkCanvas.ts"],"names":["JsiSkCanvas","HostObject","constructor","CanvasKit","ref","drawRect","rect","paint","JsiSkRect","fromValue","drawImage","image","x","y","drawImageRect","img","src","dest","fastSample","drawImageCubic","left","top","B","C","drawImageOptions","fm","mm","drawImageNine","center","filter","drawImageRectCubic","drawImageRectOptions","drawPaint","drawLine","x0","y0","x1","y1","drawCircle","cx","cy","radius","drawVertices","verts","mode","drawPatch","cubics","colors","texs","map","flat","restoreToCount","saveCount","drawPoints","points","drawArc","oval","startAngle","sweepAngle","useCenter","drawRRect","rrect","JsiSkRRect","drawDRRect","outer","inner","drawOval","drawPath","path","drawText","str","font","drawTextBlob","blob","drawGlyphs","glyphs","positions","p","drawSvg","_svgDom","_width","_height","Error","save","saveLayer","bounds","backdrop","flags","restore","rotate","rotationInDegrees","rx","ry","scale","sx","sy","skew","translate","dx","dy","drawColor","color","blendMode","undefined","clear","clipPath","op","doAntiAlias","clipRect","clipRRect","concat","m","drawPicture","skp"],"mappings":";;;;;;;AA0BA;;AAOA;;AACA;;AAEO,MAAMA,WAAN,SACGC,gBADH,CAGP;AACEC,EAAAA,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAoC;AAC7C,UAAMD,SAAN,EAAiBC,GAAjB,EAAsB,QAAtB;AACD;;AAEDC,EAAAA,QAAQ,CAACC,IAAD,EAAeC,KAAf,EAA+B;AACrC,SAAKH,GAAL,CAASC,QAAT,CACEG,qBAAUC,SAAV,CAAoB,KAAKN,SAAzB,EAAoCG,IAApC,CADF,EAEE,mBAAeC,KAAf,CAFF;AAID;;AAEDG,EAAAA,SAAS,CAACC,KAAD,EAAiBC,CAAjB,EAA4BC,CAA5B,EAAuCN,KAAvC,EAAwD;AAC/D,SAAKH,GAAL,CAASM,SAAT,CAAmB,mBAAeC,KAAf,CAAnB,EAA0CC,CAA1C,EAA6CC,CAA7C,EAAgD,2BAAgBN,KAAhB,CAAhD;AACD;;AAEDO,EAAAA,aAAa,CACXC,GADW,EAEXC,GAFW,EAGXC,IAHW,EAIXV,KAJW,EAKXW,UALW,EAMX;AACA,SAAKd,GAAL,CAASU,aAAT,CACE,mBAAeC,GAAf,CADF,EAEEP,qBAAUC,SAAV,CAAoB,KAAKN,SAAzB,EAAoCa,GAApC,CAFF,EAGER,qBAAUC,SAAV,CAAoB,KAAKN,SAAzB,EAAoCc,IAApC,CAHF,EAIE,mBAAeV,KAAf,CAJF,EAKEW,UALF;AAOD;;AAEDC,EAAAA,cAAc,CACZJ,GADY,EAEZK,IAFY,EAGZC,GAHY,EAIZC,CAJY,EAKZC,CALY,EAMZhB,KANY,EAOZ;AACA,SAAKH,GAAL,CAASe,cAAT,CACE,mBAAQJ,GAAR,CADF,EAEEK,IAFF,EAGEC,GAHF,EAIEC,CAJF,EAKEC,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C,EAAAA,QAAQ,CAACtG,IAAD,EAAeoG,EAAf,EAA2BC,WAA3B,EAAiD;AACvD,SAAKvG,GAAL,CAASwG,QAAT,CACEpG,qBAAUC,SAAV,CAAoB,KAAKN,SAAzB,EAAoCG,IAApC,CADF,EAEE,kBAAOoG,EAAP,CAFF,EAGEC,WAHF;AAKD;;AAEDE,EAAAA,SAAS,CAAChD,KAAD,EAAiB6C,EAAjB,EAA6BC,WAA7B,EAAmD;AAC1D,SAAKvG,GAAL,CAASyG,SAAT,CACE/C,uBAAWrD,SAAX,CAAqB,KAAKN,SAA1B,EAAqC0D,KAArC,CADF,EAEE,kBAAO6C,EAAP,CAFF,EAGEC,WAHF;AAKD;;AAEDG,EAAAA,MAAM,CAACC,CAAD,EAAc;AAClB,SAAK3G,GAAL,CAAS0G,MAAT,CAAgB,mBAAQC,CAAR,CAAhB;AACD;;AAEDC,EAAAA,WAAW,CAACC,GAAD,EAAiB;AAC1B,SAAK7G,GAAL,CAAS4G,WAAT,CAAqB,mBAAQC,GAAR,CAArB;AACD;;AA7SH","sourcesContent":["import type { Canvas, Image, CanvasKit, Paint } from \"canvaskit-wasm\";\n\nimport type {\n BlendMode,\n ClipOp,\n FilterMode,\n MipmapMode,\n PointMode,\n SaveLayerFlag,\n SkCanvas,\n SkColor,\n SkFont,\n SkImage,\n SkImageFilter,\n SkMatrix,\n SkPaint,\n SkPath,\n SkPicture,\n SkPoint,\n SkRect,\n SkRRect,\n SkSVG,\n SkTextBlob,\n SkVertices,\n} from \"../types\";\n\nimport {\n ckEnum,\n HostObject,\n toValue,\n toUndefinedableValue,\n toOptionalValue,\n} from \"./Host\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\n\nexport class JsiSkCanvas\n extends HostObject<Canvas, \"Canvas\">\n implements SkCanvas\n{\n constructor(CanvasKit: CanvasKit, ref: Canvas) {\n super(CanvasKit, ref, \"Canvas\");\n }\n\n drawRect(rect: SkRect, paint: SkPaint) {\n this.ref.drawRect(\n JsiSkRect.fromValue(this.CanvasKit, rect),\n toValue<Paint>(paint)\n );\n }\n\n drawImage(image: SkImage, x: number, y: number, paint?: SkPaint) {\n this.ref.drawImage(toValue<Image>(image), x, y, toOptionalValue(paint));\n }\n\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ) {\n this.ref.drawImageRect(\n toValue<Image>(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n toValue<Paint>(paint),\n fastSample\n );\n }\n\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageCubic(\n toValue(img),\n left,\n top,\n B,\n C,\n toOptionalValue(paint)\n );\n }\n\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageOptions(\n toValue(img),\n left,\n top,\n ckEnum(fm),\n ckEnum(mm),\n toOptionalValue(paint)\n );\n }\n\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageNine(\n toValue(img),\n toValue(center),\n toValue(dest),\n ckEnum(filter),\n toOptionalValue(paint)\n );\n }\n\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectCubic(\n toValue<Image>(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n B,\n C,\n toOptionalValue(paint)\n );\n }\n\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectOptions(\n toValue<Image>(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n ckEnum(fm),\n ckEnum(mm),\n toOptionalValue(paint)\n );\n }\n\n drawPaint(paint: SkPaint) {\n this.ref.drawPaint(toValue(paint));\n }\n\n drawLine(x0: number, y0: number, x1: number, y1: number, paint: SkPaint) {\n this.ref.drawLine(x0, y0, x1, y1, toValue(paint));\n }\n\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint) {\n this.ref.drawCircle(cx, cy, radius, toValue(paint));\n }\n\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint) {\n this.ref.drawVertices(toValue(verts), ckEnum(mode), toValue(paint));\n }\n\n drawPatch(\n cubics: SkPoint[],\n colors?: SkColor[] | null,\n texs?: SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ) {\n this.ref.drawPatch(\n cubics.map(({ x, y }) => [x, y]).flat(),\n colors,\n toOptionalValue(texs),\n mode ? ckEnum(mode) : null,\n toUndefinedableValue(paint)\n );\n }\n\n restoreToCount(saveCount: number) {\n this.ref.restoreToCount(saveCount);\n }\n\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint) {\n this.ref.drawPoints(\n ckEnum(mode),\n points.map(({ x, y }) => [x, y]).flat(),\n toValue(paint)\n );\n }\n\n drawArc(\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) {\n this.ref.drawArc(\n toValue(oval),\n startAngle,\n sweepAngle,\n useCenter,\n toValue(paint)\n );\n }\n\n drawRRect(rrect: SkRRect, paint: SkPaint) {\n this.ref.drawRRect(\n JsiSkRRect.fromValue(this.CanvasKit, rrect),\n toValue(paint)\n );\n }\n\n drawDRRect(outer: SkRRect, inner: SkRRect, paint: SkPaint) {\n this.ref.drawDRRect(toValue(outer), toValue(inner), toValue(paint));\n }\n\n drawOval(oval: SkRect, paint: SkPaint) {\n this.ref.drawOval(toValue(oval), toValue(paint));\n }\n\n drawPath(path: SkPath, paint: SkPaint) {\n this.ref.drawPath(toValue(path), toValue(paint));\n }\n\n drawText(str: string, x: number, y: number, paint: SkPaint, font: SkFont) {\n this.ref.drawText(str, x, y, toValue(paint), toValue(font));\n }\n\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint) {\n this.ref.drawTextBlob(toValue(blob), x, y, toValue(paint));\n }\n\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ) {\n this.ref.drawGlyphs(\n glyphs,\n positions.map((p) => [p.x, p.y]).flat(),\n x,\n y,\n toValue(font),\n toValue(paint)\n );\n }\n\n drawSvg(_svgDom: SkSVG, _width?: number, _height?: number) {\n throw new Error(\"drawSvg is not implemented on React Native Web\");\n }\n\n save() {\n return this.ref.save();\n }\n\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ) {\n return this.ref.saveLayer(\n toUndefinedableValue(paint),\n toOptionalValue(bounds),\n toOptionalValue(backdrop),\n flags\n );\n }\n\n restore() {\n this.ref.restore();\n }\n\n rotate(rotationInDegrees: number, rx: number, ry: number) {\n this.ref.rotate(rotationInDegrees, rx, ry);\n }\n\n scale(sx: number, sy: number) {\n this.ref.scale(sx, sy);\n }\n\n skew(sx: number, sy: number) {\n this.ref.skew(sx, sy);\n }\n\n translate(dx: number, dy: number) {\n this.ref.translate(dx, dy);\n }\n\n drawColor(color: SkColor, blendMode?: BlendMode) {\n this.ref.drawColor(color, blendMode ? ckEnum(blendMode) : undefined);\n }\n\n clear(color: SkColor) {\n this.ref.clear(color);\n }\n\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipPath(toValue(path), ckEnum(op), doAntiAlias);\n }\n\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRect(\n JsiSkRect.fromValue(this.CanvasKit, rect),\n ckEnum(op),\n doAntiAlias\n );\n }\n\n clipRRect(rrect: SkRRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRRect(\n JsiSkRRect.fromValue(this.CanvasKit, rrect),\n ckEnum(op),\n doAntiAlias\n );\n }\n\n concat(m: SkMatrix) {\n this.ref.concat(toValue(m));\n }\n\n drawPicture(skp: SkPicture) {\n this.ref.drawPicture(toValue(skp));\n }\n}\n"]}
|
1
|
+
{"version":3,"sources":["JsiSkCanvas.ts"],"names":["JsiSkCanvas","HostObject","constructor","CanvasKit","ref","drawRect","rect","paint","JsiSkRect","fromValue","JsiSkPaint","drawImage","image","x","y","JsiSkImage","drawImageRect","img","src","dest","fastSample","drawImageCubic","left","top","B","C","drawImageOptions","fm","mm","drawImageNine","center","filter","Array","from","drawImageRectCubic","drawImageRectOptions","drawPaint","drawLine","x0","y0","x1","y1","drawCircle","cx","cy","radius","drawVertices","verts","mode","JsiSkVertices","drawPatch","cubics","colors","texs","map","flat","flatMap","p","JsiSkPoint","undefined","restoreToCount","saveCount","drawPoints","points","drawArc","oval","startAngle","sweepAngle","useCenter","drawRRect","rrect","JsiSkRRect","drawDRRect","outer","inner","drawOval","drawPath","path","JsiSkPath","drawText","str","font","JsiSkFont","drawTextBlob","blob","JsiSkTextBlob","drawGlyphs","glyphs","positions","drawSvg","_svgDom","_width","_height","Error","save","saveLayer","bounds","backdrop","flags","JsiSkImageFilter","restore","rotate","rotationInDegrees","rx","ry","scale","sx","sy","skew","translate","dx","dy","drawColor","color","blendMode","clear","clipPath","op","doAntiAlias","clipRect","clipRRect","concat","m","JsiSkMatrix","drawPicture","skp","JsiSkPicture"],"mappings":";;;;;;;AA0BA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;AAEO,MAAMA,WAAN,SACGC,gBADH,CAGP;AACEC,EAAAA,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAoC;AAC7C,UAAMD,SAAN,EAAiBC,GAAjB,EAAsB,QAAtB;AACD;;AAEDC,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,SAAKlH,GAAL,CAASoH,SAAT,CACEjD,uBAAW9D,SAAX,CAAqB,KAAKN,SAA1B,EAAqCmE,KAArC,CADF,EAEE,kBAAO+C,EAAP,CAFF,EAGEC,WAHF;AAKD;;AAEDG,EAAAA,MAAM,CAACC,CAAD,EAAc;AAClB,SAAKtH,GAAL,CAASqH,MAAT,CAAgBE,yBAAYlH,SAAZ,CAAsBiH,CAAtB,CAAhB;AACD;;AAEDE,EAAAA,WAAW,CAACC,GAAD,EAAiB;AAC1B,SAAKzH,GAAL,CAASwH,WAAT,CAAqBE,2BAAarH,SAAb,CAAuBoH,GAAvB,CAArB;AACD;;AAxUH","sourcesContent":["import type { Canvas, CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n BlendMode,\n ClipOp,\n FilterMode,\n MipmapMode,\n PointMode,\n SaveLayerFlag,\n SkCanvas,\n SkColor,\n SkFont,\n SkImage,\n SkImageFilter,\n SkMatrix,\n SkPaint,\n SkPath,\n SkPicture,\n SkPoint,\n SkRect,\n SkRRect,\n SkSVG,\n SkTextBlob,\n SkVertices,\n} from \"../types\";\n\nimport { ckEnum, HostObject } from \"./Host\";\nimport { JsiSkPaint } from \"./JsiSkPaint\";\nimport { JsiSkRect } from \"./JsiSkRect\";\nimport { JsiSkRRect } from \"./JsiSkRRect\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkVertices } from \"./JsiSkVertices\";\nimport { JsiSkPath } from \"./JsiSkPath\";\nimport { JsiSkFont } from \"./JsiSkFont\";\nimport { JsiSkTextBlob } from \"./JsiSkTextBlob\";\nimport { JsiSkPicture } from \"./JsiSkPicture\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkImageFilter } from \"./JsiSkImageFilter\";\nimport { JsiSkPoint } from \"./JsiSkPoint\";\n\nexport class JsiSkCanvas\n extends HostObject<Canvas, \"Canvas\">\n implements SkCanvas\n{\n constructor(CanvasKit: CanvasKit, ref: Canvas) {\n super(CanvasKit, ref, \"Canvas\");\n }\n\n drawRect(rect: SkRect, paint: SkPaint) {\n this.ref.drawRect(\n JsiSkRect.fromValue(this.CanvasKit, rect),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawImage(image: SkImage, x: number, y: number, paint?: SkPaint) {\n this.ref.drawImage(\n JsiSkImage.fromValue(image),\n x,\n y,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRect(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n paint: SkPaint,\n fastSample?: boolean\n ) {\n this.ref.drawImageRect(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n JsiSkPaint.fromValue(paint),\n fastSample\n );\n }\n\n drawImageCubic(\n img: SkImage,\n left: number,\n top: number,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageCubic(\n JsiSkImage.fromValue(img),\n left,\n top,\n B,\n C,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageOptions(\n img: SkImage,\n left: number,\n top: number,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageOptions(\n JsiSkImage.fromValue(img),\n left,\n top,\n ckEnum(fm),\n ckEnum(mm),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageNine(\n img: SkImage,\n center: SkRect,\n dest: SkRect,\n filter: FilterMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageNine(\n JsiSkImage.fromValue(img),\n Array.from(JsiSkRect.fromValue(this.CanvasKit, center)),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n ckEnum(filter),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRectCubic(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n B: number,\n C: number,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectCubic(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n B,\n C,\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawImageRectOptions(\n img: SkImage,\n src: SkRect,\n dest: SkRect,\n fm: FilterMode,\n mm: MipmapMode,\n paint?: SkPaint | null\n ) {\n this.ref.drawImageRectOptions(\n JsiSkImage.fromValue(img),\n JsiSkRect.fromValue(this.CanvasKit, src),\n JsiSkRect.fromValue(this.CanvasKit, dest),\n ckEnum(fm),\n ckEnum(mm),\n paint ? JsiSkPaint.fromValue(paint) : paint\n );\n }\n\n drawPaint(paint: SkPaint) {\n this.ref.drawPaint(JsiSkPaint.fromValue(paint));\n }\n\n drawLine(x0: number, y0: number, x1: number, y1: number, paint: SkPaint) {\n this.ref.drawLine(x0, y0, x1, y1, JsiSkPaint.fromValue(paint));\n }\n\n drawCircle(cx: number, cy: number, radius: number, paint: SkPaint) {\n this.ref.drawCircle(cx, cy, radius, JsiSkPaint.fromValue(paint));\n }\n\n drawVertices(verts: SkVertices, mode: BlendMode, paint: SkPaint) {\n this.ref.drawVertices(\n JsiSkVertices.fromValue(verts),\n ckEnum(mode),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawPatch(\n cubics: SkPoint[],\n colors?: SkColor[] | null,\n texs?: SkPoint[] | null,\n mode?: BlendMode | null,\n paint?: SkPaint\n ) {\n this.ref.drawPatch(\n cubics.map(({ x, y }) => [x, y]).flat(),\n colors,\n texs ? texs.flatMap((p) => Array.from(JsiSkPoint.fromValue(p))) : texs,\n mode ? ckEnum(mode) : null,\n paint ? JsiSkPaint.fromValue(paint) : undefined\n );\n }\n\n restoreToCount(saveCount: number) {\n this.ref.restoreToCount(saveCount);\n }\n\n drawPoints(mode: PointMode, points: SkPoint[], paint: SkPaint) {\n this.ref.drawPoints(\n ckEnum(mode),\n points.map(({ x, y }) => [x, y]).flat(),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawArc(\n oval: SkRect,\n startAngle: number,\n sweepAngle: number,\n useCenter: boolean,\n paint: SkPaint\n ) {\n this.ref.drawArc(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n startAngle,\n sweepAngle,\n useCenter,\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawRRect(rrect: SkRRect, paint: SkPaint) {\n this.ref.drawRRect(\n JsiSkRRect.fromValue(this.CanvasKit, rrect),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawDRRect(outer: SkRRect, inner: SkRRect, paint: SkPaint) {\n this.ref.drawDRRect(\n JsiSkRRect.fromValue(this.CanvasKit, outer),\n JsiSkRRect.fromValue(this.CanvasKit, inner),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawOval(oval: SkRect, paint: SkPaint) {\n this.ref.drawOval(\n JsiSkRect.fromValue(this.CanvasKit, oval),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawPath(path: SkPath, paint: SkPaint) {\n this.ref.drawPath(JsiSkPath.fromValue(path), JsiSkPaint.fromValue(paint));\n }\n\n drawText(str: string, x: number, y: number, paint: SkPaint, font: SkFont) {\n this.ref.drawText(\n str,\n x,\n y,\n JsiSkPaint.fromValue(paint),\n JsiSkFont.fromValue(font)\n );\n }\n\n drawTextBlob(blob: SkTextBlob, x: number, y: number, paint: SkPaint) {\n this.ref.drawTextBlob(\n JsiSkTextBlob.fromValue(blob),\n x,\n y,\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawGlyphs(\n glyphs: number[],\n positions: SkPoint[],\n x: number,\n y: number,\n font: SkFont,\n paint: SkPaint\n ) {\n this.ref.drawGlyphs(\n glyphs,\n positions.map((p) => [p.x, p.y]).flat(),\n x,\n y,\n JsiSkFont.fromValue(font),\n JsiSkPaint.fromValue(paint)\n );\n }\n\n drawSvg(_svgDom: SkSVG, _width?: number, _height?: number) {\n throw new Error(\"drawSvg is not implemented on React Native Web\");\n }\n\n save() {\n return this.ref.save();\n }\n\n saveLayer(\n paint?: SkPaint,\n bounds?: SkRect | null,\n backdrop?: SkImageFilter | null,\n flags?: SaveLayerFlag\n ) {\n return this.ref.saveLayer(\n paint ? JsiSkPaint.fromValue(paint) : undefined,\n bounds ? JsiSkRect.fromValue(this.CanvasKit, bounds) : bounds,\n backdrop ? JsiSkImageFilter.fromValue(backdrop) : backdrop,\n flags\n );\n }\n\n restore() {\n this.ref.restore();\n }\n\n rotate(rotationInDegrees: number, rx: number, ry: number) {\n this.ref.rotate(rotationInDegrees, rx, ry);\n }\n\n scale(sx: number, sy: number) {\n this.ref.scale(sx, sy);\n }\n\n skew(sx: number, sy: number) {\n this.ref.skew(sx, sy);\n }\n\n translate(dx: number, dy: number) {\n this.ref.translate(dx, dy);\n }\n\n drawColor(color: SkColor, blendMode?: BlendMode) {\n this.ref.drawColor(color, blendMode ? ckEnum(blendMode) : undefined);\n }\n\n clear(color: SkColor) {\n this.ref.clear(color);\n }\n\n clipPath(path: SkPath, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipPath(JsiSkPath.fromValue(path), ckEnum(op), doAntiAlias);\n }\n\n clipRect(rect: SkRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRect(\n JsiSkRect.fromValue(this.CanvasKit, rect),\n ckEnum(op),\n doAntiAlias\n );\n }\n\n clipRRect(rrect: SkRRect, op: ClipOp, doAntiAlias: boolean) {\n this.ref.clipRRect(\n JsiSkRRect.fromValue(this.CanvasKit, rrect),\n ckEnum(op),\n doAntiAlias\n );\n }\n\n concat(m: SkMatrix) {\n this.ref.concat(JsiSkMatrix.fromValue(m));\n }\n\n drawPicture(skp: SkPicture) {\n this.ref.drawPicture(JsiSkPicture.fromValue(skp));\n }\n}\n"]}
|
@@ -19,15 +19,15 @@ class JsiSkColorFilterFactory extends _Host.Host {
|
|
19
19
|
}
|
20
20
|
|
21
21
|
MakeBlend(color, mode) {
|
22
|
-
return new _JsiSkColorFilter.JsiSkColorFilter(this.CanvasKit, this.CanvasKit.ColorFilter.MakeBlend(
|
22
|
+
return new _JsiSkColorFilter.JsiSkColorFilter(this.CanvasKit, this.CanvasKit.ColorFilter.MakeBlend(color, (0, _Host.ckEnum)(mode)));
|
23
23
|
}
|
24
24
|
|
25
25
|
MakeCompose(outer, inner) {
|
26
|
-
return new _JsiSkColorFilter.JsiSkColorFilter(this.CanvasKit, this.CanvasKit.ColorFilter.MakeCompose(
|
26
|
+
return new _JsiSkColorFilter.JsiSkColorFilter(this.CanvasKit, this.CanvasKit.ColorFilter.MakeCompose(_JsiSkColorFilter.JsiSkColorFilter.fromValue(outer), _JsiSkColorFilter.JsiSkColorFilter.fromValue(inner)));
|
27
27
|
}
|
28
28
|
|
29
29
|
MakeLerp(t, dst, src) {
|
30
|
-
return new _JsiSkColorFilter.JsiSkColorFilter(this.CanvasKit, this.CanvasKit.ColorFilter.MakeLerp(t,
|
30
|
+
return new _JsiSkColorFilter.JsiSkColorFilter(this.CanvasKit, this.CanvasKit.ColorFilter.MakeLerp(t, _JsiSkColorFilter.JsiSkColorFilter.fromValue(dst), _JsiSkColorFilter.JsiSkColorFilter.fromValue(src)));
|
31
31
|
}
|
32
32
|
|
33
33
|
MakeLinearToSRGBGamma() {
|
@@ -39,7 +39,7 @@ class JsiSkColorFilterFactory extends _Host.Host {
|
|
39
39
|
}
|
40
40
|
|
41
41
|
MakeLumaColorFilter() {
|
42
|
-
|
42
|
+
return new _JsiSkColorFilter.JsiSkColorFilter(this.CanvasKit, this.CanvasKit.ColorFilter.MakeLuma());
|
43
43
|
}
|
44
44
|
|
45
45
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"sources":["JsiSkColorFilterFactory.ts"],"names":["JsiSkColorFilterFactory","Host","constructor","CanvasKit","MakeMatrix","cMatrix","JsiSkColorFilter","ColorFilter","MakeBlend","color","mode","MakeCompose","outer","inner","MakeLerp","t","dst","src","MakeLinearToSRGBGamma","MakeSRGBToLinearGamma","MakeLumaColorFilter","
|
1
|
+
{"version":3,"sources":["JsiSkColorFilterFactory.ts"],"names":["JsiSkColorFilterFactory","Host","constructor","CanvasKit","MakeMatrix","cMatrix","JsiSkColorFilter","ColorFilter","MakeBlend","color","mode","MakeCompose","outer","inner","fromValue","MakeLerp","t","dst","src","MakeLinearToSRGBGamma","MakeSRGBToLinearGamma","MakeLumaColorFilter","MakeLuma"],"mappings":";;;;;;;AAUA;;AACA;;AAEO,MAAMA,uBAAN,SACGC,UADH,CAGP;AACEC,EAAAA,WAAW,CAACC,SAAD,EAAuB;AAChC,UAAMA,SAAN;AACD;;AAEDC,EAAAA,UAAU,CAACC,OAAD,EAA4B;AACpC,WAAO,IAAIC,kCAAJ,CACL,KAAKH,SADA,EAEL,KAAKA,SAAL,CAAeI,WAAf,CAA2BH,UAA3B,CAAsCC,OAAtC,CAFK,CAAP;AAID;;AAEDG,EAAAA,SAAS,CAACC,KAAD,EAAiBC,IAAjB,EAAkC;AACzC,WAAO,IAAIJ,kCAAJ,CACL,KAAKH,SADA,EAEL,KAAKA,SAAL,CAAeI,WAAf,CAA2BC,SAA3B,CAAqCC,KAArC,EAA4C,kBAAOC,IAAP,CAA5C,CAFK,CAAP;AAID;;AAEDC,EAAAA,WAAW,CAACC,KAAD,EAAuBC,KAAvB,EAA6C;AACtD,WAAO,IAAIP,kCAAJ,CACL,KAAKH,SADA,EAEL,KAAKA,SAAL,CAAeI,WAAf,CAA2BI,WAA3B,CACEL,mCAAiBQ,SAAjB,CAA2BF,KAA3B,CADF,EAEEN,mCAAiBQ,SAAjB,CAA2BD,KAA3B,CAFF,CAFK,CAAP;AAOD;;AAEDE,EAAAA,QAAQ,CAACC,CAAD,EAAYC,GAAZ,EAAgCC,GAAhC,EAAoD;AAC1D,WAAO,IAAIZ,kCAAJ,CACL,KAAKH,SADA,EAEL,KAAKA,SAAL,CAAeI,WAAf,CAA2BQ,QAA3B,CACEC,CADF,EAEEV,mCAAiBQ,SAAjB,CAA2BG,GAA3B,CAFF,EAGEX,mCAAiBQ,SAAjB,CAA2BI,GAA3B,CAHF,CAFK,CAAP;AAQD;;AAEDC,EAAAA,qBAAqB,GAAG;AACtB,WAAO,IAAIb,kCAAJ,CACL,KAAKH,SADA,EAEL,KAAKA,SAAL,CAAeI,WAAf,CAA2BY,qBAA3B,EAFK,CAAP;AAID;;AAEDC,EAAAA,qBAAqB,GAAG;AACtB,WAAO,IAAId,kCAAJ,CACL,KAAKH,SADA,EAEL,KAAKA,SAAL,CAAeI,WAAf,CAA2Ba,qBAA3B,EAFK,CAAP;AAID;;AAEDC,EAAAA,mBAAmB,GAAkB;AACnC,WAAO,IAAIf,kCAAJ,CACL,KAAKH,SADA,EAEL,KAAKA,SAAL,CAAeI,WAAf,CAA2Be,QAA3B,EAFK,CAAP;AAID;;AA3DH","sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type {\n ColorFilterFactory,\n SkColorFilter,\n InputColorMatrix,\n SkColor,\n BlendMode,\n} from \"../types\";\n\nimport { ckEnum, Host } from \"./Host\";\nimport { JsiSkColorFilter } from \"./JsiSkColorFilter\";\n\nexport class JsiSkColorFilterFactory\n extends Host\n implements ColorFilterFactory\n{\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeMatrix(cMatrix: InputColorMatrix) {\n return new JsiSkColorFilter(\n this.CanvasKit,\n this.CanvasKit.ColorFilter.MakeMatrix(cMatrix)\n );\n }\n\n MakeBlend(color: SkColor, mode: BlendMode) {\n return new JsiSkColorFilter(\n this.CanvasKit,\n this.CanvasKit.ColorFilter.MakeBlend(color, ckEnum(mode))\n );\n }\n\n MakeCompose(outer: SkColorFilter, inner: SkColorFilter) {\n return new JsiSkColorFilter(\n this.CanvasKit,\n this.CanvasKit.ColorFilter.MakeCompose(\n JsiSkColorFilter.fromValue(outer),\n JsiSkColorFilter.fromValue(inner)\n )\n );\n }\n\n MakeLerp(t: number, dst: SkColorFilter, src: SkColorFilter) {\n return new JsiSkColorFilter(\n this.CanvasKit,\n this.CanvasKit.ColorFilter.MakeLerp(\n t,\n JsiSkColorFilter.fromValue(dst),\n JsiSkColorFilter.fromValue(src)\n )\n );\n }\n\n MakeLinearToSRGBGamma() {\n return new JsiSkColorFilter(\n this.CanvasKit,\n this.CanvasKit.ColorFilter.MakeLinearToSRGBGamma()\n );\n }\n\n MakeSRGBToLinearGamma() {\n return new JsiSkColorFilter(\n this.CanvasKit,\n this.CanvasKit.ColorFilter.MakeSRGBToLinearGamma()\n );\n }\n\n MakeLumaColorFilter(): SkColorFilter {\n return new JsiSkColorFilter(\n this.CanvasKit,\n this.CanvasKit.ColorFilter.MakeLuma()\n );\n }\n}\n"]}
|
@@ -7,6 +7,10 @@ exports.JsiSkFont = void 0;
|
|
7
7
|
|
8
8
|
var _Host = require("./Host");
|
9
9
|
|
10
|
+
var _JsiSkPaint = require("./JsiSkPaint");
|
11
|
+
|
12
|
+
var _JsiSkPoint = require("./JsiSkPoint");
|
13
|
+
|
10
14
|
var _JsiSkRect = require("./JsiSkRect");
|
11
15
|
|
12
16
|
var _JsiSkTypeface = require("./JsiSkTypeface");
|
@@ -39,11 +43,11 @@ class JsiSkFont extends _Host.HostObject {
|
|
39
43
|
|
40
44
|
|
41
45
|
getGlyphWidths(glyphs, paint) {
|
42
|
-
return [...this.ref.getGlyphWidths(glyphs, paint ?
|
46
|
+
return [...this.ref.getGlyphWidths(glyphs, paint ? _JsiSkPaint.JsiSkPaint.fromValue(paint) : null)];
|
43
47
|
}
|
44
48
|
|
45
49
|
getGlyphIntercepts(glyphs, positions, top, bottom) {
|
46
|
-
return [...this.ref.getGlyphIntercepts(glyphs, positions.map(p => (
|
50
|
+
return [...this.ref.getGlyphIntercepts(glyphs, positions.map(p => Array.from(_JsiSkPoint.JsiSkPoint.fromValue(p))).flat(), top, bottom)];
|
47
51
|
}
|
48
52
|
|
49
53
|
getScaleX() {
|
@@ -104,7 +108,7 @@ class JsiSkFont extends _Host.HostObject {
|
|
104
108
|
}
|
105
109
|
|
106
110
|
setTypeface(face) {
|
107
|
-
this.ref.setTypeface(face ?
|
111
|
+
this.ref.setTypeface(face ? _JsiSkTypeface.JsiSkTypeface.fromValue(face) : null);
|
108
112
|
}
|
109
113
|
|
110
114
|
}
|