@shopify/react-native-skia 2.0.3 → 2.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/cpp/api/recorder/DrawingCtx.h +3 -3
  2. package/cpp/api/recorder/JsiRecorder.h +2 -1
  3. package/cpp/api/recorder/Paint.h +8 -3
  4. package/cpp/api/recorder/RNRecorder.h +4 -3
  5. package/cpp/rnskia/RNSkJsiViewApi.h +53 -51
  6. package/lib/commonjs/skia/types/Recorder.d.ts +1 -1
  7. package/lib/commonjs/skia/types/Recorder.js.map +1 -1
  8. package/lib/commonjs/sksg/Recorder/Player.js +3 -1
  9. package/lib/commonjs/sksg/Recorder/Player.js.map +1 -1
  10. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
  11. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js +2 -2
  12. package/lib/commonjs/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
  13. package/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -1
  14. package/lib/commonjs/sksg/Recorder/Recorder.js +3 -2
  15. package/lib/commonjs/sksg/Recorder/Recorder.js.map +1 -1
  16. package/lib/commonjs/sksg/Recorder/Visitor.js +2 -2
  17. package/lib/commonjs/sksg/Recorder/Visitor.js.map +1 -1
  18. package/lib/commonjs/sksg/Recorder/commands/Paint.d.ts +1 -1
  19. package/lib/commonjs/sksg/Recorder/commands/Paint.js +6 -2
  20. package/lib/commonjs/sksg/Recorder/commands/Paint.js.map +1 -1
  21. package/lib/module/skia/types/Recorder.d.ts +1 -1
  22. package/lib/module/skia/types/Recorder.js.map +1 -1
  23. package/lib/module/sksg/Recorder/Player.js +3 -1
  24. package/lib/module/sksg/Recorder/Player.js.map +1 -1
  25. package/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
  26. package/lib/module/sksg/Recorder/ReanimatedRecorder.js +2 -2
  27. package/lib/module/sksg/Recorder/ReanimatedRecorder.js.map +1 -1
  28. package/lib/module/sksg/Recorder/Recorder.d.ts +1 -1
  29. package/lib/module/sksg/Recorder/Recorder.js +3 -2
  30. package/lib/module/sksg/Recorder/Recorder.js.map +1 -1
  31. package/lib/module/sksg/Recorder/Visitor.js +2 -2
  32. package/lib/module/sksg/Recorder/Visitor.js.map +1 -1
  33. package/lib/module/sksg/Recorder/commands/Paint.d.ts +1 -1
  34. package/lib/module/sksg/Recorder/commands/Paint.js +6 -2
  35. package/lib/module/sksg/Recorder/commands/Paint.js.map +1 -1
  36. package/lib/typescript/lib/commonjs/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
  37. package/lib/typescript/lib/commonjs/sksg/Recorder/Recorder.d.ts +1 -1
  38. package/lib/typescript/lib/commonjs/sksg/Recorder/commands/Paint.d.ts +1 -1
  39. package/lib/typescript/lib/module/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
  40. package/lib/typescript/lib/module/sksg/Recorder/Recorder.d.ts +1 -1
  41. package/lib/typescript/lib/module/sksg/Recorder/commands/Paint.d.ts +1 -1
  42. package/lib/typescript/src/skia/types/Recorder.d.ts +1 -1
  43. package/lib/typescript/src/sksg/Recorder/ReanimatedRecorder.d.ts +1 -1
  44. package/lib/typescript/src/sksg/Recorder/Recorder.d.ts +1 -1
  45. package/lib/typescript/src/sksg/Recorder/commands/Paint.d.ts +1 -1
  46. package/package.json +1 -1
  47. package/src/__tests__/snapshots/drawings/semi-transparent-layer.png +0 -0
  48. package/src/__tests__/snapshots/drawings/transparent-layer.png +0 -0
  49. package/src/renderer/__tests__/e2e/Opacity.spec.tsx +23 -0
  50. package/src/skia/types/Recorder.ts +1 -1
  51. package/src/sksg/Recorder/Player.ts +7 -1
  52. package/src/sksg/Recorder/ReanimatedRecorder.ts +2 -2
  53. package/src/sksg/Recorder/Recorder.ts +2 -2
  54. package/src/sksg/Recorder/Visitor.ts +2 -2
  55. package/src/sksg/Recorder/commands/Paint.ts +7 -2
