react-native-livechart 4.24.0 → 4.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,6 +2,16 @@ import { type SharedValue } from "react-native-reanimated";
|
|
|
2
2
|
import type { LiveChartPalette } from "../types";
|
|
3
3
|
import type { ChartEngineLayout } from "../core/useLiveChartEngine";
|
|
4
4
|
type DegenPack = SharedValue<Float64Array<ArrayBuffer>>;
|
|
5
|
+
type DegenParticlesOverlayProps = {
|
|
6
|
+
pack: DegenPack;
|
|
7
|
+
packRevision: SharedValue<number>;
|
|
8
|
+
engine: ChartEngineLayout;
|
|
9
|
+
palette: LiveChartPalette;
|
|
10
|
+
particleSlotCount: number;
|
|
11
|
+
particleBurstDurationSec: number;
|
|
12
|
+
particleOpacity: number;
|
|
13
|
+
colors: string[] | null;
|
|
14
|
+
};
|
|
5
15
|
/**
|
|
6
16
|
* Renders the degen particle burst with a single `drawAtlas` call.
|
|
7
17
|
*
|
|
@@ -19,15 +29,6 @@ type DegenPack = SharedValue<Float64Array<ArrayBuffer>>;
|
|
|
19
29
|
* correctly-faded particle, visually equivalent to the old `<Circle color
|
|
20
30
|
* opacity>`.
|
|
21
31
|
*/
|
|
22
|
-
export declare function DegenParticlesOverlay(
|
|
23
|
-
pack: DegenPack;
|
|
24
|
-
packRevision: SharedValue<number>;
|
|
25
|
-
engine: ChartEngineLayout;
|
|
26
|
-
palette: LiveChartPalette;
|
|
27
|
-
particleSlotCount: number;
|
|
28
|
-
particleBurstDurationSec: number;
|
|
29
|
-
particleOpacity: number;
|
|
30
|
-
colors: string[] | null;
|
|
31
|
-
}): import("react").JSX.Element;
|
|
32
|
+
export declare function DegenParticlesOverlay(props: DegenParticlesOverlayProps): import("react").JSX.Element;
|
|
32
33
|
export {};
|
|
33
34
|
//# sourceMappingURL=DegenParticlesOverlay.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DegenParticlesOverlay.d.ts","sourceRoot":"","sources":["../../src/components/DegenParticlesOverlay.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAM5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,KAAK,SAAS,GAAG,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"DegenParticlesOverlay.d.ts","sourceRoot":"","sources":["../../src/components/DegenParticlesOverlay.tsx"],"names":[],"mappings":"AAQA,OAAO,EAAmB,KAAK,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAM5E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAEpE,KAAK,SAAS,GAAG,WAAW,CAAC,YAAY,CAAC,WAAW,CAAC,CAAC,CAAC;AAExD,KAAK,0BAA0B,GAAG;IAChC,IAAI,EAAE,SAAS,CAAC;IAChB,YAAY,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAClC,MAAM,EAAE,iBAAiB,CAAC;IAC1B,OAAO,EAAE,gBAAgB,CAAC;IAC1B,iBAAiB,EAAE,MAAM,CAAC;IAC1B,wBAAwB,EAAE,MAAM,CAAC;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;CACzB,CAAC;AA8CF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,0BAA0B,+BAGtE"}
|
package/package.json
CHANGED
|
@@ -17,13 +17,30 @@ import type { ChartEngineLayout } from "../core/useLiveChartEngine";
|
|
|
17
17
|
|
|
18
18
|
type DegenPack = SharedValue<Float64Array<ArrayBuffer>>;
|
|
19
19
|
|
|
20
|
+
type DegenParticlesOverlayProps = {
|
|
21
|
+
pack: DegenPack;
|
|
22
|
+
packRevision: SharedValue<number>;
|
|
23
|
+
engine: ChartEngineLayout;
|
|
24
|
+
palette: LiveChartPalette;
|
|
25
|
+
particleSlotCount: number;
|
|
26
|
+
particleBurstDurationSec: number;
|
|
27
|
+
particleOpacity: number;
|
|
28
|
+
colors: string[] | null;
|
|
29
|
+
};
|
|
30
|
+
|
|
20
31
|
type ParticlePool = {
|
|
21
|
-
a:
|
|
22
|
-
b:
|
|
32
|
+
a: ParticleFrame;
|
|
33
|
+
b: ParticleFrame;
|
|
23
34
|
tick: boolean;
|
|
24
35
|
instances: ReturnType<typeof buildParticleInstances>;
|
|
25
36
|
instancePool: ReturnType<typeof buildParticleInstances>;
|
|
26
|
-
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
type ParticleFrame = {
|
|
40
|
+
transforms: SkRSXform[];
|
|
41
|
+
sprites: SkRect[];
|
|
42
|
+
colors: SkColor[];
|
|
43
|
+
activeCount: number;
|
|
27
44
|
};
|
|
28
45
|
|
|
29
46
|
function makeParticlePool(
|
|
@@ -37,13 +54,21 @@ function makeParticlePool(
|
|
|
37
54
|
alpha: 0,
|
|
38
55
|
colorIndex: 0,
|
|
39
56
|
}));
|
|
57
|
+
const spriteRect = Skia.XYWHRect(0, 0, spriteSize, spriteSize);
|
|
58
|
+
const hiddenTransform = Skia.RSXform(0, 0, 0, 0);
|
|
59
|
+
const hiddenColor = Skia.Color("rgba(0, 0, 0, 0)");
|
|
60
|
+
const makeFrame = (): ParticleFrame => ({
|
|
61
|
+
transforms: Array.from({ length: particleSlotCount }, () => hiddenTransform),
|
|
62
|
+
sprites: Array.from({ length: particleSlotCount }, () => spriteRect),
|
|
63
|
+
colors: Array.from({ length: particleSlotCount }, () => hiddenColor),
|
|
64
|
+
activeCount: 0,
|
|
65
|
+
});
|
|
40
66
|
return {
|
|
41
|
-
a:
|
|
42
|
-
b:
|
|
67
|
+
a: makeFrame(),
|
|
68
|
+
b: makeFrame(),
|
|
43
69
|
tick: false,
|
|
44
70
|
instances: [],
|
|
45
71
|
instancePool,
|
|
46
|
-
spriteRect: Skia.XYWHRect(0, 0, spriteSize, spriteSize),
|
|
47
72
|
};
|
|
48
73
|
}
|
|
49
74
|
|
|
@@ -64,7 +89,12 @@ function makeParticlePool(
|
|
|
64
89
|
* correctly-faded particle, visually equivalent to the old `<Circle color
|
|
65
90
|
* opacity>`.
|
|
66
91
|
*/
|
|
67
|
-
export function DegenParticlesOverlay({
|
|
92
|
+
export function DegenParticlesOverlay(props: DegenParticlesOverlayProps) {
|
|
93
|
+
// Replace the Atlas and its derived values together when the array size changes.
|
|
94
|
+
return <ParticleAtlas key={props.particleSlotCount} {...props} />;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function ParticleAtlas({
|
|
68
98
|
pack,
|
|
69
99
|
packRevision,
|
|
70
100
|
engine,
|
|
@@ -73,16 +103,7 @@ export function DegenParticlesOverlay({
|
|
|
73
103
|
particleBurstDurationSec,
|
|
74
104
|
particleOpacity,
|
|
75
105
|
colors,
|
|
76
|
-
}: {
|
|
77
|
-
pack: DegenPack;
|
|
78
|
-
packRevision: SharedValue<number>;
|
|
79
|
-
engine: ChartEngineLayout;
|
|
80
|
-
palette: LiveChartPalette;
|
|
81
|
-
particleSlotCount: number;
|
|
82
|
-
particleBurstDurationSec: number;
|
|
83
|
-
particleOpacity: number;
|
|
84
|
-
colors: string[] | null;
|
|
85
|
-
}) {
|
|
106
|
+
}: DegenParticlesOverlayProps) {
|
|
86
107
|
/* istanbul ignore next -- branch depends on render-time props */
|
|
87
108
|
const colorList = colors && colors.length > 0 ? colors : [palette.line];
|
|
88
109
|
|
|
@@ -110,11 +131,8 @@ export function DegenParticlesOverlay({
|
|
|
110
131
|
pool.tick = !pool.tick;
|
|
111
132
|
const frame = pool.tick ? pool.a : pool.b;
|
|
112
133
|
const transforms = frame.transforms;
|
|
113
|
-
const sprites = frame.sprites;
|
|
114
134
|
const colorsOut = frame.colors;
|
|
115
|
-
|
|
116
|
-
sprites.length = 0;
|
|
117
|
-
colorsOut.length = 0;
|
|
135
|
+
let activeCount = 0;
|
|
118
136
|
if (rev >= 0) {
|
|
119
137
|
const instances = buildParticleInstances(
|
|
120
138
|
pack.get(),
|
|
@@ -127,22 +145,25 @@ export function DegenParticlesOverlay({
|
|
|
127
145
|
pool.instancePool,
|
|
128
146
|
);
|
|
129
147
|
const half = sprite.size / 2;
|
|
130
|
-
|
|
148
|
+
activeCount = instances.length;
|
|
149
|
+
for (let i = 0; i < activeCount; i++) {
|
|
131
150
|
const inst = instances[i];
|
|
132
151
|
// Center the scaled sprite on (x, y); RSXform has no rotation.
|
|
133
|
-
transforms.
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
inst.y - inst.scale * half,
|
|
139
|
-
),
|
|
152
|
+
transforms[i] = Skia.RSXform(
|
|
153
|
+
inst.scale,
|
|
154
|
+
0,
|
|
155
|
+
inst.x - inst.scale * half,
|
|
156
|
+
inst.y - inst.scale * half,
|
|
140
157
|
);
|
|
141
|
-
sprites.push(pool.spriteRect);
|
|
142
158
|
const [r, g, b] = colorRgb[inst.colorIndex % colorRgb.length];
|
|
143
|
-
colorsOut
|
|
159
|
+
colorsOut[i] = Skia.Color(`rgba(${r}, ${g}, ${b}, ${inst.alpha})`);
|
|
144
160
|
}
|
|
145
161
|
}
|
|
162
|
+
for (let i = activeCount; i < frame.activeCount; i++) {
|
|
163
|
+
transforms[i] = Skia.RSXform(0, 0, 0, 0);
|
|
164
|
+
colorsOut[i] = Skia.Color("rgba(0, 0, 0, 0)");
|
|
165
|
+
}
|
|
166
|
+
frame.activeCount = activeCount;
|
|
146
167
|
return frame;
|
|
147
168
|
}, [
|
|
148
169
|
pack,
|