-
Notifications
You must be signed in to change notification settings - Fork 0
/
emitter.txt
47 lines (43 loc) · 1.36 KB
/
emitter.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const heartPath = document.createElementNS("http://www.w3.org/2000/svg", "path");
heartPath.setAttribute(
"d",
"M316.722,29.761c66.852,0,121.053,54.202,121.053,121.041c0,110.478-218.893,257.212-218.893,257.212S0,266.569,0,150.801 C0,67.584,54.202,29.761,121.041,29.761c40.262,0,75.827,19.745,97.841,49.976C240.899,49.506,276.47,29.761,316.722,29.761z"
);
const heartShape = document.createElementNS("http://www.w3.org/2000/svg", "svg");
heartShape.setAttribute("viewBox", "0 0 512 512");
heartShape.setAttribute("height", "20");
heartShape.setAttribute("width", "20");
heartShape.appendChild(heartPath);
party.scene.current.createEmitter({
emitterOptions: {
loops: 1,
lifetime: 0.01,
useGravity: false,
modules: [
new party.ModuleBuilder()
.drive("size")
.by((t) => 0.1 + 0.2 * (Math.sin(t *2) + 1))
.build(),
new party.ModuleBuilder()
.drive("opacity")
.by((t) => 1-t)
.through("lifetime")
.build(),
],
},
emissionOptions: {
rate: 0,
bursts: [{ time: 0, count: 6}],
sourceSampler: party.sources.dynamicSource(runButton),
angle: party.variation.range(0, 360),
initialSpeed: 60,
initialLifetime: 1,
initialColor: party.variation.gradientSample(
party.Gradient.simple(party.Color.fromHex("#ffa68d"), party.Color.fromHex("#fd3a84"))
),
},
rendererOptions: {
shapeFactory: heartShape,
applyLighting: undefined,
},
});