@shopify/react-native-skia 0.1.184 → 0.1.186
Sign up to get free protection for your applications and to get access to all the features.
- package/android/build.gradle +2 -1
- package/android/cpp/jni/JniPlatformContext.cpp +92 -3
- package/android/cpp/jni/include/JniPlatformContext.h +4 -0
- package/android/cpp/rnskia-android/RNSkAndroidPlatformContext.h +8 -0
- package/android/src/main/java/com/shopify/reactnative/skia/PlatformContext.java +17 -1
- package/android/src/main/java/com/shopify/reactnative/skia/ViewScreenshotService.java +180 -0
- package/cpp/api/JsiSkFont.h +1 -1
- package/cpp/api/JsiSkHostObjects.h +1 -1
- package/cpp/api/JsiSkImage.h +8 -1
- package/cpp/api/JsiSkImageFactory.h +29 -0
- package/cpp/api/JsiSkPaint.h +7 -7
- package/cpp/api/JsiSkPathFactory.h +1 -1
- package/cpp/api/JsiSkPicture.h +2 -2
- package/cpp/api/JsiSkRuntimeEffect.h +3 -3
- package/cpp/api/JsiSkSVG.h +12 -2
- package/cpp/api/JsiSkShader.h +1 -1
- package/cpp/api/JsiSkSurface.h +3 -3
- package/cpp/api/JsiSkSurfaceFactory.h +1 -1
- package/cpp/api/JsiSkTypeface.h +1 -1
- package/cpp/rnskia/RNSkAnimation.h +3 -3
- package/cpp/rnskia/RNSkDomView.h +9 -9
- package/cpp/rnskia/RNSkInfoParameter.h +2 -2
- package/cpp/rnskia/RNSkJsView.h +8 -8
- package/cpp/rnskia/RNSkJsiViewApi.h +5 -5
- package/cpp/rnskia/RNSkPictureView.h +8 -8
- package/cpp/rnskia/RNSkPlatformContext.h +32 -3
- package/cpp/rnskia/RNSkValueApi.h +5 -5
- package/cpp/rnskia/RNSkView.h +10 -8
- package/cpp/rnskia/dom/base/ConcatablePaint.h +6 -6
- package/cpp/rnskia/dom/base/Declaration.h +1 -1
- package/cpp/rnskia/dom/base/DeclarationContext.h +7 -7
- package/cpp/rnskia/dom/base/DrawingContext.h +3 -3
- package/cpp/rnskia/dom/base/NodePropsContainer.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiBlurMaskNode.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiColorFilterNodes.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiGlyphsNode.h +8 -7
- package/cpp/rnskia/dom/nodes/JsiImageFilterNodes.h +9 -6
- package/cpp/rnskia/dom/nodes/JsiImageNode.h +5 -2
- package/cpp/rnskia/dom/nodes/JsiImageSvgNode.h +9 -9
- package/cpp/rnskia/dom/nodes/JsiPathEffectNodes.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiPathNode.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiPointsNode.h +1 -1
- package/cpp/rnskia/dom/nodes/JsiShaderNodes.h +7 -3
- package/cpp/rnskia/dom/nodes/JsiTextNode.h +5 -4
- package/cpp/rnskia/dom/nodes/JsiTextPathNode.h +3 -1
- package/cpp/rnskia/dom/props/BlendModeProp.h +1 -1
- package/cpp/rnskia/dom/props/CircleProp.h +1 -1
- package/cpp/rnskia/dom/props/ClipProp.h +1 -1
- package/cpp/rnskia/dom/props/FontProp.h +15 -10
- package/cpp/rnskia/dom/props/ImageProps.h +30 -16
- package/cpp/rnskia/dom/props/PaintProps.h +1 -1
- package/cpp/rnskia/dom/props/PathProp.h +1 -1
- package/cpp/rnskia/dom/props/PointProp.h +1 -1
- package/cpp/rnskia/dom/props/PointsProp.h +1 -1
- package/cpp/rnskia/dom/props/RRectProp.h +2 -2
- package/cpp/rnskia/dom/props/RadiusProp.h +1 -1
- package/cpp/rnskia/dom/props/RectProp.h +1 -1
- package/cpp/rnskia/dom/props/StrokeProps.h +1 -1
- package/cpp/rnskia/dom/props/SvgProp.h +18 -12
- package/cpp/rnskia/dom/props/TextBlobProp.h +60 -57
- package/cpp/rnskia/dom/props/TileModeProp.h +1 -1
- package/cpp/rnskia/dom/props/UniformsProp.h +1 -1
- package/cpp/rnskia/dom/props/VertexModeProp.h +1 -1
- package/cpp/rnskia/dom/props/VerticesProps.h +1 -1
- package/cpp/rnskia/values/RNSkClockValue.h +2 -2
- package/cpp/rnskia/values/RNSkComputedValue.h +1 -1
- package/cpp/rnskia/values/RNSkReadonlyValue.h +3 -3
- package/cpp/rnskia/values/RNSkValue.h +4 -4
- package/cpp/utils/RNSkMeasureTime.h +1 -1
- package/cpp/utils/RNSkTimingInfo.h +1 -1
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.h +16 -13
- package/ios/RNSkia-iOS/RNSkiOSPlatformContext.mm +8 -0
- package/ios/RNSkia-iOS/SkiaManager.mm +20 -1
- package/ios/RNSkia-iOS/ViewScreenshotService.h +21 -0
- package/ios/RNSkia-iOS/ViewScreenshotService.mm +79 -0
- package/lib/commonjs/dom/nodes/drawings/ImageNode.js +22 -1
- package/lib/commonjs/dom/nodes/drawings/ImageNode.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/ImageSVG.js +5 -0
- package/lib/commonjs/dom/nodes/drawings/ImageSVG.js.map +1 -1
- package/lib/commonjs/dom/nodes/drawings/Text.d.ts +2 -2
- package/lib/commonjs/dom/nodes/drawings/Text.js +13 -2
- package/lib/commonjs/dom/nodes/drawings/Text.js.map +1 -1
- package/lib/commonjs/dom/nodes/paint/Shaders.js +5 -0
- package/lib/commonjs/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/commonjs/dom/types/Drawings.d.ts +5 -5
- package/lib/commonjs/dom/types/Drawings.js.map +1 -1
- package/lib/commonjs/dom/types/Shaders.d.ts +1 -1
- package/lib/commonjs/dom/types/Shaders.js.map +1 -1
- package/lib/commonjs/mock/index.js +2 -1
- package/lib/commonjs/mock/index.js.map +1 -1
- package/lib/commonjs/skia/core/Image.d.ts +14 -2
- package/lib/commonjs/skia/core/Image.js +37 -1
- package/lib/commonjs/skia/core/Image.js.map +1 -1
- package/lib/commonjs/skia/types/Image/Image.d.ts +6 -0
- package/lib/commonjs/skia/types/Image/Image.js.map +1 -1
- package/lib/commonjs/skia/types/Image/ImageFactory.d.ts +7 -0
- package/lib/commonjs/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/commonjs/skia/types/SVG/SVG.d.ts +4 -1
- package/lib/commonjs/skia/types/SVG/SVG.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/commonjs/skia/web/JsiSkImage.js +4 -0
- package/lib/commonjs/skia/web/JsiSkImage.js.map +1 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.d.ts +2 -1
- package/lib/commonjs/skia/web/JsiSkImageFactory.js +7 -0
- package/lib/commonjs/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/module/dom/nodes/drawings/ImageNode.js +22 -1
- package/lib/module/dom/nodes/drawings/ImageNode.js.map +1 -1
- package/lib/module/dom/nodes/drawings/ImageSVG.js +5 -0
- package/lib/module/dom/nodes/drawings/ImageSVG.js.map +1 -1
- package/lib/module/dom/nodes/drawings/Text.d.ts +2 -2
- package/lib/module/dom/nodes/drawings/Text.js +13 -2
- package/lib/module/dom/nodes/drawings/Text.js.map +1 -1
- package/lib/module/dom/nodes/paint/Shaders.js +5 -0
- package/lib/module/dom/nodes/paint/Shaders.js.map +1 -1
- package/lib/module/dom/types/Drawings.d.ts +5 -5
- package/lib/module/dom/types/Drawings.js.map +1 -1
- package/lib/module/dom/types/Shaders.d.ts +1 -1
- package/lib/module/dom/types/Shaders.js.map +1 -1
- package/lib/module/mock/index.js +2 -1
- package/lib/module/mock/index.js.map +1 -1
- package/lib/module/skia/core/Image.d.ts +14 -2
- package/lib/module/skia/core/Image.js +32 -0
- package/lib/module/skia/core/Image.js.map +1 -1
- package/lib/module/skia/types/Image/Image.d.ts +6 -0
- package/lib/module/skia/types/Image/Image.js.map +1 -1
- package/lib/module/skia/types/Image/ImageFactory.d.ts +7 -0
- package/lib/module/skia/types/Image/ImageFactory.js.map +1 -1
- package/lib/module/skia/types/SVG/SVG.d.ts +4 -1
- package/lib/module/skia/types/SVG/SVG.js.map +1 -1
- package/lib/module/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/module/skia/web/JsiSkImage.js +4 -0
- package/lib/module/skia/web/JsiSkImage.js.map +1 -1
- package/lib/module/skia/web/JsiSkImageFactory.d.ts +2 -1
- package/lib/module/skia/web/JsiSkImageFactory.js +7 -0
- package/lib/module/skia/web/JsiSkImageFactory.js.map +1 -1
- package/lib/typescript/src/dom/nodes/drawings/Text.d.ts +2 -2
- package/lib/typescript/src/dom/types/Drawings.d.ts +5 -5
- package/lib/typescript/src/dom/types/Shaders.d.ts +1 -1
- package/lib/typescript/src/skia/core/Image.d.ts +14 -2
- package/lib/typescript/src/skia/types/Image/Image.d.ts +6 -0
- package/lib/typescript/src/skia/types/Image/ImageFactory.d.ts +7 -0
- package/lib/typescript/src/skia/types/SVG/SVG.d.ts +4 -1
- package/lib/typescript/src/skia/web/JsiSkImage.d.ts +1 -0
- package/lib/typescript/src/skia/web/JsiSkImageFactory.d.ts +2 -1
- package/package.json +2 -2
- package/scripts/install-npm.js +3 -2
- package/src/dom/nodes/drawings/ImageNode.ts +9 -1
- package/src/dom/nodes/drawings/ImageSVG.ts +3 -0
- package/src/dom/nodes/drawings/Text.ts +13 -3
- package/src/dom/nodes/paint/Shaders.ts +4 -0
- package/src/dom/types/Drawings.ts +5 -5
- package/src/dom/types/Shaders.ts +1 -1
- package/src/mock/index.ts +1 -0
- package/src/skia/core/Image.ts +43 -1
- package/src/skia/types/Image/Image.ts +7 -0
- package/src/skia/types/Image/ImageFactory.ts +8 -0
- package/src/skia/types/SVG/SVG.ts +4 -1
- package/src/skia/web/JsiSkImage.ts +7 -0
- package/src/skia/web/JsiSkImageFactory.ts +8 -1
@@ -8,9 +8,9 @@ export declare class TextNode extends JsiDrawingNode<TextProps, null> {
|
|
8
8
|
protected deriveProps(): null;
|
9
9
|
draw({ canvas, paint }: DrawingContext): void;
|
10
10
|
}
|
11
|
-
export declare class TextPathNode extends JsiDrawingNode<TextPathProps, SkTextBlob> {
|
11
|
+
export declare class TextPathNode extends JsiDrawingNode<TextPathProps, SkTextBlob | null> {
|
12
12
|
constructor(ctx: NodeContext, props: TextPathProps);
|
13
|
-
deriveProps(): SkTextBlob;
|
13
|
+
deriveProps(): SkTextBlob | null;
|
14
14
|
draw({ canvas, paint }: DrawingContext): void;
|
15
15
|
}
|
16
16
|
export declare class TextBlobNode extends JsiDrawingNode<TextBlobProps, null> {
|
@@ -31,7 +31,10 @@ class TextNode extends _DrawingNode.JsiDrawingNode {
|
|
31
31
|
y,
|
32
32
|
font
|
33
33
|
} = this.props;
|
34
|
-
|
34
|
+
|
35
|
+
if (font) {
|
36
|
+
canvas.drawText(text, x, y, paint, font);
|
37
|
+
}
|
35
38
|
}
|
36
39
|
|
37
40
|
}
|
@@ -49,6 +52,11 @@ class TextPathNode extends _DrawingNode.JsiDrawingNode {
|
|
49
52
|
font,
|
50
53
|
initialOffset
|
51
54
|
} = this.props;
|
55
|
+
|
56
|
+
if (!font) {
|
57
|
+
return null;
|
58
|
+
}
|
59
|
+
|
52
60
|
let {
|
53
61
|
text
|
54
62
|
} = this.props;
|
@@ -171,7 +179,10 @@ class GlyphsNode extends _DrawingNode.JsiDrawingNode {
|
|
171
179
|
y,
|
172
180
|
font
|
173
181
|
} = this.props;
|
174
|
-
|
182
|
+
|
183
|
+
if (font) {
|
184
|
+
canvas.drawGlyphs(glyphs, positions, x, y, font, paint);
|
185
|
+
}
|
175
186
|
}
|
176
187
|
|
177
188
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["TextNode","JsiDrawingNode","constructor","ctx","props","NodeType","Text","deriveProps","draw","canvas","paint","text","x","y","font","drawText","TextPathNode","TextPath","path","processPath","Skia","initialOffset","ids","getGlyphIDs","widths","getGlyphWidths","rsx","meas","ContourMeasureIter","cont","next","dist","i","length","width","substring","p","t","getPosTan","adjustedX","adjustedY","push","RSXform","TextBlob","MakeFromRSXform","derived","Error","drawTextBlob","TextBlobNode","blob","GlyphsNode","Glyphs","glyphs","reduce","acc","glyph","id","pos","positions","drawGlyphs"],"sources":["Text.ts"],"sourcesContent":["import type { SkRSXform, SkTextBlob, SkPoint } from \"../../../skia/types\";\nimport type {\n DrawingContext,\n TextBlobProps,\n TextPathProps,\n TextProps,\n} from \"../../types\";\nimport { NodeType } from \"../../types\";\nimport { processPath } from \"../datatypes\";\nimport type { GlyphsProps } from \"../../types/Drawings\";\nimport { JsiDrawingNode } from \"../DrawingNode\";\nimport type { NodeContext } from \"../Node\";\n\nexport class TextNode extends JsiDrawingNode<TextProps, null> {\n constructor(ctx: NodeContext, props: TextProps) {\n super(ctx, NodeType.Text, props);\n }\n\n protected deriveProps() {\n return null;\n }\n\n draw({ canvas, paint }: DrawingContext) {\n const { text, x, y, font } = this.props;\n canvas.drawText(text, x, y, paint, font);\n }\n}\n\nexport class TextPathNode extends JsiDrawingNode
|
1
|
+
{"version":3,"names":["TextNode","JsiDrawingNode","constructor","ctx","props","NodeType","Text","deriveProps","draw","canvas","paint","text","x","y","font","drawText","TextPathNode","TextPath","path","processPath","Skia","initialOffset","ids","getGlyphIDs","widths","getGlyphWidths","rsx","meas","ContourMeasureIter","cont","next","dist","i","length","width","substring","p","t","getPosTan","adjustedX","adjustedY","push","RSXform","TextBlob","MakeFromRSXform","derived","Error","drawTextBlob","TextBlobNode","blob","GlyphsNode","Glyphs","glyphs","reduce","acc","glyph","id","pos","positions","drawGlyphs"],"sources":["Text.ts"],"sourcesContent":["import type { SkRSXform, SkTextBlob, SkPoint } from \"../../../skia/types\";\nimport type {\n DrawingContext,\n TextBlobProps,\n TextPathProps,\n TextProps,\n} from \"../../types\";\nimport { NodeType } from \"../../types\";\nimport { processPath } from \"../datatypes\";\nimport type { GlyphsProps } from \"../../types/Drawings\";\nimport { JsiDrawingNode } from \"../DrawingNode\";\nimport type { NodeContext } from \"../Node\";\n\nexport class TextNode extends JsiDrawingNode<TextProps, null> {\n constructor(ctx: NodeContext, props: TextProps) {\n super(ctx, NodeType.Text, props);\n }\n\n protected deriveProps() {\n return null;\n }\n\n draw({ canvas, paint }: DrawingContext) {\n const { text, x, y, font } = this.props;\n if (font) {\n canvas.drawText(text, x, y, paint, font);\n }\n }\n}\n\nexport class TextPathNode extends JsiDrawingNode<\n TextPathProps,\n SkTextBlob | null\n> {\n constructor(ctx: NodeContext, props: TextPathProps) {\n super(ctx, NodeType.TextPath, props);\n }\n\n deriveProps() {\n const path = processPath(this.Skia, this.props.path);\n const { font, initialOffset } = this.props;\n if (!font) {\n return null;\n }\n let { text } = this.props;\n const ids = font.getGlyphIDs(text);\n const widths = font.getGlyphWidths(ids);\n const rsx: SkRSXform[] = [];\n const meas = this.Skia.ContourMeasureIter(path, false, 1);\n let cont = meas.next();\n let dist = initialOffset;\n for (let i = 0; i < text.length && cont; i++) {\n const width = widths[i];\n dist += width / 2;\n if (dist > cont.length()) {\n // jump to next contour\n cont = meas.next();\n if (!cont) {\n // We have come to the end of the path - terminate the string\n // right here.\n text = text.substring(0, i);\n break;\n }\n dist = width / 2;\n }\n // Gives us the (x, y) coordinates as well as the cos/sin of the tangent\n // line at that position.\n const [p, t] = cont.getPosTan(dist);\n const adjustedX = p.x - (width / 2) * t.x;\n const adjustedY = p.y - (width / 2) * t.y;\n rsx.push(this.Skia.RSXform(t.x, t.y, adjustedX, adjustedY));\n dist += width / 2;\n }\n return this.Skia.TextBlob.MakeFromRSXform(text, rsx, font);\n }\n\n draw({ canvas, paint }: DrawingContext) {\n if (!this.derived) {\n throw new Error(\"TextPathNode: blob is null\");\n }\n canvas.drawTextBlob(this.derived, 0, 0, paint);\n }\n}\n\nexport class TextBlobNode extends JsiDrawingNode<TextBlobProps, null> {\n constructor(ctx: NodeContext, props: TextBlobProps) {\n super(ctx, NodeType.TextBlob, props);\n }\n\n protected deriveProps() {\n return null;\n }\n\n draw({ canvas, paint }: DrawingContext) {\n const { blob, x, y } = this.props;\n canvas.drawTextBlob(blob, x, y, paint);\n }\n}\n\ninterface ProcessedGlyphs {\n glyphs: number[];\n positions: SkPoint[];\n}\n\nexport class GlyphsNode extends JsiDrawingNode<GlyphsProps, ProcessedGlyphs> {\n constructor(ctx: NodeContext, props: GlyphsProps) {\n super(ctx, NodeType.Glyphs, props);\n }\n\n deriveProps() {\n return this.props.glyphs.reduce<ProcessedGlyphs>(\n (acc, glyph) => {\n const { id, pos } = glyph;\n acc.glyphs.push(id);\n acc.positions.push(pos);\n return acc;\n },\n { glyphs: [], positions: [] }\n );\n }\n\n draw({ canvas, paint }: DrawingContext) {\n if (!this.derived) {\n throw new Error(\"GlyphsNode: processedGlyphs is null\");\n }\n const { glyphs, positions } = this.derived;\n const { x, y, font } = this.props;\n if (font) {\n canvas.drawGlyphs(glyphs, positions, x, y, font, paint);\n }\n }\n}\n"],"mappings":";;;;;;;AAOA;;AACA;;AAEA;;AAGO,MAAMA,QAAN,SAAuBC,2BAAvB,CAAuD;EAC5DC,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAqC;IAC9C,MAAMD,GAAN,EAAWE,eAAA,CAASC,IAApB,EAA0BF,KAA1B;EACD;;EAESG,WAAW,GAAG;IACtB,OAAO,IAAP;EACD;;EAEDC,IAAI,OAAoC;IAAA,IAAnC;MAAEC,MAAF;MAAUC;IAAV,CAAmC;IACtC,MAAM;MAAEC,IAAF;MAAQC,CAAR;MAAWC,CAAX;MAAcC;IAAd,IAAuB,KAAKV,KAAlC;;IACA,IAAIU,IAAJ,EAAU;MACRL,MAAM,CAACM,QAAP,CAAgBJ,IAAhB,EAAsBC,CAAtB,EAAyBC,CAAzB,EAA4BH,KAA5B,EAAmCI,IAAnC;IACD;EACF;;AAd2D;;;;AAiBvD,MAAME,YAAN,SAA2Bf,2BAA3B,CAGL;EACAC,WAAW,CAACC,GAAD,EAAmBC,KAAnB,EAAyC;IAClD,MAAMD,GAAN,EAAWE,eAAA,CAASY,QAApB,EAA8Bb,KAA9B;EACD;;EAEDG,WAAW,GAAG;IACZ,MAAMW,IAAI,GAAG,IAAAC,sBAAA,EAAY,KAAKC,IAAjB,EAAuB,KAAKhB,KAAL,CAAWc,IAAlC,CAAb;IACA,MAAM;MAAEJ,IAAF;MAAQO;IAAR,IAA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EDG,WAAW,GAAG;IACZ,OAAO,KAAKH,KAAL,CAAWgD,MAAX,CAAkBC,MAAlB,CACL,CAACC,GAAD,EAAMC,KAAN,KAAgB;MACd,MAAM;QAAEC,EAAF;QAAMC;MAAN,IAAcF,KAApB;MACAD,GAAG,CAACF,MAAJ,CAAWX,IAAX,CAAgBe,EAAhB;MACAF,GAAG,CAACI,SAAJ,CAAcjB,IAAd,CAAmBgB,GAAnB;MACA,OAAOH,GAAP;IACD,CANI,EAOL;MAAEF,MAAM,EAAE,EAAV;MAAcM,SAAS,EAAE;IAAzB,CAPK,CAAP;EASD;;EAEDlD,IAAI,QAAoC;IAAA,IAAnC;MAAEC,MAAF;MAAUC;IAAV,CAAmC;;IACtC,IAAI,CAAC,KAAKmC,OAAV,EAAmB;MACjB,MAAM,IAAIC,KAAJ,CAAU,qCAAV,CAAN;IACD;;IACD,MAAM;MAAEM,MAAF;MAAUM;IAAV,IAAwB,KAAKb,OAAnC;IACA,MAAM;MAAEjC,CAAF;MAAKC,CAAL;MAAQC;IAAR,IAAiB,KAAKV,KAA5B;;IACA,IAAIU,IAAJ,EAAU;MACRL,MAAM,CAACkD,UAAP,CAAkBP,MAAlB,EAA0BM,SAA1B,EAAqC9C,CAArC,EAAwCC,CAAxC,EAA2CC,IAA3C,EAAiDJ,KAAjD;IACD;EACF;;AA1B0E"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["ShaderDeclaration","JsiDeclarationNode","constructor","ctx","type","props","DeclarationType","Shader","ShaderNode","NodeType","decorate","decorateChildren","source","uniforms","transform","m3","Skia","Matrix","processTransformProps","shader","makeShaderWithChildren","processUniforms","shaders","popAll","push","ImageShaderNode","ImageShader","fit","image","tx","ty","fm","mm","imageShaderProps","rct","getRect","rects","fitRects","x","y","width","height","sx","sy","rect2rect","src","dst","translate","translateX","translateY","scale","scaleX","scaleY","lm","concat","makeShaderOptions","TileMode","enumKey","FilterMode","MipmapMode","ColorNode","ColorShader","color","MakeColor","Color","TurbulenceNode","Turbulence","freqX","freqY","octaves","seed","tileWidth","tileHeight","MakeTurbulence","FractalNoiseNode","FractalNoise","MakeFractalNoise","LinearGradientNode","LinearGradient","start","end","colors","positions","mode","localMatrix","flags","processGradientProps","MakeLinearGradient","RadialGradientNode","RadialGradient","c","r","MakeRadialGradient","SweepGradientNode","SweepGradient","MakeSweepGradient","TwoPointConicalGradientNode","TwoPointConicalGradient","startR","endR","MakeTwoPointConicalGradient"],"sources":["Shaders.ts"],"sourcesContent":["import {\n processUniforms,\n FilterMode,\n MipmapMode,\n TileMode,\n} from \"../../../skia/types\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport type {\n ColorProps,\n DeclarationContext,\n FractalNoiseProps,\n ImageShaderProps,\n LinearGradientProps,\n RadialGradientProps,\n ShaderProps,\n SweepGradientProps,\n TurbulenceProps,\n TwoPointConicalGradientProps,\n} from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport {\n enumKey,\n fitRects,\n getRect,\n processGradientProps,\n processTransformProps,\n rect2rect,\n} from \"../datatypes\";\n\nexport abstract class ShaderDeclaration<P> extends JsiDeclarationNode<P> {\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, DeclarationType.Shader, type, props);\n }\n}\n\nexport class ShaderNode extends ShaderDeclaration<ShaderProps> {\n constructor(ctx: NodeContext, props: ShaderProps) {\n super(ctx, NodeType.Shader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n this.decorateChildren(ctx);\n const { source, uniforms, ...transform } = this.props;\n const m3 = this.Skia.Matrix();\n processTransformProps(m3, transform);\n const shader = source.makeShaderWithChildren(\n processUniforms(source, uniforms),\n ctx.shaders.popAll(),\n m3\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class ImageShaderNode extends ShaderDeclaration<ImageShaderProps> {\n constructor(ctx: NodeContext, props: ImageShaderProps) {\n super(ctx, NodeType.ImageShader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { fit, image, tx, ty, fm, mm, ...imageShaderProps } = this.props;\n const rct = getRect(this.Skia, imageShaderProps);\n const m3 = this.Skia.Matrix();\n if (rct) {\n const rects = fitRects(\n fit,\n { x: 0, y: 0, width: image.width(), height: image.height() },\n rct\n );\n const [x, y, sx, sy] = rect2rect(rects.src, rects.dst);\n m3.translate(x.translateX, y.translateY);\n m3.scale(sx.scaleX, sy.scaleY);\n }\n const lm = this.Skia.Matrix();\n lm.concat(m3);\n processTransformProps(lm, imageShaderProps);\n const shader = image.makeShaderOptions(\n TileMode[enumKey(tx)],\n TileMode[enumKey(ty)],\n FilterMode[enumKey(fm)],\n MipmapMode[enumKey(mm)],\n lm\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class ColorNode extends ShaderDeclaration<ColorProps> {\n constructor(ctx: NodeContext, props: ColorProps) {\n super(ctx, NodeType.ColorShader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { color } = this.props;\n const shader = this.Skia.Shader.MakeColor(this.Skia.Color(color));\n ctx.shaders.push(shader);\n }\n}\n\nexport class TurbulenceNode extends ShaderDeclaration<TurbulenceProps> {\n constructor(ctx: NodeContext, props: TurbulenceProps) {\n super(ctx, NodeType.Turbulence, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n const shader = this.Skia.Shader.MakeTurbulence(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class FractalNoiseNode extends ShaderDeclaration<FractalNoiseProps> {\n constructor(ctx: NodeContext, props: FractalNoiseProps) {\n super(ctx, NodeType.FractalNoise, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n const shader = this.Skia.Shader.MakeFractalNoise(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class LinearGradientNode extends ShaderDeclaration<LinearGradientProps> {\n constructor(ctx: NodeContext, props: LinearGradientProps) {\n super(ctx, NodeType.LinearGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeLinearGradient(\n start,\n end,\n colors,\n positions ?? null,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class RadialGradientNode extends ShaderDeclaration<RadialGradientProps> {\n constructor(ctx: NodeContext, props: RadialGradientProps) {\n super(ctx, NodeType.RadialGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { c, r } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeRadialGradient(\n c,\n r,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class SweepGradientNode extends ShaderDeclaration<SweepGradientProps> {\n constructor(ctx: NodeContext, props: SweepGradientProps) {\n super(ctx, NodeType.SweepGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { c, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeSweepGradient(\n c.x,\n c.y,\n colors,\n positions,\n mode,\n localMatrix,\n flags,\n start,\n end\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class TwoPointConicalGradientNode extends ShaderDeclaration<TwoPointConicalGradientProps> {\n constructor(ctx: NodeContext, props: TwoPointConicalGradientProps) {\n super(ctx, NodeType.TwoPointConicalGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { startR, endR, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeTwoPointConicalGradient(\n start,\n startR,\n end,\n endR,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );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AA1C,CAA0F;EAC/FE,WAAW,CAACC,GAAD,EAAmBE,KAAnB,EAAwD;IACjE,MAAMF,GAAN,EAAWM,gBAAA,CAASwF,uBAApB,EAA6C5F,KAA7C;EACD;;EAEDK,QAAQ,CAACP,GAAD,EAA0B;IAChC,MAAM;MAAE+F,MAAF;MAAUC,IAAV;MAAgBpB,KAAhB;MAAuBC;IAAvB,IAA+B,KAAK3E,KAA1C;IACA,MAAM;MAAE4E,MAAF;MAAUC,SAAV;MAAqBC,IAArB;MAA2BC,WAA3B;MAAwCC;IAAxC,IACJ,IAAAC,+BAAA,EAAqB,KAAKtE,IAA1B,EAAgC,KAAKX,KAArC,CADF;IAEA,MAAMc,MAAM,GAAG,KAAKH,IAAL,CAAUT,MAAV,CAAiB6F,2BAAjB,CACbrB,KADa,EAEbmB,MAFa,EAGblB,GAHa,EAIbmB,IAJa,EAKblB,MALa,EAMbC,SANa,EAObC,IAPa,EAQbC,WARa,EASbC,KATa,CAAf;IAWAlF,GAAG,CAACmB,OAAJ,CAAYE,IAAZ,CAAiBL,MAAjB;EACD;;AArB8F"}
|
1
|
+
{"version":3,"names":["ShaderDeclaration","JsiDeclarationNode","constructor","ctx","type","props","DeclarationType","Shader","ShaderNode","NodeType","decorate","decorateChildren","source","uniforms","transform","m3","Skia","Matrix","processTransformProps","shader","makeShaderWithChildren","processUniforms","shaders","popAll","push","ImageShaderNode","ImageShader","fit","image","tx","ty","fm","mm","imageShaderProps","rct","getRect","rects","fitRects","x","y","width","height","sx","sy","rect2rect","src","dst","translate","translateX","translateY","scale","scaleX","scaleY","lm","concat","makeShaderOptions","TileMode","enumKey","FilterMode","MipmapMode","ColorNode","ColorShader","color","MakeColor","Color","TurbulenceNode","Turbulence","freqX","freqY","octaves","seed","tileWidth","tileHeight","MakeTurbulence","FractalNoiseNode","FractalNoise","MakeFractalNoise","LinearGradientNode","LinearGradient","start","end","colors","positions","mode","localMatrix","flags","processGradientProps","MakeLinearGradient","RadialGradientNode","RadialGradient","c","r","MakeRadialGradient","SweepGradientNode","SweepGradient","MakeSweepGradient","TwoPointConicalGradientNode","TwoPointConicalGradient","startR","endR","MakeTwoPointConicalGradient"],"sources":["Shaders.ts"],"sourcesContent":["import {\n processUniforms,\n FilterMode,\n MipmapMode,\n TileMode,\n} from \"../../../skia/types\";\nimport type { NodeContext } from \"../Node\";\nimport { JsiDeclarationNode } from \"../Node\";\nimport type {\n ColorProps,\n DeclarationContext,\n FractalNoiseProps,\n ImageShaderProps,\n LinearGradientProps,\n RadialGradientProps,\n ShaderProps,\n SweepGradientProps,\n TurbulenceProps,\n TwoPointConicalGradientProps,\n} from \"../../types\";\nimport { DeclarationType, NodeType } from \"../../types\";\nimport {\n enumKey,\n fitRects,\n getRect,\n processGradientProps,\n processTransformProps,\n rect2rect,\n} from \"../datatypes\";\n\nexport abstract class ShaderDeclaration<P> extends JsiDeclarationNode<P> {\n constructor(ctx: NodeContext, type: NodeType, props: P) {\n super(ctx, DeclarationType.Shader, type, props);\n }\n}\n\nexport class ShaderNode extends ShaderDeclaration<ShaderProps> {\n constructor(ctx: NodeContext, props: ShaderProps) {\n super(ctx, NodeType.Shader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n this.decorateChildren(ctx);\n const { source, uniforms, ...transform } = this.props;\n const m3 = this.Skia.Matrix();\n processTransformProps(m3, transform);\n const shader = source.makeShaderWithChildren(\n processUniforms(source, uniforms),\n ctx.shaders.popAll(),\n m3\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class ImageShaderNode extends ShaderDeclaration<ImageShaderProps> {\n constructor(ctx: NodeContext, props: ImageShaderProps) {\n super(ctx, NodeType.ImageShader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { fit, image, tx, ty, fm, mm, ...imageShaderProps } = this.props;\n if (!image) {\n return;\n }\n\n const rct = getRect(this.Skia, imageShaderProps);\n const m3 = this.Skia.Matrix();\n if (rct) {\n const rects = fitRects(\n fit,\n { x: 0, y: 0, width: image.width(), height: image.height() },\n rct\n );\n const [x, y, sx, sy] = rect2rect(rects.src, rects.dst);\n m3.translate(x.translateX, y.translateY);\n m3.scale(sx.scaleX, sy.scaleY);\n }\n const lm = this.Skia.Matrix();\n lm.concat(m3);\n processTransformProps(lm, imageShaderProps);\n const shader = image.makeShaderOptions(\n TileMode[enumKey(tx)],\n TileMode[enumKey(ty)],\n FilterMode[enumKey(fm)],\n MipmapMode[enumKey(mm)],\n lm\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class ColorNode extends ShaderDeclaration<ColorProps> {\n constructor(ctx: NodeContext, props: ColorProps) {\n super(ctx, NodeType.ColorShader, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { color } = this.props;\n const shader = this.Skia.Shader.MakeColor(this.Skia.Color(color));\n ctx.shaders.push(shader);\n }\n}\n\nexport class TurbulenceNode extends ShaderDeclaration<TurbulenceProps> {\n constructor(ctx: NodeContext, props: TurbulenceProps) {\n super(ctx, NodeType.Turbulence, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n const shader = this.Skia.Shader.MakeTurbulence(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class FractalNoiseNode extends ShaderDeclaration<FractalNoiseProps> {\n constructor(ctx: NodeContext, props: FractalNoiseProps) {\n super(ctx, NodeType.FractalNoise, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { freqX, freqY, octaves, seed, tileWidth, tileHeight } = this.props;\n const shader = this.Skia.Shader.MakeFractalNoise(\n freqX,\n freqY,\n octaves,\n seed,\n tileWidth,\n tileHeight\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class LinearGradientNode extends ShaderDeclaration<LinearGradientProps> {\n constructor(ctx: NodeContext, props: LinearGradientProps) {\n super(ctx, NodeType.LinearGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeLinearGradient(\n start,\n end,\n colors,\n positions ?? null,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class RadialGradientNode extends ShaderDeclaration<RadialGradientProps> {\n constructor(ctx: NodeContext, props: RadialGradientProps) {\n super(ctx, NodeType.RadialGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { c, r } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeRadialGradient(\n c,\n r,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class SweepGradientNode extends ShaderDeclaration<SweepGradientProps> {\n constructor(ctx: NodeContext, props: SweepGradientProps) {\n super(ctx, NodeType.SweepGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { c, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeSweepGradient(\n c.x,\n c.y,\n colors,\n positions,\n mode,\n localMatrix,\n flags,\n start,\n end\n );\n ctx.shaders.push(shader);\n }\n}\n\nexport class TwoPointConicalGradientNode extends ShaderDeclaration<TwoPointConicalGradientProps> {\n constructor(ctx: NodeContext, props: TwoPointConicalGradientProps) {\n super(ctx, NodeType.TwoPointConicalGradient, props);\n }\n\n decorate(ctx: DeclarationContext) {\n const { startR, endR, start, end } = this.props;\n const { colors, positions, mode, localMatrix, flags } =\n processGradientProps(this.Skia, this.props);\n const shader = this.Skia.Shader.MakeTwoPointConicalGradient(\n start,\n startR,\n end,\n endR,\n colors,\n positions,\n mode,\n localMatrix,\n flags\n );\n ctx.shaders.push(shader);\n }\n}\n"],"mappings":";;;;;;;AAAA;;AAOA;;AAaA;;AACA;;AASO,MAAeA,iBAAf,SAA4CC,wBAA5C,CAAkE;EACvEC,WAAW,CAACC,GAAD,EAAmBC,IAAnB,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C5F,KAA7C;EACD;;EAEDK,QAAQ,CAACP,GAAD,EAA0B;IAChC,MAAM;MAAE+F,MAAF;MAAUC,IAAV;MAAgBpB,KAAhB;MAAuBC;IAAvB,IAA+B,KAAK3E,KAA1C;IACA,MAAM;MAAE4E,MAAF;MAAUC,SAAV;MAAqBC,IAArB;MAA2BC,WAA3B;MAAwCC;IAAxC,IACJ,IAAAC,+BAAA,EAAqB,KAAKtE,IAA1B,EAAgC,KAAKX,KAArC,CADF;IAEA,MAAMc,MAAM,GAAG,KAAKH,IAAL,CAAUT,MAAV,CAAiB6F,2BAAjB,CACbrB,KADa,EAEbmB,MAFa,EAGblB,GAHa,EAIbmB,IAJa,EAKblB,MALa,EAMbC,SANa,EAObC,IAPa,EAQbC,WARa,EASbC,KATa,CAAf;IAWAlF,GAAG,CAACmB,OAAJ,CAAYE,IAAZ,CAAiBL,MAAjB;EACD;;AArB8F"}
|
@@ -6,7 +6,7 @@ export interface DrawingNodeProps extends GroupProps {
|
|
6
6
|
}
|
7
7
|
export declare type ImageProps = DrawingNodeProps & RectDef & {
|
8
8
|
fit?: Fit;
|
9
|
-
image: SkImage;
|
9
|
+
image: SkImage | null;
|
10
10
|
};
|
11
11
|
export declare type CircleProps = CircleDef & DrawingNodeProps;
|
12
12
|
export interface PathProps extends DrawingNodeProps {
|
@@ -51,7 +51,7 @@ export interface VerticesProps extends DrawingNodeProps {
|
|
51
51
|
indices?: number[];
|
52
52
|
}
|
53
53
|
export declare type ImageSVGProps = RectDef & {
|
54
|
-
svg: SkSVG;
|
54
|
+
svg: SkSVG | null;
|
55
55
|
} & DrawingNodeProps;
|
56
56
|
export interface PictureProps extends DrawingNodeProps {
|
57
57
|
picture: SkPicture;
|
@@ -65,13 +65,13 @@ export interface DiffRectProps extends DrawingNodeProps {
|
|
65
65
|
outer: SkRRect;
|
66
66
|
}
|
67
67
|
export interface TextProps extends DrawingNodeProps {
|
68
|
-
font: SkFont;
|
68
|
+
font: SkFont | null;
|
69
69
|
text: string;
|
70
70
|
x: number;
|
71
71
|
y: number;
|
72
72
|
}
|
73
73
|
export interface TextPathProps extends DrawingNodeProps {
|
74
|
-
font: SkFont;
|
74
|
+
font: SkFont | null;
|
75
75
|
text: string;
|
76
76
|
path: PathDef;
|
77
77
|
initialOffset: number;
|
@@ -86,7 +86,7 @@ export interface Glyph {
|
|
86
86
|
pos: SkPoint;
|
87
87
|
}
|
88
88
|
export interface GlyphsProps extends DrawingNodeProps {
|
89
|
-
font: SkFont;
|
89
|
+
font: SkFont | null;
|
90
90
|
x: number;
|
91
91
|
y: number;
|
92
92
|
glyphs: Glyph[];
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["Drawings.ts"],"sourcesContent":["import type {\n FillType,\n SkImage,\n StrokeOpts,\n Vector,\n Color,\n SkPoint,\n BlendMode,\n PointMode,\n VertexMode,\n SkFont,\n SkRRect,\n SkTextBlob,\n SkPicture,\n SkSVG,\n SkPaint,\n SkRect,\n} from \"../../skia/types\";\n\nimport type {\n CircleDef,\n Fit,\n GroupProps,\n PathDef,\n RectDef,\n RRectDef,\n SkEnum,\n} from \"./Common\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\nexport interface DrawingNodeProps extends GroupProps {\n paint?: SkPaint;\n}\n\nexport type ImageProps = DrawingNodeProps &\n RectDef & {\n fit?: Fit;\n image: SkImage;\n };\n\nexport type CircleProps = CircleDef & DrawingNodeProps;\n\nexport interface PathProps extends DrawingNodeProps {\n path: PathDef;\n start: number;\n end: number;\n stroke?: StrokeOpts;\n fillType?: SkEnum<typeof FillType>;\n}\n\nexport interface CustomDrawingNodeProps extends DrawingNodeProps {\n drawing: (ctx: DrawingContext) => void;\n}\n\nexport interface LineProps extends DrawingNodeProps {\n p1: Vector;\n p2: Vector;\n}\n\nexport type OvalProps = RectDef & DrawingNodeProps;\n\nexport type RectProps = RectDef & DrawingNodeProps;\n\nexport type RoundedRectProps = RRectDef & DrawingNodeProps;\n\nexport interface CubicBezierHandle {\n pos: Vector;\n c1: Vector;\n c2: Vector;\n}\n\nexport interface PatchProps extends DrawingNodeProps {\n colors?: Color[];\n patch: [\n CubicBezierHandle,\n CubicBezierHandle,\n CubicBezierHandle,\n CubicBezierHandle\n ];\n texture?: readonly [SkPoint, SkPoint, SkPoint, SkPoint];\n blendMode?: SkEnum<typeof BlendMode>;\n}\n\nexport interface VerticesProps extends DrawingNodeProps {\n colors?: string[];\n vertices: SkPoint[];\n textures?: SkPoint[];\n mode: SkEnum<typeof VertexMode>;\n blendMode?: SkEnum<typeof BlendMode>;\n indices?: number[];\n}\n\nexport type ImageSVGProps = RectDef & {\n svg: SkSVG;\n} & DrawingNodeProps;\n\nexport interface PictureProps extends DrawingNodeProps {\n picture: SkPicture;\n}\n\nexport interface PointsProps extends DrawingNodeProps {\n points: SkPoint[];\n mode: SkEnum<typeof PointMode>;\n}\n\nexport interface DiffRectProps extends DrawingNodeProps {\n inner: SkRRect;\n outer: SkRRect;\n}\n\nexport interface TextProps extends DrawingNodeProps {\n font: SkFont;\n text: string;\n x: number;\n y: number;\n}\n\nexport interface TextPathProps extends DrawingNodeProps {\n font: SkFont;\n text: string;\n path: PathDef;\n initialOffset: number;\n}\n\nexport interface TextBlobProps extends DrawingNodeProps {\n blob: SkTextBlob;\n x: number;\n y: number;\n}\n\nexport interface Glyph {\n id: number;\n pos: SkPoint;\n}\n\nexport interface GlyphsProps extends DrawingNodeProps {\n font: SkFont;\n x: number;\n y: number;\n glyphs: Glyph[];\n}\n\nexport interface BoxProps extends DrawingNodeProps {\n box: SkRRect | SkRect;\n}\n\nexport interface BoxShadowProps {\n dx?: number;\n dy?: number;\n spread?: number;\n blur: number;\n color?: Color;\n inner?: boolean;\n}\n"],"mappings":""}
|
1
|
+
{"version":3,"names":[],"sources":["Drawings.ts"],"sourcesContent":["import type {\n FillType,\n SkImage,\n StrokeOpts,\n Vector,\n Color,\n SkPoint,\n BlendMode,\n PointMode,\n VertexMode,\n SkFont,\n SkRRect,\n SkTextBlob,\n SkPicture,\n SkSVG,\n SkPaint,\n SkRect,\n} from \"../../skia/types\";\n\nimport type {\n CircleDef,\n Fit,\n GroupProps,\n PathDef,\n RectDef,\n RRectDef,\n SkEnum,\n} from \"./Common\";\nimport type { DrawingContext } from \"./DrawingContext\";\n\nexport interface DrawingNodeProps extends GroupProps {\n paint?: SkPaint;\n}\n\nexport type ImageProps = DrawingNodeProps &\n RectDef & {\n fit?: Fit;\n image: SkImage | null;\n };\n\nexport type CircleProps = CircleDef & DrawingNodeProps;\n\nexport interface PathProps extends DrawingNodeProps {\n path: PathDef;\n start: number;\n end: number;\n stroke?: StrokeOpts;\n fillType?: SkEnum<typeof FillType>;\n}\n\nexport interface CustomDrawingNodeProps extends DrawingNodeProps {\n drawing: (ctx: DrawingContext) => void;\n}\n\nexport interface LineProps extends DrawingNodeProps {\n p1: Vector;\n p2: Vector;\n}\n\nexport type OvalProps = RectDef & DrawingNodeProps;\n\nexport type RectProps = RectDef & DrawingNodeProps;\n\nexport type RoundedRectProps = RRectDef & DrawingNodeProps;\n\nexport interface CubicBezierHandle {\n pos: Vector;\n c1: Vector;\n c2: Vector;\n}\n\nexport interface PatchProps extends DrawingNodeProps {\n colors?: Color[];\n patch: [\n CubicBezierHandle,\n CubicBezierHandle,\n CubicBezierHandle,\n CubicBezierHandle\n ];\n texture?: readonly [SkPoint, SkPoint, SkPoint, SkPoint];\n blendMode?: SkEnum<typeof BlendMode>;\n}\n\nexport interface VerticesProps extends DrawingNodeProps {\n colors?: string[];\n vertices: SkPoint[];\n textures?: SkPoint[];\n mode: SkEnum<typeof VertexMode>;\n blendMode?: SkEnum<typeof BlendMode>;\n indices?: number[];\n}\n\nexport type ImageSVGProps = RectDef & {\n svg: SkSVG | null;\n} & DrawingNodeProps;\n\nexport interface PictureProps extends DrawingNodeProps {\n picture: SkPicture;\n}\n\nexport interface PointsProps extends DrawingNodeProps {\n points: SkPoint[];\n mode: SkEnum<typeof PointMode>;\n}\n\nexport interface DiffRectProps extends DrawingNodeProps {\n inner: SkRRect;\n outer: SkRRect;\n}\n\nexport interface TextProps extends DrawingNodeProps {\n font: SkFont | null;\n text: string;\n x: number;\n y: number;\n}\n\nexport interface TextPathProps extends DrawingNodeProps {\n font: SkFont | null;\n text: string;\n path: PathDef;\n initialOffset: number;\n}\n\nexport interface TextBlobProps extends DrawingNodeProps {\n blob: SkTextBlob;\n x: number;\n y: number;\n}\n\nexport interface Glyph {\n id: number;\n pos: SkPoint;\n}\n\nexport interface GlyphsProps extends DrawingNodeProps {\n font: SkFont | null;\n x: number;\n y: number;\n glyphs: Glyph[];\n}\n\nexport interface BoxProps extends DrawingNodeProps {\n box: SkRRect | SkRect;\n}\n\nexport interface BoxShadowProps {\n dx?: number;\n dy?: number;\n spread?: number;\n blur: number;\n color?: Color;\n inner?: boolean;\n}\n"],"mappings":""}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["Shaders.ts"],"sourcesContent":["import type {\n Color,\n FilterMode,\n MipmapMode,\n SkImage,\n SkRect,\n SkRuntimeEffect,\n TileMode,\n Uniforms,\n Vector,\n} from \"../../skia/types\";\n\nimport type {\n SkEnum,\n TransformProps,\n ChildrenProps,\n RectCtor,\n Fit,\n} from \"./Common\";\n\nexport interface ShaderProps extends TransformProps, ChildrenProps {\n source: SkRuntimeEffect;\n uniforms: Uniforms;\n}\n\nexport interface ImageShaderProps extends TransformProps, Partial<RectCtor> {\n tx: SkEnum<typeof TileMode>;\n ty: SkEnum<typeof TileMode>;\n fm: SkEnum<typeof FilterMode>;\n mm: SkEnum<typeof MipmapMode>;\n fit: Fit;\n rect?: SkRect;\n image: SkImage;\n}\n\nexport interface ColorProps {\n color: Color;\n}\n\nexport interface TurbulenceProps {\n freqX: number;\n freqY: number;\n octaves: number;\n seed: number;\n tileWidth: number;\n tileHeight: number;\n}\n\nexport interface FractalNoiseProps {\n freqX: number;\n freqY: number;\n octaves: number;\n seed: number;\n tileWidth: number;\n tileHeight: number;\n}\n\nexport interface GradientProps extends TransformProps {\n colors: Color[];\n positions?: number[];\n mode?: SkEnum<typeof TileMode>;\n flags?: number;\n}\n\nexport interface LinearGradientProps extends GradientProps {\n start: Vector;\n end: Vector;\n}\n\nexport interface RadialGradientProps extends GradientProps {\n c: Vector;\n r: number;\n}\n\nexport interface SweepGradientProps extends GradientProps {\n c: Vector;\n start?: number;\n end?: number;\n}\n\nexport interface TwoPointConicalGradientProps extends GradientProps {\n start: Vector;\n startR: number;\n end: Vector;\n endR: number;\n}\n"],"mappings":""}
|
1
|
+
{"version":3,"names":[],"sources":["Shaders.ts"],"sourcesContent":["import type {\n Color,\n FilterMode,\n MipmapMode,\n SkImage,\n SkRect,\n SkRuntimeEffect,\n TileMode,\n Uniforms,\n Vector,\n} from \"../../skia/types\";\n\nimport type {\n SkEnum,\n TransformProps,\n ChildrenProps,\n RectCtor,\n Fit,\n} from \"./Common\";\n\nexport interface ShaderProps extends TransformProps, ChildrenProps {\n source: SkRuntimeEffect;\n uniforms: Uniforms;\n}\n\nexport interface ImageShaderProps extends TransformProps, Partial<RectCtor> {\n tx: SkEnum<typeof TileMode>;\n ty: SkEnum<typeof TileMode>;\n fm: SkEnum<typeof FilterMode>;\n mm: SkEnum<typeof MipmapMode>;\n fit: Fit;\n rect?: SkRect;\n image: SkImage | null;\n}\n\nexport interface ColorProps {\n color: Color;\n}\n\nexport interface TurbulenceProps {\n freqX: number;\n freqY: number;\n octaves: number;\n seed: number;\n tileWidth: number;\n tileHeight: number;\n}\n\nexport interface FractalNoiseProps {\n freqX: number;\n freqY: number;\n octaves: number;\n seed: number;\n tileWidth: number;\n tileHeight: number;\n}\n\nexport interface GradientProps extends TransformProps {\n colors: Color[];\n positions?: number[];\n mode?: SkEnum<typeof TileMode>;\n flags?: number;\n}\n\nexport interface LinearGradientProps extends GradientProps {\n start: Vector;\n end: Vector;\n}\n\nexport interface RadialGradientProps extends GradientProps {\n c: Vector;\n r: number;\n}\n\nexport interface SweepGradientProps extends GradientProps {\n c: Vector;\n start?: number;\n end?: number;\n}\n\nexport interface TwoPointConicalGradientProps extends GradientProps {\n start: Vector;\n startR: number;\n end: Vector;\n endR: number;\n}\n"],"mappings":""}
|
@@ -118,7 +118,8 @@ const Mock = {
|
|
118
118
|
mixColors: (_v, _x, _y) => Float32Array.of(0, 0, 0, 0),
|
119
119
|
ShaderLib: _ShaderLib.ShaderLib,
|
120
120
|
createDrawing: Noop,
|
121
|
-
createDeclaration: Noop
|
121
|
+
createDeclaration: Noop,
|
122
|
+
makeImageFromView: Noop
|
122
123
|
};
|
123
124
|
exports.Mock = Mock;
|
124
125
|
//# sourceMappingURL=index.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","BaseSkia","useRawData","useData","useFont","useTypeface","useImage","useSVG","createPicture","rect","width","height","rrect","r","rx","ry","point","add","a","b","sub","neg","dist","Math","hypot","translate","translateX","translateY","bounds","topLeft","topRight","bottomLeft","bottomRight","center","processTransform2d","Values","ValuesHooks","Selector","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","ShaderLib","createDrawing","createDeclaration"],"sources":["index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Color, Skia as SkiaApi, SkRect, Vector } from \"../skia/types\";\nimport * as Values from \"../values/web\";\nimport * as ValuesHooks from \"../values/hooks\";\nimport { Selector } from \"../values/selector\";\nimport * as BaseSkia from \"../skia/types\";\nimport type * as SkiaExports from \"../skia\";\nimport type * as ValueExports from \"../values\";\nimport type * as AnimationExports from \"../animation\";\nimport * as timingFunctions from \"../animation/timing\";\nimport * as springFunctions from \"../animation/spring\";\nimport * as decayFunctions from \"../animation/decay\";\nimport * as interpolateFn from \"../animation/functions/interpolate\";\nimport * as interpolatePathFn from \"../animation/functions/interpolatePaths\";\nimport * as interpolateVectorFn from \"../animation/functions/interpolateVector\";\nimport { ShaderLib } from \"../renderer/components/shaders/ShaderLib\";\n\nclass Stub {\n constructor() {\n return new Proxy(() => {}, {\n get: () => new Stub(),\n apply: () => new Stub(),\n set: () => true,\n });\n }\n}\n\nconst Noop: () => any = () => {};\n\nexport const Skia: SkiaApi = new Stub() as any;\n\nexport const vec = (x?: number, y?: number) => ({ x: x ?? 0, y: y ?? x ?? 0 });\n\nexport const Mock: typeof SkiaExports &\n typeof ValueExports &\n typeof AnimationExports & {\n createDrawing: () => any;\n createDeclaration: () => any;\n ShaderLib: typeof ShaderLib;\n } = {\n // SkiaExports\n // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc\n Skia,\n ...BaseSkia,\n // 2. Hooks\n useRawData: Noop,\n useData: Noop,\n useFont: Noop,\n useTypeface: Noop,\n useImage: Noop,\n useSVG: Noop,\n createPicture: Noop,\n // 3. Point/Rect/Transform utilities\n vec,\n rect: (x: number, y: number, width: number, height: number) => ({\n x,\n y,\n width,\n height,\n }),\n rrect: (r: SkRect, rx: number, ry: number) => ({\n rect: r,\n rx,\n ry,\n }),\n point: vec,\n add: (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y),\n sub: (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y),\n neg: (a: Vector) => vec(-a.x, -a.y),\n dist: (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y),\n translate: ({ x, y }: Vector) =>\n [{ translateX: x }, { translateY: y }] as const,\n\n bounds: Noop,\n topLeft: Noop,\n topRight: Noop,\n bottomLeft: Noop,\n bottomRight: Noop,\n center: Noop,\n processTransform2d: Noop,\n // ValueExports\n ...Values,\n ...ValuesHooks,\n Selector,\n // Animations\n ...timingFunctions,\n ...springFunctions,\n ...decayFunctions,\n ...interpolateFn,\n ...interpolatePathFn,\n ...interpolateVectorFn,\n interpolateColors: (\n _value: number,\n _inputRange: number[],\n _outputRange: Color[]\n ) => Float32Array.of(0, 0, 0, 0),\n mixColors: (_v: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kBA5CI;EA6CJ;EACA,GAAGC,eA9CC;EA+CJ,GAAGC,eA/CC;EAgDJ,GAAGC,cAhDC;EAiDJ,GAAGC,aAjDC;EAkDJ,GAAGC,iBAlDC;EAmDJ,GAAGC,mBAnDC;EAoDJC,iBAAiB,EAAE,CACjBC,MADiB,EAEjBC,WAFiB,EAGjBC,YAHiB,KAIdC,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CAxDD;EAyDJC,SAAS,EAAE,CAACC,EAAD,EAAaC,EAAb,EAAwBC,EAAxB,KAAsCL,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CAzD7C;EA0DJK,SAAS,EAATA,oBA1DI;EA2DJC,aAAa,EAAE5D,IA3DX;EA4DJ6D,iBAAiB,EAAE7D;
|
1
|
+
{"version":3,"names":["Stub","constructor","Proxy","get","apply","set","Noop","Skia","vec","x","y","Mock","BaseSkia","useRawData","useData","useFont","useTypeface","useImage","useSVG","createPicture","rect","width","height","rrect","r","rx","ry","point","add","a","b","sub","neg","dist","Math","hypot","translate","translateX","translateY","bounds","topLeft","topRight","bottomLeft","bottomRight","center","processTransform2d","Values","ValuesHooks","Selector","timingFunctions","springFunctions","decayFunctions","interpolateFn","interpolatePathFn","interpolateVectorFn","interpolateColors","_value","_inputRange","_outputRange","Float32Array","of","mixColors","_v","_x","_y","ShaderLib","createDrawing","createDeclaration","makeImageFromView"],"sources":["index.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n\nimport type { Color, Skia as SkiaApi, SkRect, Vector } from \"../skia/types\";\nimport * as Values from \"../values/web\";\nimport * as ValuesHooks from \"../values/hooks\";\nimport { Selector } from \"../values/selector\";\nimport * as BaseSkia from \"../skia/types\";\nimport type * as SkiaExports from \"../skia\";\nimport type * as ValueExports from \"../values\";\nimport type * as AnimationExports from \"../animation\";\nimport * as timingFunctions from \"../animation/timing\";\nimport * as springFunctions from \"../animation/spring\";\nimport * as decayFunctions from \"../animation/decay\";\nimport * as interpolateFn from \"../animation/functions/interpolate\";\nimport * as interpolatePathFn from \"../animation/functions/interpolatePaths\";\nimport * as interpolateVectorFn from \"../animation/functions/interpolateVector\";\nimport { ShaderLib } from \"../renderer/components/shaders/ShaderLib\";\n\nclass Stub {\n constructor() {\n return new Proxy(() => {}, {\n get: () => new Stub(),\n apply: () => new Stub(),\n set: () => true,\n });\n }\n}\n\nconst Noop: () => any = () => {};\n\nexport const Skia: SkiaApi = new Stub() as any;\n\nexport const vec = (x?: number, y?: number) => ({ x: x ?? 0, y: y ?? x ?? 0 });\n\nexport const Mock: typeof SkiaExports &\n typeof ValueExports &\n typeof AnimationExports & {\n createDrawing: () => any;\n createDeclaration: () => any;\n ShaderLib: typeof ShaderLib;\n } = {\n // SkiaExports\n // 1. Skia API. BaseSkia contains the enums, and functions like isPaint etc\n Skia,\n ...BaseSkia,\n // 2. Hooks\n useRawData: Noop,\n useData: Noop,\n useFont: Noop,\n useTypeface: Noop,\n useImage: Noop,\n useSVG: Noop,\n createPicture: Noop,\n // 3. Point/Rect/Transform utilities\n vec,\n rect: (x: number, y: number, width: number, height: number) => ({\n x,\n y,\n width,\n height,\n }),\n rrect: (r: SkRect, rx: number, ry: number) => ({\n rect: r,\n rx,\n ry,\n }),\n point: vec,\n add: (a: Vector, b: Vector) => vec(a.x + b.x, a.y + b.y),\n sub: (a: Vector, b: Vector) => vec(a.x - b.x, a.y - b.y),\n neg: (a: Vector) => vec(-a.x, -a.y),\n dist: (a: Vector, b: Vector) => Math.hypot(a.x - b.x, a.y - b.y),\n translate: ({ x, y }: Vector) =>\n [{ translateX: x }, { translateY: y }] as const,\n\n bounds: Noop,\n topLeft: Noop,\n topRight: Noop,\n bottomLeft: Noop,\n bottomRight: Noop,\n center: Noop,\n processTransform2d: Noop,\n // ValueExports\n ...Values,\n ...ValuesHooks,\n Selector,\n // Animations\n ...timingFunctions,\n ...springFunctions,\n ...decayFunctions,\n ...interpolateFn,\n ...interpolatePathFn,\n ...interpolateVectorFn,\n interpolateColors: (\n _value: number,\n _inputRange: number[],\n _outputRange: Color[]\n ) => Float32Array.of(0, 0, 0, 0),\n mixColors: (_v: number, _x: Color, _y: Color) => Float32Array.of(0, 0, 0, 0),\n ShaderLib,\n createDrawing: Noop,\n createDeclaration: Noop,\n makeImageFromView: Noop,\n};\n"],"mappings":";;;;;;;AAGA;;AACA;;AACA;;AACA;;AAIA;;AACA;;AACA;;AACA;;AACA;;AACA;;AACA;;;;;;AAhBA;AAkBA,MAAMA,IAAN,CAAW;EACTC,WAAW,GAAG;IACZ,OAAO,IAAIC,KAAJ,CAAU,MAAM,CAAE,CAAlB,EAAoB;MACzBC,GAAG,EAAE,MAAM,IAAIH,IAAJ,EADc;MAEzBI,KAAK,EAAE,MAAM,IAAIJ,IAAJ,EAFY;MAGzBK,GAAG,EAAE,MAAM;IAHc,CAApB,CAAP;EAKD;;AAPQ;;AAUX,MAAMC,IAAe,GAAG,MAAM,CAAE,CAAhC;;AAEO,MAAMC,IAAa,GAAG,IAAIP,IAAJ,EAAtB;;;AAEA,MAAMQ,GAAG,GAAG,CAACC,CAAD,EAAaC,CAAb,MAA6B;EAAED,CAAC,EAAEA,CAAC,IAAI,CAAV;EAAaC,CAAC,EAAEA,CAAC,IAAID,CAAL,IAAU;AAA1B,CAA7B,CAAZ;;;AAEA,MAAME,IAMV,GAAG;EACJ;EACA;EACAJ,IAHI;EAIJ,GAAGK,QAJC;EAKJ;EACAC,UAAU,EAAEP,IANR;EAOJQ,OAAO,EAAER,IAPL;EAQJS,OAAO,EAAET,IARL;EASJU,WAAW,EAAEV,IATT;EAUJW,QAAQ,EAAEX,IAVN;EAWJY,MAAM,EAAEZ,IAXJ;EAYJa,aAAa,EAAEb,IAZX;EAaJ;EACAE,GAdI;EAeJY,IAAI,EAAE,CAACX,CAAD,EAAYC,CAAZ,EAAuBW,KAAvB,EAAsCC,MAAtC,MAA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CR;EAsCJqC,WAAW,EAAErC,IAtCT;EAuCJsC,MAAM,EAAEtC,IAvCJ;EAwCJuC,kBAAkB,EAAEvC,IAxChB;EAyCJ;EACA,GAAGwC,MA1CC;EA2CJ,GAAGC,WA3CC;EA4CJC,QAAQ,EAARA,kBA5CI;EA6CJ;EACA,GAAGC,eA9CC;EA+CJ,GAAGC,eA/CC;EAgDJ,GAAGC,cAhDC;EAiDJ,GAAGC,aAjDC;EAkDJ,GAAGC,iBAlDC;EAmDJ,GAAGC,mBAnDC;EAoDJC,iBAAiB,EAAE,CACjBC,MADiB,EAEjBC,WAFiB,EAGjBC,YAHiB,KAIdC,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CAxDD;EAyDJC,SAAS,EAAE,CAACC,EAAD,EAAaC,EAAb,EAAwBC,EAAxB,KAAsCL,YAAY,CAACC,EAAb,CAAgB,CAAhB,EAAmB,CAAnB,EAAsB,CAAtB,EAAyB,CAAzB,CAzD7C;EA0DJK,SAAS,EAATA,oBA1DI;EA2DJC,aAAa,EAAE5D,IA3DX;EA4DJ6D,iBAAiB,EAAE7D,IA5Df;EA6DJ8D,iBAAiB,EAAE9D;AA7Df,CANC"}
|
@@ -1,5 +1,17 @@
|
|
1
|
-
|
1
|
+
/// <reference types="react" />
|
2
|
+
import type { DataSourceParam, SkImage } from "../types";
|
2
3
|
/**
|
3
4
|
* Returns a Skia Image object
|
4
5
|
* */
|
5
|
-
export declare const useImage: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) =>
|
6
|
+
export declare const useImage: (source: DataSourceParam, onError?: ((err: Error) => void) | undefined) => SkImage | null;
|
7
|
+
/**
|
8
|
+
* Creates an image from a given view reference. NOTE: This method has different implementations
|
9
|
+
* on web/native. On web, the callback is called with the view ref and the callback is expected to
|
10
|
+
* return a promise that resolves to a Skia Image object. On native, the view ref is used to
|
11
|
+
* find the view tag and the Skia Image object is created from the view tag. This means that on web
|
12
|
+
* you will need to implement the logic to create the image from the view ref yourself.
|
13
|
+
* @param viewRef Ref to the view we're creating an image from
|
14
|
+
* @returns A promise that resolves to a Skia Image object or rejects
|
15
|
+
* with an error id the view tag is invalid.
|
16
|
+
*/
|
17
|
+
export declare const makeImageFromView: <T extends number | import("react").Component<unknown, unknown, any> | import("react").ComponentClass<unknown, any>>(viewRef: import("react").RefObject<T>, callback?: ((viewRef: import("react").RefObject<T>) => Promise<SkImage | null>) | null) => Promise<SkImage | null>;
|
@@ -3,7 +3,9 @@
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
4
4
|
value: true
|
5
5
|
});
|
6
|
-
exports.useImage = void 0;
|
6
|
+
exports.useImage = exports.makeImageFromView = void 0;
|
7
|
+
|
8
|
+
var _reactNative = require("react-native");
|
7
9
|
|
8
10
|
var _Skia = require("../Skia");
|
9
11
|
|
@@ -16,6 +18,40 @@ const imgFactory = _Skia.Skia.Image.MakeImageFromEncoded.bind(_Skia.Skia.Image);
|
|
16
18
|
|
17
19
|
|
18
20
|
const useImage = (source, onError) => (0, _Data.useRawData)(source, imgFactory, onError);
|
21
|
+
/**
|
22
|
+
* Creates an image from a given view reference. NOTE: This method has different implementations
|
23
|
+
* on web/native. On web, the callback is called with the view ref and the callback is expected to
|
24
|
+
* return a promise that resolves to a Skia Image object. On native, the view ref is used to
|
25
|
+
* find the view tag and the Skia Image object is created from the view tag. This means that on web
|
26
|
+
* you will need to implement the logic to create the image from the view ref yourself.
|
27
|
+
* @param viewRef Ref to the view we're creating an image from
|
28
|
+
* @returns A promise that resolves to a Skia Image object or rejects
|
29
|
+
* with an error id the view tag is invalid.
|
30
|
+
*/
|
31
|
+
|
19
32
|
|
20
33
|
exports.useImage = useImage;
|
34
|
+
|
35
|
+
const makeImageFromView = function (viewRef) {
|
36
|
+
let callback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
|
37
|
+
|
38
|
+
// In web implementation we just delegate the work to the provided callback
|
39
|
+
if (_reactNative.Platform.OS === "web") {
|
40
|
+
if (callback) {
|
41
|
+
return callback(viewRef);
|
42
|
+
} else {
|
43
|
+
Promise.reject(new Error("Callback is required on web in the makeImageFromView function."));
|
44
|
+
}
|
45
|
+
}
|
46
|
+
|
47
|
+
const viewTag = (0, _reactNative.findNodeHandle)(viewRef.current);
|
48
|
+
|
49
|
+
if (viewTag !== null && viewTag !== 0) {
|
50
|
+
return _Skia.Skia.Image.MakeImageFromViewTag(viewTag);
|
51
|
+
}
|
52
|
+
|
53
|
+
return Promise.reject(new Error("Invalid view tag"));
|
54
|
+
};
|
55
|
+
|
56
|
+
exports.makeImageFromView = makeImageFromView;
|
21
57
|
//# sourceMappingURL=Image.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["imgFactory","Skia","Image","MakeImageFromEncoded","bind","useImage","source","onError","useRawData"],"sources":["Image.ts"],"sourcesContent":["import { Skia } from \"../Skia\";\nimport type { DataSourceParam } from \"../types\";\n\nimport { useRawData } from \"./Data\";\n\nconst imgFactory = Skia.Image.MakeImageFromEncoded.bind(Skia.Image);\n\n/**\n * Returns a Skia Image object\n * */\nexport const useImage = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => useRawData(source, imgFactory, onError);\n"],"mappings":";;;;;;;AAAA;;AAGA;;AAEA,MAAMA,UAAU,GAAGC,UAAA,CAAKC,KAAL,CAAWC,oBAAX,CAAgCC,IAAhC,CAAqCH,UAAA,CAAKC,KAA1C,CAAnB;AAEA;AACA;AACA;;;AACO,MAAMG,QAAQ,GAAG,CACtBC,MADsB,EAEtBC,OAFsB,KAGnB,IAAAC,gBAAA,EAAWF,MAAX,EAAmBN,UAAnB,EAA+BO,OAA/B,CAHE"}
|
1
|
+
{"version":3,"names":["imgFactory","Skia","Image","MakeImageFromEncoded","bind","useImage","source","onError","useRawData","makeImageFromView","viewRef","callback","Platform","OS","Promise","reject","Error","viewTag","findNodeHandle","current","MakeImageFromViewTag"],"sources":["Image.ts"],"sourcesContent":["import { findNodeHandle, Platform } from \"react-native\";\n\nimport { Skia } from \"../Skia\";\nimport type { DataSourceParam, SkImage } from \"../types\";\n\nimport { useRawData } from \"./Data\";\n\nconst imgFactory = Skia.Image.MakeImageFromEncoded.bind(Skia.Image);\n\n/**\n * Returns a Skia Image object\n * */\nexport const useImage = (\n source: DataSourceParam,\n onError?: (err: Error) => void\n) => useRawData(source, imgFactory, onError);\n\n/**\n * Creates an image from a given view reference. NOTE: This method has different implementations\n * on web/native. On web, the callback is called with the view ref and the callback is expected to\n * return a promise that resolves to a Skia Image object. On native, the view ref is used to\n * find the view tag and the Skia Image object is created from the view tag. This means that on web\n * you will need to implement the logic to create the image from the view ref yourself.\n * @param viewRef Ref to the view we're creating an image from\n * @returns A promise that resolves to a Skia Image object or rejects\n * with an error id the view tag is invalid.\n */\nexport const makeImageFromView = <\n T extends\n | number\n | React.Component<unknown, unknown>\n | React.ComponentClass<unknown>\n>(\n viewRef: React.RefObject<T>,\n callback:\n | null\n | ((viewRef: React.RefObject<T>) => Promise<SkImage | null>) = null\n) => {\n // In web implementation we just delegate the work to the provided callback\n if (Platform.OS === \"web\") {\n if (callback) {\n return callback(viewRef);\n } else {\n Promise.reject(\n new Error(\n \"Callback is required on web in the makeImageFromView function.\"\n )\n );\n }\n }\n const viewTag = findNodeHandle(viewRef.current);\n if (viewTag !== null && viewTag !== 0) {\n return Skia.Image.MakeImageFromViewTag(viewTag);\n }\n return Promise.reject(new Error(\"Invalid view tag\"));\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAGA;;AAEA,MAAMA,UAAU,GAAGC,UAAA,CAAKC,KAAL,CAAWC,oBAAX,CAAgCC,IAAhC,CAAqCH,UAAA,CAAKC,KAA1C,CAAnB;AAEA;AACA;AACA;;;AACO,MAAMG,QAAQ,GAAG,CACtBC,MADsB,EAEtBC,OAFsB,KAGnB,IAAAC,gBAAA,EAAWF,MAAX,EAAmBN,UAAnB,EAA+BO,OAA/B,CAHE;AAKP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAME,iBAAiB,GAAG,UAM/BC,OAN+B,EAU5B;EAAA,IAHHC,QAGG,uEAD8D,IAC9D;;EACH;EACA,IAAIC,qBAAA,CAASC,EAAT,KAAgB,KAApB,EAA2B;IACzB,IAAIF,QAAJ,EAAc;MACZ,OAAOA,QAAQ,CAACD,OAAD,CAAf;IACD,CAFD,MAEO;MACLI,OAAO,CAACC,MAAR,CACE,IAAIC,KAAJ,CACE,gEADF,CADF;IAKD;EACF;;EACD,MAAMC,OAAO,GAAG,IAAAC,2BAAA,EAAeR,OAAO,CAACS,OAAvB,CAAhB;;EACA,IAAIF,OAAO,KAAK,IAAZ,IAAoBA,OAAO,KAAK,CAApC,EAAuC;IACrC,OAAOhB,UAAA,CAAKC,KAAL,CAAWkB,oBAAX,CAAgCH,OAAhC,CAAP;EACD;;EACD,OAAOH,OAAO,CAACC,MAAR,CAAe,IAAIC,KAAJ,CAAU,kBAAV,CAAf,CAAP;AACD,CA5BM"}
|
@@ -72,4 +72,10 @@ export interface SkImage extends SkJSIInstance<"Image">, JsiDisposable {
|
|
72
72
|
@return base64 encoded string of data
|
73
73
|
*/
|
74
74
|
encodeToBase64(fmt?: ImageFormat, quality?: number): string;
|
75
|
+
/**
|
76
|
+
* Returns raster image or lazy image. Copies SkImage backed by GPU texture
|
77
|
+
* into CPU memory if needed. Returns original SkImage if decoded in raster
|
78
|
+
* bitmap, or if encoded in a stream.
|
79
|
+
*/
|
80
|
+
makeNonTextureImage(): SkImage;
|
75
81
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["FilterMode","MipmapMode","ImageFormat"],"sources":["Image.ts"],"sourcesContent":["import type { SkMatrix } from \"../Matrix\";\nimport type { JsiDisposable, SkJSIInstance } from \"../JsiInstance\";\nimport type { TileMode } from \"../ImageFilter\";\nimport type { SkShader } from \"../Shader\";\n\nexport enum FilterMode {\n Nearest,\n Linear,\n}\n\nexport enum MipmapMode {\n None,\n Nearest,\n Linear,\n}\n\nexport enum ImageFormat {\n JPEG = 3,\n PNG = 4,\n WEBP = 6,\n}\n\nexport interface SkImage extends SkJSIInstance<\"Image\">, JsiDisposable {\n /**\n * Returns the possibly scaled height of the image.\n */\n height(): number;\n\n /**\n * Returns the possibly scaled width of the image.\n */\n width(): number;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param fm - The filter mode. (default nearest)\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps (default none)\n * calculated with makeCopyWithDefaultMipmaps;\n * @param localMatrix\n */\n makeShaderOptions(\n tx: TileMode,\n ty: TileMode,\n fm: FilterMode,\n mm: MipmapMode,\n localMatrix?: SkMatrix\n ): SkShader;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param localMatrix\n */\n makeShaderCubic(\n tx: TileMode,\n ty: TileMode,\n B: number,\n C: number,\n localMatrix?: SkMatrix\n ): SkShader;\n\n /** Encodes Image pixels, returning result as UInt8Array. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return Uint8Array with data\n */\n encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array;\n\n /** Encodes Image pixels, returning result as a base64 encoded string. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return base64 encoded string of data\n */\n encodeToBase64(fmt?: ImageFormat, quality?: number): string;\n}\n"],"mappings":";;;;;;IAKYA,U;;;WAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;IAKAC,U;;;WAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;IAMAC,W;;;WAAAA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;GAAAA,W,2BAAAA,W"}
|
1
|
+
{"version":3,"names":["FilterMode","MipmapMode","ImageFormat"],"sources":["Image.ts"],"sourcesContent":["import type { SkMatrix } from \"../Matrix\";\nimport type { JsiDisposable, SkJSIInstance } from \"../JsiInstance\";\nimport type { TileMode } from \"../ImageFilter\";\nimport type { SkShader } from \"../Shader\";\n\nexport enum FilterMode {\n Nearest,\n Linear,\n}\n\nexport enum MipmapMode {\n None,\n Nearest,\n Linear,\n}\n\nexport enum ImageFormat {\n JPEG = 3,\n PNG = 4,\n WEBP = 6,\n}\n\nexport interface SkImage extends SkJSIInstance<\"Image\">, JsiDisposable {\n /**\n * Returns the possibly scaled height of the image.\n */\n height(): number;\n\n /**\n * Returns the possibly scaled width of the image.\n */\n width(): number;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param fm - The filter mode. (default nearest)\n * @param mm - The mipmap mode. Note: for settings other than None, the image must have mipmaps (default none)\n * calculated with makeCopyWithDefaultMipmaps;\n * @param localMatrix\n */\n makeShaderOptions(\n tx: TileMode,\n ty: TileMode,\n fm: FilterMode,\n mm: MipmapMode,\n localMatrix?: SkMatrix\n ): SkShader;\n\n /**\n * Returns this image as a shader with the specified tiling. It will use cubic sampling.\n * @param tx - tile mode in the x direction.\n * @param ty - tile mode in the y direction.\n * @param B - See CubicResampler in SkSamplingOptions.h for more information\n * @param C - See CubicResampler in SkSamplingOptions.h for more information\n * @param localMatrix\n */\n makeShaderCubic(\n tx: TileMode,\n ty: TileMode,\n B: number,\n C: number,\n localMatrix?: SkMatrix\n ): SkShader;\n\n /** Encodes Image pixels, returning result as UInt8Array. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return Uint8Array with data\n */\n encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array;\n\n /** Encodes Image pixels, returning result as a base64 encoded string. Returns existing\n encoded data if present; otherwise, SkImage is encoded with\n SkEncodedImageFormat::kPNG. Skia must be built with SK_ENCODE_PNG to encode\n SkImage.\n\n Returns nullptr if existing encoded data is missing or invalid, and\n encoding fails.\n\n @param fmt - PNG is the default value.\n @param quality - a value from 0 to 100; 100 is the least lossy. May be ignored.\n\n @return base64 encoded string of data\n */\n encodeToBase64(fmt?: ImageFormat, quality?: number): string;\n\n /**\n * Returns raster image or lazy image. Copies SkImage backed by GPU texture\n * into CPU memory if needed. Returns original SkImage if decoded in raster\n * bitmap, or if encoded in a stream.\n */\n makeNonTextureImage(): SkImage;\n}\n"],"mappings":";;;;;;IAKYA,U;;;WAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;IAKAC,U;;;WAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;EAAAA,U,CAAAA,U;GAAAA,U,0BAAAA,U;;IAMAC,W;;;WAAAA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;EAAAA,W,CAAAA,W;GAAAA,W,2BAAAA,W"}
|
@@ -48,6 +48,13 @@ export interface ImageFactory {
|
|
48
48
|
* image, nullptr is returned.
|
49
49
|
*/
|
50
50
|
MakeImageFromEncoded: (encoded: SkData) => SkImage | null;
|
51
|
+
/**
|
52
|
+
* Returns an image that will be a screenshot of the view represented by
|
53
|
+
* the view tag
|
54
|
+
* @param viewTag - The tag of the view to make an image from.
|
55
|
+
* @returns Returns a valid SkImage, if the view tag is invalid, nullptr is returned.
|
56
|
+
*/
|
57
|
+
MakeImageFromViewTag: (viewTag: number) => Promise<SkImage | null>;
|
51
58
|
/**
|
52
59
|
* Returns an image with the given pixel data and format.
|
53
60
|
* Note that we will always make a copy of the pixel data, because of inconsistencies in
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["AlphaType","ColorType"],"sources":["ImageFactory.ts"],"sourcesContent":["import type { SkData } from \"../Data\";\n\nimport type { SkImage } from \"./Image\";\n\nexport enum AlphaType {\n Unknown,\n Opaque,\n Premul,\n Unpremul,\n}\n\nexport enum ColorType {\n Unknown, //!< uninitialized\n Alpha_8, //!< pixel with alpha in 8-bit byte\n RGB_565, //!< pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word\n ARGB_4444, //!< pixel with 4 bits for alpha, red, green, blue; in 16-bit word\n RGBA_8888, //!< pixel with 8 bits for red, green, blue, alpha; in 32-bit word\n RGB_888x, //!< pixel with 8 bits each for red, green, blue; in 32-bit word\n BGRA_8888, //!< pixel with 8 bits for blue, green, red, alpha; in 32-bit word\n RGBA_1010102, //!< 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word\n BGRA_1010102, //!< 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word\n RGB_101010x, //!< pixel with 10 bits each for red, green, blue; in 32-bit word\n BGR_101010x, //!< pixel with 10 bits each for blue, green, red; in 32-bit word\n Gray_8, //!< pixel with grayscale level in 8-bit byte\n RGBA_F16Norm, //!< pixel with half floats in [0,1] for red, green, blue, alpha;\n // in 64-bit word\n RGBA_F16, //!< pixel with half floats for red, green, blue, alpha;\n // in 64-bit word\n RGBA_F32, //!< pixel using C float for red, green, blue, alpha; in 128-bit word\n\n // The following 6 colortypes are just for reading from - not for rendering to\n R8G8_unorm, //!< pixel with a uint8_t for red and green\n\n A16_float, //!< pixel with a half float for alpha\n R16G16_float, //!< pixel with a half float for red and green\n\n A16_unorm, //!< pixel with a little endian uint16_t for alpha\n R16G16_unorm, //!< pixel with a little endian uint16_t for red and green\n R16G16B16A16_unorm, //!< pixel with a little endian uint16_t for red, green, blue\n // and alpha\n SRGBA_8888,\n}\n\nexport interface ImageInfo {\n alphaType: AlphaType;\n // TODO: add support for color space\n // colorSpace: ColorSpace;\n colorType: ColorType;\n height: number;\n width: number;\n}\n\nexport interface ImageFactory {\n /**\n * Return an Image backed by the encoded data, but attempt to defer decoding until the image\n * is actually used/drawn. This deferral allows the system to cache the result, either on the\n * CPU or on the GPU, depending on where the image is drawn.\n * This decoding uses the codecs that have been compiled into CanvasKit. If the bytes are\n * invalid (or an unrecognized codec), null will be returned. See Image.h for more details.\n * @param data - Data object with bytes of data\n * @returns If the encoded format is not supported, or subset is outside of the bounds of the decoded\n * image, nullptr is returned.\n */\n MakeImageFromEncoded: (encoded: SkData) => SkImage | null;\n\n /**\n * Returns an image with the given pixel data and format.\n * Note that we will always make a copy of the pixel data, because of inconsistencies in\n * behavior between GPU and CPU (i.e. the pixel data will be turned into a GPU texture and\n * not modifiable after creation).\n *\n * @param info\n * @param data - bytes representing the pixel data.\n * @param bytesPerRow\n */\n MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number): SkImage | null;\n}\n"],"mappings":";;;;;;IAIYA,S;;;WAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S;;IAOAC,S;;;WAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S"}
|
1
|
+
{"version":3,"names":["AlphaType","ColorType"],"sources":["ImageFactory.ts"],"sourcesContent":["import type { SkData } from \"../Data\";\n\nimport type { SkImage } from \"./Image\";\n\nexport enum AlphaType {\n Unknown,\n Opaque,\n Premul,\n Unpremul,\n}\n\nexport enum ColorType {\n Unknown, //!< uninitialized\n Alpha_8, //!< pixel with alpha in 8-bit byte\n RGB_565, //!< pixel with 5 bits red, 6 bits green, 5 bits blue, in 16-bit word\n ARGB_4444, //!< pixel with 4 bits for alpha, red, green, blue; in 16-bit word\n RGBA_8888, //!< pixel with 8 bits for red, green, blue, alpha; in 32-bit word\n RGB_888x, //!< pixel with 8 bits each for red, green, blue; in 32-bit word\n BGRA_8888, //!< pixel with 8 bits for blue, green, red, alpha; in 32-bit word\n RGBA_1010102, //!< 10 bits for red, green, blue; 2 bits for alpha; in 32-bit word\n BGRA_1010102, //!< 10 bits for blue, green, red; 2 bits for alpha; in 32-bit word\n RGB_101010x, //!< pixel with 10 bits each for red, green, blue; in 32-bit word\n BGR_101010x, //!< pixel with 10 bits each for blue, green, red; in 32-bit word\n Gray_8, //!< pixel with grayscale level in 8-bit byte\n RGBA_F16Norm, //!< pixel with half floats in [0,1] for red, green, blue, alpha;\n // in 64-bit word\n RGBA_F16, //!< pixel with half floats for red, green, blue, alpha;\n // in 64-bit word\n RGBA_F32, //!< pixel using C float for red, green, blue, alpha; in 128-bit word\n\n // The following 6 colortypes are just for reading from - not for rendering to\n R8G8_unorm, //!< pixel with a uint8_t for red and green\n\n A16_float, //!< pixel with a half float for alpha\n R16G16_float, //!< pixel with a half float for red and green\n\n A16_unorm, //!< pixel with a little endian uint16_t for alpha\n R16G16_unorm, //!< pixel with a little endian uint16_t for red and green\n R16G16B16A16_unorm, //!< pixel with a little endian uint16_t for red, green, blue\n // and alpha\n SRGBA_8888,\n}\n\nexport interface ImageInfo {\n alphaType: AlphaType;\n // TODO: add support for color space\n // colorSpace: ColorSpace;\n colorType: ColorType;\n height: number;\n width: number;\n}\n\nexport interface ImageFactory {\n /**\n * Return an Image backed by the encoded data, but attempt to defer decoding until the image\n * is actually used/drawn. This deferral allows the system to cache the result, either on the\n * CPU or on the GPU, depending on where the image is drawn.\n * This decoding uses the codecs that have been compiled into CanvasKit. If the bytes are\n * invalid (or an unrecognized codec), null will be returned. See Image.h for more details.\n * @param data - Data object with bytes of data\n * @returns If the encoded format is not supported, or subset is outside of the bounds of the decoded\n * image, nullptr is returned.\n */\n MakeImageFromEncoded: (encoded: SkData) => SkImage | null;\n\n /**\n * Returns an image that will be a screenshot of the view represented by\n * the view tag\n * @param viewTag - The tag of the view to make an image from.\n * @returns Returns a valid SkImage, if the view tag is invalid, nullptr is returned.\n */\n MakeImageFromViewTag: (viewTag: number) => Promise<SkImage | null>;\n\n /**\n * Returns an image with the given pixel data and format.\n * Note that we will always make a copy of the pixel data, because of inconsistencies in\n * behavior between GPU and CPU (i.e. the pixel data will be turned into a GPU texture and\n * not modifiable after creation).\n *\n * @param info\n * @param data - bytes representing the pixel data.\n * @param bytesPerRow\n */\n MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number): SkImage | null;\n}\n"],"mappings":";;;;;;IAIYA,S;;;WAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S;;IAOAC,S;;;WAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;EAAAA,S,CAAAA,S;GAAAA,S,yBAAAA,S"}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":[],"sources":["SVG.ts"],"sourcesContent":["import type { JsiDisposable, SkJSIInstance } from \"../JsiInstance\";\n\nexport
|
1
|
+
{"version":3,"names":[],"sources":["SVG.ts"],"sourcesContent":["import type { JsiDisposable, SkJSIInstance } from \"../JsiInstance\";\n\nexport interface SkSVG extends SkJSIInstance<\"SVG\">, JsiDisposable {\n width(): number;\n height(): number;\n}\n"],"mappings":""}
|
@@ -11,4 +11,5 @@ export declare class JsiSkImage extends HostObject<Image, "Image"> implements Sk
|
|
11
11
|
encodeToBytes(fmt?: ImageFormat, quality?: number): Uint8Array;
|
12
12
|
encodeToBase64(fmt?: ImageFormat, quality?: number): string;
|
13
13
|
dispose(): void;
|
14
|
+
makeNonTextureImage(): SkImage;
|
14
15
|
}
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["toBase64String","bytes","Buffer","from","toString","CHUNK_SIZE","index","length","result","slice","Math","min","String","fromCharCode","apply","btoa","JsiSkImage","HostObject","constructor","CanvasKit","ref","height","width","makeShaderOptions","tx","ty","fm","mm","localMatrix","JsiSkShader","ckEnum","JsiSkMatrix","fromValue","undefined","makeShaderCubic","B","C","encodeToBytes","fmt","quality","Error","encodeToBase64","dispose","delete"],"sources":["JsiSkImage.ts"],"sourcesContent":["import type { CanvasKit, Image } from \"canvaskit-wasm\";\n\nimport type {\n ImageFormat,\n FilterMode,\n MipmapMode,\n SkImage,\n SkMatrix,\n SkShader,\n TileMode,\n} from \"../types\";\n\nimport { ckEnum, HostObject } from \"./Host\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkShader } from \"./JsiSkShader\";\n\n// https://github.com/google/skia/blob/1f193df9b393d50da39570dab77a0bb5d28ec8ef/modules/canvaskit/htmlcanvas/util.js\nexport const toBase64String = (bytes: Uint8Array) => {\n if (typeof Buffer !== \"undefined\") {\n // Are we on node?\n return Buffer.from(bytes).toString(\"base64\");\n } else {\n // From https://stackoverflow.com/a/25644409\n // because the naive solution of\n // btoa(String.fromCharCode.apply(null, bytes));\n // would occasionally throw \"Maximum call stack size exceeded\"\n var CHUNK_SIZE = 0x8000; //arbitrary number\n var index = 0;\n var { length } = bytes;\n var result = \"\";\n var slice;\n while (index < length) {\n slice = bytes.slice(index, Math.min(index + CHUNK_SIZE, length));\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result += String.fromCharCode.apply(null, slice as any);\n index += CHUNK_SIZE;\n }\n return btoa(result);\n }\n};\n\nexport class JsiSkImage extends HostObject<Image, \"Image\"> implements SkImage {\n constructor(CanvasKit: CanvasKit, ref: Image) {\n super(CanvasKit, ref, \"Image\");\n }\n\n height() {\n return this.ref.height();\n }\n\n width() {\n return this.ref.width();\n }\n\n makeShaderOptions(\n tx: TileMode,\n ty: TileMode,\n fm: FilterMode,\n mm: MipmapMode,\n localMatrix?: SkMatrix\n ): SkShader {\n return new JsiSkShader(\n this.CanvasKit,\n this.ref.makeShaderOptions(\n ckEnum(tx),\n ckEnum(ty),\n ckEnum(fm),\n ckEnum(mm),\n localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined\n )\n );\n }\n\n makeShaderCubic(\n tx: TileMode,\n ty: TileMode,\n B: number,\n C: number,\n localMatrix?: SkMatrix\n ): SkShader {\n return new JsiSkShader(\n this.CanvasKit,\n this.ref.makeShaderCubic(\n ckEnum(tx),\n ckEnum(ty),\n B,\n C,\n localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined\n )\n );\n }\n\n encodeToBytes(fmt?: ImageFormat, quality?: number) {\n let result: Uint8Array | null;\n if (fmt && quality) {\n result = this.ref.encodeToBytes(ckEnum(fmt), quality);\n } else if (fmt) {\n result = this.ref.encodeToBytes(ckEnum(fmt));\n } else {\n result = this.ref.encodeToBytes();\n }\n if (!result) {\n throw new Error(\"encodeToBytes failed\");\n }\n return result;\n }\n\n encodeToBase64(fmt?: ImageFormat, quality?: number) {\n const bytes = this.encodeToBytes(fmt, quality);\n return toBase64String(bytes);\n }\n\n dispose() {\n this.ref.delete();\n }\n}\n"],"mappings":";;;;;;;AAYA;;AACA;;AACA;;AAEA;AACO,MAAMA,cAAc,GAAIC,KAAD,IAAuB;EACnD,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;IACjC;IACA,OAAOA,MAAM,CAACC,IAAP,CAAYF,KAAZ,EAAmBG,QAAnB,CAA4B,QAA5B,CAAP;EACD,CAHD,MAGO;IACL;IACA;IACA;IACA;IACA,IAAIC,UAAU,GAAG,MAAjB,CALK,CAKoB;;IACzB,IAAIC,KAAK,GAAG,CAAZ;IACA,IAAI;MAAEC;IAAF,IAAaN,KAAjB;IACA,IAAIO,MAAM,GAAG,EAAb;IACA,IAAIC,KAAJ;;IACA,OAAOH,KAAK,GAAGC,MAAf,EAAuB;MACrBE,KAAK,GAAGR,KAAK,CAACQ,KAAN,CAAYH,KAAZ,EAAmBI,IAAI,CAACC,GAAL,CAASL,KAAK,GAAGD,UAAjB,EAA6BE,MAA7B,CAAnB,CAAR,CADqB,CAErB;;MACAC,MAAM,IAAII,MAAM,CAACC,YAAP,CAAoBC,KAApB,CAA0B,IAA1B,EAAgCL,KAAhC,CAAV;MACAH,KAAK,IAAID,UAAT;IACD;;IACD,OAAOU,IAAI,CAACP,MAAD,CAAX;EACD;AACF,CAtBM;;;;AAwBA,MAAMQ,UAAN,SAAyBC,gBAAzB,CAAuE;EAC5EC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,IAAID,GAAJ,EAAS;MACd9B,MAAM,GAAG,KAAKY,GAAL,CAASiB,aAAT,CAAuB,IAAAP,YAAA,EAAOQ,GAAP,CAAvB,CAAT;IACD,CAFM,MAEA;MACL9B,MAAM,GAAG,KAAKY,GAAL,CAASiB,aAAT,EAAT;IACD;;IACD,IAAI,CAAC7B,MAAL,EAAa;MACX,MAAM,IAAIgC,KAAJ,CAAU,sBAAV,CAAN;IACD;;IACD,OAAOhC,MAAP;EACD;;EAEDiC,cAAc,CAACH,GAAD,EAAoBC,OAApB,EAAsC;IAClD,MAAMtC,KAAK,GAAG,KAAKoC,aAAL,CAAmBC,GAAnB,EAAwBC,OAAxB,CAAd;IACA,OAAOvC,cAAc,CAACC,KAAD,CAArB;EACD;;EAEDyC,OAAO,GAAG;IACR,KAAKtB,GAAL,CAASuB,MAAT;EACD;;
|
1
|
+
{"version":3,"names":["toBase64String","bytes","Buffer","from","toString","CHUNK_SIZE","index","length","result","slice","Math","min","String","fromCharCode","apply","btoa","JsiSkImage","HostObject","constructor","CanvasKit","ref","height","width","makeShaderOptions","tx","ty","fm","mm","localMatrix","JsiSkShader","ckEnum","JsiSkMatrix","fromValue","undefined","makeShaderCubic","B","C","encodeToBytes","fmt","quality","Error","encodeToBase64","dispose","delete","makeNonTextureImage","MakeImageFromEncoded"],"sources":["JsiSkImage.ts"],"sourcesContent":["import type { CanvasKit, Image } from \"canvaskit-wasm\";\n\nimport type {\n ImageFormat,\n FilterMode,\n MipmapMode,\n SkImage,\n SkMatrix,\n SkShader,\n TileMode,\n} from \"../types\";\n\nimport { ckEnum, HostObject } from \"./Host\";\nimport { JsiSkMatrix } from \"./JsiSkMatrix\";\nimport { JsiSkShader } from \"./JsiSkShader\";\n\n// https://github.com/google/skia/blob/1f193df9b393d50da39570dab77a0bb5d28ec8ef/modules/canvaskit/htmlcanvas/util.js\nexport const toBase64String = (bytes: Uint8Array) => {\n if (typeof Buffer !== \"undefined\") {\n // Are we on node?\n return Buffer.from(bytes).toString(\"base64\");\n } else {\n // From https://stackoverflow.com/a/25644409\n // because the naive solution of\n // btoa(String.fromCharCode.apply(null, bytes));\n // would occasionally throw \"Maximum call stack size exceeded\"\n var CHUNK_SIZE = 0x8000; //arbitrary number\n var index = 0;\n var { length } = bytes;\n var result = \"\";\n var slice;\n while (index < length) {\n slice = bytes.slice(index, Math.min(index + CHUNK_SIZE, length));\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n result += String.fromCharCode.apply(null, slice as any);\n index += CHUNK_SIZE;\n }\n return btoa(result);\n }\n};\n\nexport class JsiSkImage extends HostObject<Image, \"Image\"> implements SkImage {\n constructor(CanvasKit: CanvasKit, ref: Image) {\n super(CanvasKit, ref, \"Image\");\n }\n\n height() {\n return this.ref.height();\n }\n\n width() {\n return this.ref.width();\n }\n\n makeShaderOptions(\n tx: TileMode,\n ty: TileMode,\n fm: FilterMode,\n mm: MipmapMode,\n localMatrix?: SkMatrix\n ): SkShader {\n return new JsiSkShader(\n this.CanvasKit,\n this.ref.makeShaderOptions(\n ckEnum(tx),\n ckEnum(ty),\n ckEnum(fm),\n ckEnum(mm),\n localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined\n )\n );\n }\n\n makeShaderCubic(\n tx: TileMode,\n ty: TileMode,\n B: number,\n C: number,\n localMatrix?: SkMatrix\n ): SkShader {\n return new JsiSkShader(\n this.CanvasKit,\n this.ref.makeShaderCubic(\n ckEnum(tx),\n ckEnum(ty),\n B,\n C,\n localMatrix ? JsiSkMatrix.fromValue(localMatrix) : undefined\n )\n );\n }\n\n encodeToBytes(fmt?: ImageFormat, quality?: number) {\n let result: Uint8Array | null;\n if (fmt && quality) {\n result = this.ref.encodeToBytes(ckEnum(fmt), quality);\n } else if (fmt) {\n result = this.ref.encodeToBytes(ckEnum(fmt));\n } else {\n result = this.ref.encodeToBytes();\n }\n if (!result) {\n throw new Error(\"encodeToBytes failed\");\n }\n return result;\n }\n\n encodeToBase64(fmt?: ImageFormat, quality?: number) {\n const bytes = this.encodeToBytes(fmt, quality);\n return toBase64String(bytes);\n }\n\n dispose() {\n this.ref.delete();\n }\n\n makeNonTextureImage(): SkImage {\n return new JsiSkImage(\n this.CanvasKit,\n this.CanvasKit.MakeImageFromEncoded(this.encodeToBytes())!\n );\n }\n}\n"],"mappings":";;;;;;;AAYA;;AACA;;AACA;;AAEA;AACO,MAAMA,cAAc,GAAIC,KAAD,IAAuB;EACnD,IAAI,OAAOC,MAAP,KAAkB,WAAtB,EAAmC;IACjC;IACA,OAAOA,MAAM,CAACC,IAAP,CAAYF,KAAZ,EAAmBG,QAAnB,CAA4B,QAA5B,CAAP;EACD,CAHD,MAGO;IACL;IACA;IACA;IACA;IACA,IAAIC,UAAU,GAAG,MAAjB,CALK,CAKoB;;IACzB,IAAIC,KAAK,GAAG,CAAZ;IACA,IAAI;MAAEC;IAAF,IAAaN,KAAjB;IACA,IAAIO,MAAM,GAAG,EAAb;IACA,IAAIC,KAAJ;;IACA,OAAOH,KAAK,GAAGC,MAAf,EAAuB;MACrBE,KAAK,GAAGR,KAAK,CAACQ,KAAN,CAAYH,KAAZ,EAAmBI,IAAI,CAACC,GAAL,CAASL,KAAK,GAAGD,UAAjB,EAA6BE,MAA7B,CAAnB,CAAR,CADqB,CAErB;;MACAC,MAAM,IAAII,MAAM,CAACC,YAAP,CAAoBC,KAApB,CAA0B,IAA1B,EAAgCL,KAAhC,CAAV;MACAH,KAAK,IAAID,UAAT;IACD;;IACD,OAAOU,IAAI,CAACP,MAAD,CAAX;EACD;AACF,CAtBM;;;;AAwBA,MAAMQ,UAAN,SAAyBC,gBAAzB,CAAuE;EAC5EC,WAAW,CAACC,SAAD,EAAuBC,GAAvB,EAAmC;IAC5C,MAAMD,SAAN,EAAiBC,GAAjB,EAAsB,OAAtB;EACD;;EAEDC,MAAM,GAAG;IACP,OAAO,KAAKD,GAAL,CAASC,MAAT,EAAP;EACD;;EAEDC,KAAK,GAAG;IACN,OAAO,KAAKF,GAAL,CAASE,KAAT,EAAP;E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M,IAAIgC,KAAJ,CAAU,sBAAV,CAAN;IACD;;IACD,OAAOhC,MAAP;EACD;;EAEDiC,cAAc,CAACH,GAAD,EAAoBC,OAApB,EAAsC;IAClD,MAAMtC,KAAK,GAAG,KAAKoC,aAAL,CAAmBC,GAAnB,EAAwBC,OAAxB,CAAd;IACA,OAAOvC,cAAc,CAACC,KAAD,CAArB;EACD;;EAEDyC,OAAO,GAAG;IACR,KAAKtB,GAAL,CAASuB,MAAT;EACD;;EAEDC,mBAAmB,GAAY;IAC7B,OAAO,IAAI5B,UAAJ,CACL,KAAKG,SADA,EAEL,KAAKA,SAAL,CAAe0B,oBAAf,CAAoC,KAAKR,aAAL,EAApC,CAFK,CAAP;EAID;;AAhF2E"}
|
@@ -1,10 +1,11 @@
|
|
1
1
|
import type { CanvasKit } from "canvaskit-wasm";
|
2
|
-
import type { SkData, ImageInfo } from "../types";
|
2
|
+
import type { SkData, ImageInfo, SkImage } from "../types";
|
3
3
|
import type { ImageFactory } from "../types/Image/ImageFactory";
|
4
4
|
import { Host } from "./Host";
|
5
5
|
import { JsiSkImage } from "./JsiSkImage";
|
6
6
|
export declare class JsiSkImageFactory extends Host implements ImageFactory {
|
7
7
|
constructor(CanvasKit: CanvasKit);
|
8
|
+
MakeImageFromViewTag(viewTag: number): Promise<SkImage | null>;
|
8
9
|
MakeImageFromEncoded(encoded: SkData): JsiSkImage | null;
|
9
10
|
MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number): JsiSkImage | null;
|
10
11
|
}
|
@@ -16,6 +16,13 @@ class JsiSkImageFactory extends _Host.Host {
|
|
16
16
|
super(CanvasKit);
|
17
17
|
}
|
18
18
|
|
19
|
+
MakeImageFromViewTag(viewTag) {
|
20
|
+
const view = viewTag; // TODO: Implement screenshot from view in React JS
|
21
|
+
|
22
|
+
console.log(view);
|
23
|
+
return Promise.resolve(null);
|
24
|
+
}
|
25
|
+
|
19
26
|
MakeImageFromEncoded(encoded) {
|
20
27
|
const image = this.CanvasKit.MakeImageFromEncoded(_JsiSkData.JsiSkData.fromValue(encoded));
|
21
28
|
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"names":["JsiSkImageFactory","Host","constructor","CanvasKit","MakeImageFromEncoded","encoded","image","JsiSkData","fromValue","JsiSkImage","MakeImage","info","data","bytesPerRow","alphaType","ckEnum","colorSpace","ColorSpace","SRGB","colorType","height","width"],"sources":["JsiSkImageFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkData, ImageInfo } from \"../types\";\nimport type { ImageFactory } from \"../types/Image/ImageFactory\";\n\nimport { Host, ckEnum } from \"./Host\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkData } from \"./JsiSkData\";\n\nexport class JsiSkImageFactory extends Host implements ImageFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeImageFromEncoded(encoded: SkData) {\n const image = this.CanvasKit.MakeImageFromEncoded(\n JsiSkData.fromValue(encoded)\n );\n if (image === null) {\n return null;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n\n MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number) {\n // see toSkImageInfo() from canvaskit\n const image = this.CanvasKit.MakeImage(\n {\n alphaType: ckEnum(info.alphaType),\n colorSpace: this.CanvasKit.ColorSpace.SRGB,\n colorType: ckEnum(info.colorType),\n height: info.height,\n width: info.width,\n },\n JsiSkData.fromValue(data),\n bytesPerRow\n );\n if (image === null) {\n return null;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n}\n"],"mappings":";;;;;;;AAKA;;AACA;;AACA;;AAEO,MAAMA,iBAAN,SAAgCC,UAAhC,CAA6D;EAClEC,WAAW,CAACC,SAAD,EAAuB;IAChC,MAAMA,SAAN;EACD;;EAEDC,oBAAoB,CAACC,OAAD,EAAkB;IACpC,MAAMC,KAAK,GAAG,
|
1
|
+
{"version":3,"names":["JsiSkImageFactory","Host","constructor","CanvasKit","MakeImageFromViewTag","viewTag","view","console","log","Promise","resolve","MakeImageFromEncoded","encoded","image","JsiSkData","fromValue","JsiSkImage","MakeImage","info","data","bytesPerRow","alphaType","ckEnum","colorSpace","ColorSpace","SRGB","colorType","height","width"],"sources":["JsiSkImageFactory.ts"],"sourcesContent":["import type { CanvasKit } from \"canvaskit-wasm\";\n\nimport type { SkData, ImageInfo, SkImage } from \"../types\";\nimport type { ImageFactory } from \"../types/Image/ImageFactory\";\n\nimport { Host, ckEnum } from \"./Host\";\nimport { JsiSkImage } from \"./JsiSkImage\";\nimport { JsiSkData } from \"./JsiSkData\";\n\nexport class JsiSkImageFactory extends Host implements ImageFactory {\n constructor(CanvasKit: CanvasKit) {\n super(CanvasKit);\n }\n\n MakeImageFromViewTag(viewTag: number): Promise<SkImage | null> {\n const view = viewTag as unknown as HTMLElement;\n // TODO: Implement screenshot from view in React JS\n console.log(view);\n return Promise.resolve(null);\n }\n\n MakeImageFromEncoded(encoded: SkData) {\n const image = this.CanvasKit.MakeImageFromEncoded(\n JsiSkData.fromValue(encoded)\n );\n if (image === null) {\n return null;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n\n MakeImage(info: ImageInfo, data: SkData, bytesPerRow: number) {\n // see toSkImageInfo() from canvaskit\n const image = this.CanvasKit.MakeImage(\n {\n alphaType: ckEnum(info.alphaType),\n colorSpace: this.CanvasKit.ColorSpace.SRGB,\n colorType: ckEnum(info.colorType),\n height: info.height,\n width: info.width,\n },\n JsiSkData.fromValue(data),\n bytesPerRow\n );\n if (image === null) {\n return null;\n }\n return new JsiSkImage(this.CanvasKit, image);\n }\n}\n"],"mappings":";;;;;;;AAKA;;AACA;;AACA;;AAEO,MAAMA,iBAAN,SAAgCC,UAAhC,CAA6D;EAClEC,WAAW,CAACC,SAAD,EAAuB;IAChC,MAAMA,SAAN;EACD;;EAEDC,oBAAoB,CAACC,OAAD,EAA2C;IAC7D,MAAMC,IAAI,GAAGD,OAAb,CAD6D,CAE7D;;IACAE,OAAO,CAACC,GAAR,CAAYF,IAAZ;IACA,OAAOG,OAAO,CAACC,OAAR,CAAgB,IAAhB,CAAP;EACD;;EAEDC,oBAAoB,CAACC,OAAD,EAAkB;IACpC,MAAMC,KAAK,GAAG,KAAKV,SAAL,CAAeQ,oBAAf,CACZG,oBAAA,CAAUC,SAAV,CAAoBH,OAApB,CADY,CAAd;;IAGA,IAAIC,KAAK,KAAK,IAAd,EAAoB;MAClB,OAAO,IAAP;IACD;;IACD,OAAO,IAAIG,sBAAJ,CAAe,KAAKb,SAApB,EAA+BU,KAA/B,CAAP;EACD;;EAEDI,SAAS,CAACC,IAAD,EAAkBC,IAAlB,EAAgCC,WAAhC,EAAqD;IAC5D;IACA,MAAMP,KAAK,GAAG,KAAKV,SAAL,CAAec,SAAf,CACZ;MACEI,SAAS,EAAE,IAAAC,YAAA,EAAOJ,IAAI,CAACG,SAAZ,CADb;MAEEE,UAAU,EAAE,KAAKpB,SAAL,CAAeqB,UAAf,CAA0BC,IAFxC;MAGEC,SAAS,EAAE,IAAAJ,YAAA,EAAOJ,IAAI,CAACQ,SAAZ,CAHb;MAIEC,MAAM,EAAET,IAAI,CAACS,MAJf;MAKEC,KAAK,EAAEV,IAAI,CAACU;IALd,CADY,EAQZd,oBAAA,CAAUC,SAAV,CAAoBI,IAApB,CARY,EASZC,WATY,CAAd;;IAWA,IAAIP,KAAK,KAAK,IAAd,EAAoB;MAClB,OAAO,IAAP;IACD;;IACD,OAAO,IAAIG,sBAAJ,CAAe,KAAKb,SAApB,EAA+BU,KAA/B,CAAP;EACD;;AAvCiE"}
|
@@ -12,6 +12,24 @@ export class ImageNode extends JsiDrawingNode {
|
|
12
12
|
const {
|
13
13
|
image
|
14
14
|
} = this.props;
|
15
|
+
|
16
|
+
if (!image) {
|
17
|
+
return {
|
18
|
+
src: {
|
19
|
+
x: 0,
|
20
|
+
y: 0,
|
21
|
+
width: 0,
|
22
|
+
height: 0
|
23
|
+
},
|
24
|
+
dst: {
|
25
|
+
x: 0,
|
26
|
+
y: 0,
|
27
|
+
width: 0,
|
28
|
+
height: 0
|
29
|
+
}
|
30
|
+
};
|
31
|
+
}
|
32
|
+
|
15
33
|
const fit = (_this$props$fit = this.props.fit) !== null && _this$props$fit !== void 0 ? _this$props$fit : "contain";
|
16
34
|
const rect = processRect(this.Skia, this.props);
|
17
35
|
const {
|
@@ -46,7 +64,10 @@ export class ImageNode extends JsiDrawingNode {
|
|
46
64
|
src,
|
47
65
|
dst
|
48
66
|
} = this.derived;
|
49
|
-
|
67
|
+
|
68
|
+
if (image) {
|
69
|
+
canvas.drawImageRect(image, src, dst, paint);
|
70
|
+
}
|
50
71
|
}
|
51
72
|
|
52
73
|
}
|