@@ -11,14 +11,18 @@ export const setPaintProperties = (Skia, ctx, {
11
11
  strokeMiter,
12
12
  antiAlias,
13
13
  dither
14
- }) => {
14
+ }, standalone) => {
15
15
  "worklet";
16
16
 
17
17
  const {
18
18
  paint
19
19
  } = ctx;
20
20
  if (opacity !== undefined) {
21
- ctx.setOpacity(ctx.getOpacity() * opacity);
21
+ if (standalone) {
22
+ paint.setAlphaf(paint.getAlphaf() * opacity);
23
+ } else {
24
+ ctx.setOpacity(ctx.getOpacity() * opacity);
25
+ }
22
26
  }
23
27
  if (color !== undefined) {
24
28
  paint.setShader(null);
@@ -1 +1 @@
1
- {"version":3,"names":["enumKey","processColor","BlendMode","PaintStyle","StrokeCap","StrokeJoin","setPaintProperties","Skia","ctx","opacity","color","blendMode","strokeWidth","style","strokeJoin","strokeCap","strokeMiter","antiAlias","dither","paint","undefined","setOpacity","getOpacity","setShader","setColor","setBlendMode","setStrokeWidth","setStyle","setStrokeJoin","setStrokeCap","setStrokeMiter","setAntiAlias","setDither"],"sources":["Paint.ts"],"sourcesContent":["import { enumKey, processColor } from \"../../../dom/nodes\";\nimport type { PaintProps } from \"../../../dom/types\";\nimport {\n BlendMode,\n PaintStyle,\n StrokeCap,\n StrokeJoin,\n} from \"../../../skia/types\";\nimport type { Skia } from \"../../../skia/types\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\nexport const setPaintProperties = (\n Skia: Skia,\n ctx: DrawingContext,\n {\n opacity,\n color,\n blendMode,\n strokeWidth,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n antiAlias,\n dither,\n }: PaintProps\n) => {\n \"worklet\";\n const { paint } = ctx;\n\n if (opacity !== undefined) {\n ctx.setOpacity(ctx.getOpacity() * opacity);\n }\n if (color !== undefined) {\n paint.setShader(null);\n paint.setColor(processColor(Skia, color));\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(BlendMode[enumKey(blendMode)]);\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (style !== undefined) {\n paint.setStyle(PaintStyle[enumKey(style)]);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(StrokeJoin[enumKey(strokeJoin)]);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(StrokeCap[enumKey(strokeCap)]);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n if (dither !== undefined) {\n paint.setDither(dither);\n }\n};\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,YAAY,QAAQ,oBAAoB;AAE1D,SACEC,SAAS,EACTC,UAAU,EACVC,SAAS,EACTC,UAAU,QACL,qBAAqB;AAI5B,OAAO,MAAMC,kBAAkB,GAAGA,CAChCC,IAAU,EACVC,GAAmB,EACnB;EACEC,OAAO;EACPC,KAAK;EACLC,SAAS;EACTC,WAAW;EACXC,KAAK;EACLC,UAAU;EACVC,SAAS;EACTC,WAAW;EACXC,SAAS;EACTC;AACU,CAAC,KACV;EACH,SAAS;;EACT,MAAM;IAAEC;EAAM,CAAC,GAAGX,GAAG;EAErB,IAAIC,OAAO,KAAKW,SAAS,EAAE;IACzBZ,GAAG,CAACa,UAAU,CAACb,GAAG,CAACc,UAAU,CAAC,CAAC,GAAGb,OAAO,CAAC;EAC5C;EACA,IAAIC,KAAK,KAAKU,SAAS,EAAE;IACvBD,KAAK,CAACI,SAAS,CAAC,IAAI,CAAC;IACrBJ,KAAK,CAACK,QAAQ,CAACvB,YAAY,CAACM,IAAI,EAAEG,KAAK,CAAC,CAAC;EAC3C;EACA,IAAIC,SAAS,KAAKS,SAAS,EAAE;IAC3BD,KAAK,CAACM,YAAY,CAACvB,SAAS,CAACF,OAAO,CAACW,SAAS,CAAC,CAAC,CAAC;EACnD;EACA,IAAIC,WAAW,KAAKQ,SAAS,EAAE;IAC7BD,KAAK,CAACO,cAAc,CAACd,WAAW,CAAC;EACnC;EACA,IAAIC,KAAK,KAAKO,SAAS,EAAE;IACvBD,KAAK,CAACQ,QAAQ,CAACxB,UAAU,CAACH,OAAO,CAACa,KAAK,CAAC,CAAC,CAAC;EAC5C;EACA,IAAIC,UAAU,KAAKM,SAAS,EAAE;IAC5BD,KAAK,CAACS,aAAa,CAACvB,UAAU,CAACL,OAAO,CAACc,UAAU,CAAC,CAAC,CAAC;EACtD;EACA,IAAIC,SAAS,KAAKK,SAAS,EAAE;IAC3BD,KAAK,CAACU,YAAY,CAACzB,SAAS,CAACJ,OAAO,CAACe,SAAS,CAAC,CAAC,CAAC;EACnD;EACA,IAAIC,WAAW,KAAKI,SAAS,EAAE;IAC7BD,KAAK,CAACW,cAAc,CAACd,WAAW,CAAC;EACnC;EACA,IAAIC,SAAS,KAAKG,SAAS,EAAE;IAC3BD,KAAK,CAACY,YAAY,CAACd,SAAS,CAAC;EAC/B;EACA,IAAIC,MAAM,KAAKE,SAAS,EAAE;IACxBD,KAAK,CAACa,SAAS,CAACd,MAAM,CAAC;EACzB;AACF,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["enumKey","processColor","BlendMode","PaintStyle","StrokeCap","StrokeJoin","setPaintProperties","Skia","ctx","opacity","color","blendMode","strokeWidth","style","strokeJoin","strokeCap","strokeMiter","antiAlias","dither","standalone","paint","undefined","setAlphaf","getAlphaf","setOpacity","getOpacity","setShader","setColor","setBlendMode","setStrokeWidth","setStyle","setStrokeJoin","setStrokeCap","setStrokeMiter","setAntiAlias","setDither"],"sources":["Paint.ts"],"sourcesContent":["import { enumKey, processColor } from \"../../../dom/nodes\";\nimport type { PaintProps } from \"../../../dom/types\";\nimport {\n BlendMode,\n PaintStyle,\n StrokeCap,\n StrokeJoin,\n} from \"../../../skia/types\";\nimport type { Skia } from \"../../../skia/types\";\nimport type { DrawingContext } from \"../DrawingContext\";\n\nexport const setPaintProperties = (\n Skia: Skia,\n ctx: DrawingContext,\n {\n opacity,\n color,\n blendMode,\n strokeWidth,\n style,\n strokeJoin,\n strokeCap,\n strokeMiter,\n antiAlias,\n dither,\n }: PaintProps,\n standalone: boolean\n) => {\n \"worklet\";\n const { paint } = ctx;\n\n if (opacity !== undefined) {\n if (standalone) {\n paint.setAlphaf(paint.getAlphaf() * opacity);\n } else {\n ctx.setOpacity(ctx.getOpacity() * opacity);\n }\n }\n if (color !== undefined) {\n paint.setShader(null);\n paint.setColor(processColor(Skia, color));\n }\n if (blendMode !== undefined) {\n paint.setBlendMode(BlendMode[enumKey(blendMode)]);\n }\n if (strokeWidth !== undefined) {\n paint.setStrokeWidth(strokeWidth);\n }\n if (style !== undefined) {\n paint.setStyle(PaintStyle[enumKey(style)]);\n }\n if (strokeJoin !== undefined) {\n paint.setStrokeJoin(StrokeJoin[enumKey(strokeJoin)]);\n }\n if (strokeCap !== undefined) {\n paint.setStrokeCap(StrokeCap[enumKey(strokeCap)]);\n }\n if (strokeMiter !== undefined) {\n paint.setStrokeMiter(strokeMiter);\n }\n if (antiAlias !== undefined) {\n paint.setAntiAlias(antiAlias);\n }\n if (dither !== undefined) {\n paint.setDither(dither);\n }\n};\n"],"mappings":"AAAA,SAASA,OAAO,EAAEC,YAAY,QAAQ,oBAAoB;AAE1D,SACEC,SAAS,EACTC,UAAU,EACVC,SAAS,EACTC,UAAU,QACL,qBAAqB;AAI5B,OAAO,MAAMC,kBAAkB,GAAGA,CAChCC,IAAU,EACVC,GAAmB,EACnB;EACEC,OAAO;EACPC,KAAK;EACLC,SAAS;EACTC,WAAW;EACXC,KAAK;EACLC,UAAU;EACVC,SAAS;EACTC,WAAW;EACXC,SAAS;EACTC;AACU,CAAC,EACbC,UAAmB,KAChB;EACH,SAAS;;EACT,MAAM;IAAEC;EAAM,CAAC,GAAGZ,GAAG;EAErB,IAAIC,OAAO,KAAKY,SAAS,EAAE;IACzB,IAAIF,UAAU,EAAE;MACdC,KAAK,CAACE,SAAS,CAACF,KAAK,CAACG,SAAS,CAAC,CAAC,GAAGd,OAAO,CAAC;IAC9C,CAAC,MAAM;MACLD,GAAG,CAACgB,UAAU,CAAChB,GAAG,CAACiB,UAAU,CAAC,CAAC,GAAGhB,OAAO,CAAC;IAC5C;EACF;EACA,IAAIC,KAAK,KAAKW,SAAS,EAAE;IACvBD,KAAK,CAACM,SAAS,CAAC,IAAI,CAAC;IACrBN,KAAK,CAACO,QAAQ,CAAC1B,YAAY,CAACM,IAAI,EAAEG,KAAK,CAAC,CAAC;EAC3C;EACA,IAAIC,SAAS,KAAKU,SAAS,EAAE;IAC3BD,KAAK,CAACQ,YAAY,CAAC1B,SAAS,CAACF,OAAO,CAACW,SAAS,CAAC,CAAC,CAAC;EACnD;EACA,IAAIC,WAAW,KAAKS,SAAS,EAAE;IAC7BD,KAAK,CAACS,cAAc,CAACjB,WAAW,CAAC;EACnC;EACA,IAAIC,KAAK,KAAKQ,SAAS,EAAE;IACvBD,KAAK,CAACU,QAAQ,CAAC3B,UAAU,CAACH,OAAO,CAACa,KAAK,CAAC,CAAC,CAAC;EAC5C;EACA,IAAIC,UAAU,KAAKO,SAAS,EAAE;IAC5BD,KAAK,CAACW,aAAa,CAAC1B,UAAU,CAACL,OAAO,CAACc,UAAU,CAAC,CAAC,CAAC;EACtD;EACA,IAAIC,SAAS,KAAKM,SAAS,EAAE;IAC3BD,KAAK,CAACY,YAAY,CAAC5B,SAAS,CAACJ,OAAO,CAACe,SAAS,CAAC,CAAC,CAAC;EACnD;EACA,IAAIC,WAAW,KAAKK,SAAS,EAAE;IAC7BD,KAAK,CAACa,cAAc,CAACjB,WAAW,CAAC;EACnC;EACA,IAAIC,SAAS,KAAKI,SAAS,EAAE;IAC3BD,KAAK,CAACc,YAAY,CAACjB,SAAS,CAAC;EAC/B;EACA,IAAIC,MAAM,KAAKG,SAAS,EAAE;IACxBD,KAAK,CAACe,SAAS,CAACjB,MAAM,CAAC;EACzB;AACF,CAAC","ignoreList":[]}
@@ -7,7 +7,7 @@ export class ReanimatedRecorder {
7
7
  getSharedValues(): any[];
8
8
  saveGroup(): void;
9
9
  restoreGroup(): void;
10
- savePaint(props: any): void;
10
+ savePaint(props: any, standalone: any): void;
11
11
  restorePaint(): void;
12
12
  restorePaintDeclaration(): void;
13
13
  materializePaint(): void;
@@ -12,7 +12,7 @@ export class Recorder {
12
12
  add(command: any): void;
13
13
  saveGroup(): void;
14
14
  restoreGroup(): void;
15
- savePaint(props: any): void;
15
+ savePaint(props: any, standalone: any): void;
16
16
  restorePaint(): void;
17
17
  restorePaintDeclaration(): void;
18
18
  materializePaint(): void;
@@ -10,4 +10,4 @@ export function setPaintProperties(Skia: any, ctx: any, { opacity, color, blendM
10
10
  strokeMiter: any;
11
11
  antiAlias: any;
12
12
  dither: any;
13
- }): void;
13
+ }, standalone: any): void;
@@ -6,7 +6,7 @@ export class ReanimatedRecorder {
6
6
  getSharedValues(): any[];
7
7
  saveGroup(): void;
8
8
  restoreGroup(): void;
9
- savePaint(props: any): void;
9
+ savePaint(props: any, standalone: any): void;
10
10
  restorePaint(): void;
11
11
  restorePaintDeclaration(): void;
12
12
  materializePaint(): void;
@@ -11,7 +11,7 @@ export class Recorder {
11
11
  add(command: any): void;
12
12
  saveGroup(): void;
13
13
  restoreGroup(): void;
14
- savePaint(props: any): void;
14
+ savePaint(props: any, standalone: any): void;
15
15
  restorePaint(): void;
16
16
  restorePaintDeclaration(): void;
17
17
  materializePaint(): void;
@@ -9,4 +9,4 @@ export function setPaintProperties(Skia: any, ctx: any, { opacity, color, blendM
9
9
  strokeMiter: any;
10
10
  antiAlias: any;
11
11
  dither: any;
12
- }): void;
12
+ }, standalone: any): void;
@@ -5,7 +5,7 @@ import type { SkPicture } from "./Picture";
5
5
  export interface BaseRecorder {
6
6
  saveGroup(): void;
7
7
  restoreGroup(): void;
8
- savePaint(props: AnimatedProps<PaintProps>): void;
8
+ savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void;
9
9
  restorePaint(): void;
10
10
  restorePaintDeclaration(): void;
11
11
  materializePaint(): void;
@@ -11,7 +11,7 @@ export declare class ReanimatedRecorder implements BaseRecorder {
11
11
  getSharedValues(): SharedValue<unknown>[];
12
12
  saveGroup(): void;
13
13
  restoreGroup(): void;
14
- savePaint(props: AnimatedProps<PaintProps>): void;
14
+ savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void;
15
15
  restorePaint(): void;
16
16
  restorePaintDeclaration(): void;
17
17
  materializePaint(): void;
@@ -21,7 +21,7 @@ export declare class Recorder implements BaseRecorder {
21
21
  private add;
22
22
  saveGroup(): void;
23
23
  restoreGroup(): void;
24
- savePaint(props: AnimatedProps<PaintProps>): void;
24
+ savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void;
25
25
  restorePaint(): void;
26
26
  restorePaintDeclaration(): void;
27
27
  materializePaint(): void;
@@ -1,4 +1,4 @@
1
1
  import type { PaintProps } from "../../../dom/types";
2
2
  import type { Skia } from "../../../skia/types";
3
3
  import type { DrawingContext } from "../DrawingContext";
4
- export declare const setPaintProperties: (Skia: Skia, ctx: DrawingContext, { opacity, color, blendMode, strokeWidth, style, strokeJoin, strokeCap, strokeMiter, antiAlias, dither, }: PaintProps) => void;
4
+ export declare const setPaintProperties: (Skia: Skia, ctx: DrawingContext, { opacity, color, blendMode, strokeWidth, style, strokeJoin, strokeCap, strokeMiter, antiAlias, dither, }: PaintProps, standalone: boolean) => void;
package/package.json CHANGED
@@ -8,7 +8,7 @@
8
8
  "setup-skia-web": "scripts/setup-canvaskit.js"
9
9
  },
10
10
  "title": "React Native Skia",
11
- "version": "2.0.3",
11
+ "version": "2.0.4",
12
12
  "description": "High-performance React Native Graphics using Skia",
13
13
  "main": "lib/module/index.js",
14
14
  "react-native": "src/index.ts",
@@ -14,6 +14,7 @@ import {
14
14
  Group,
15
15
  Image,
16
16
  ImageShader,
17
+ Paint,
17
18
  RoundedRect,
18
19
  } from "../../components";
19
20
  import { setupSkia } from "../../../skia/__tests__/setup";
@@ -275,4 +276,26 @@ describe("Opacity", () => {
275
276
  );
276
277
  checkImage(img, "snapshots/drawings/opacity-image.png");
277
278
  });
279
+ it("Should apply opacity on a layer (1)", async () => {
280
+ const {} = importSkia();
281
+ const img = await surface.draw(
282
+ <Group>
283
+ <Group layer={<Paint opacity={0.5} />}>
284
+ <Fill color="lightblue" />
285
+ </Group>
286
+ </Group>
287
+ );
288
+ checkImage(img, "snapshots/drawings/semi-transparent-layer.png");
289
+ });
290
+ it("Should apply opacity on a layer (2)", async () => {
291
+ const {} = importSkia();
292
+ const img = await surface.draw(
293
+ <Group>
294
+ <Group layer={<Paint opacity={0} />}>
295
+ <Fill color="lightblue" />
296
+ </Group>
297
+ </Group>
298
+ );
299
+ checkImage(img, "snapshots/drawings/transparent-layer.png");
300
+ });
278
301
  });
@@ -34,7 +34,7 @@ import type { SkPicture } from "./Picture";
34
34
  export interface BaseRecorder {
35
35
  saveGroup(): void;
36
36
  restoreGroup(): void;
37
- savePaint(props: AnimatedProps<PaintProps>): void;
37
+ savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void;
38
38
  restorePaint(): void;
39
39
  restorePaintDeclaration(): void;
40
40
  materializePaint(): void;
@@ -67,7 +67,13 @@ function play(ctx: DrawingContext, _command: Command) {
67
67
  ctx.paints.push(command.props.paint);
68
68
  } else {
69
69
  ctx.savePaint();
70
- setPaintProperties(ctx.Skia, ctx, command.props);
70
+ setPaintProperties(
71
+ ctx.Skia,
72
+ ctx,
73
+ command.props,
74
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
75
+ (command as any).standalone
76
+ );
71
77
  }
72
78
  } else if (isCommand(command, CommandType.RestorePaint)) {
73
79
  ctx.restorePaint();
@@ -69,9 +69,9 @@ export class ReanimatedRecorder implements BaseRecorder {
69
69
  this.recorder.restoreGroup();
70
70
  }
71
71
 
72
- savePaint(props: AnimatedProps<PaintProps>): void {
72
+ savePaint(props: AnimatedProps<PaintProps>, standalone: boolean): void {
73
73
  this.processAnimationValues(props);
74
- this.recorder.savePaint(props);
74
+ this.recorder.savePaint(props, standalone);
75
75
  }
76
76
 
77
77
  restorePaint(): void {
@@ -102,8 +102,8 @@ export class Recorder implements BaseRecorder {
102
102
  this.cursors.pop();
103
103
  }
104
104
 
105
- savePaint(props: AnimatedProps<PaintProps>) {
106
- this.add({ type: CommandType.SavePaint, props });
105
+ savePaint(props: AnimatedProps<PaintProps>, standalone: boolean) {
106
+ this.add({ type: CommandType.SavePaint, props, standalone });
107
107
  }
108
108
 
109
109
  restorePaint() {
@@ -188,7 +188,7 @@ const pushMaskFilters = (recorder: BaseRecorder, maskFilters: Node<any>[]) => {
188
188
 
189
189
  const pushPaints = (recorder: BaseRecorder, paints: Node<any>[]) => {
190
190
  paints.forEach((paint) => {
191
- recorder.savePaint(paint.props);
191
+ recorder.savePaint(paint.props, true);
192
192
  const { colorFilters, maskFilters, shaders, imageFilters, pathEffects } =
193
193
  sortNodeChildren(paint);
194
194
  pushColorFilters(recorder, colorFilters);
@@ -223,7 +223,7 @@ const visitNode = (recorder: BaseRecorder, node: Node<any>) => {
223
223
  pathEffects.length > 0 ||
224
224
  shaders.length > 0;
225
225
  if (shouldPushPaint) {
226
- recorder.savePaint(paint ?? {});
226
+ recorder.savePaint(paint ?? {}, false);
227
227
  pushColorFilters(recorder, colorFilters);
228
228
  pushImageFilters(recorder, imageFilters);
229
229
  pushMaskFilters(recorder, maskFilters);
@@ -23,13 +23,18 @@ export const setPaintProperties = (
23
23
  strokeMiter,
24
24
  antiAlias,
25
25
  dither,
26
- }: PaintProps
26
+ }: PaintProps,
27
+ standalone: boolean
27
28
  ) => {
28
29
  "worklet";
29
30
  const { paint } = ctx;
30
31
 
31
32
  if (opacity !== undefined) {
32
- ctx.setOpacity(ctx.getOpacity() * opacity);
33
+ if (standalone) {
34
+ paint.setAlphaf(paint.getAlphaf() * opacity);
35
+ } else {
36
+ ctx.setOpacity(ctx.getOpacity() * opacity);
37
+ }
33
38
  }
34
39
  if (color !== undefined) {
35
40
  paint.setShader(null);