• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1{
2   "MaxCount": 4096,
3   "Duration": 1,
4   "Rate": 400,
5   "Drawable": {
6      "Type": "SkCircleDrawable",
7      "Radius": 2
8   },
9   "Code": [
10      "// float rand; Every read returns a random float [0 .. 1)",
11      "layout(ctype=float) in uniform float dt;",
12      "layout(ctype=float) in uniform float effectAge;",
13      "",
14      "struct Particle {",
15      "  float  age;",
16      "  float  lifetime;",
17      "  float2 pos;",
18      "  float2 dir;",
19      "  float  scale;",
20      "  float2 vel;",
21      "  float  spin;",
22      "  float4 color;",
23      "  float  frame;",
24      "};",
25      "",
26      "void spawn(inout Particle p) {",
27      "  p.lifetime = 1 + 2 * rand;",
28      "  p.pos.x = rand * 50;",
29      "  float a = radians(-10 + 20 * rand);",
30      "  float s = 50 + 10 * rand;",
31      "  p.vel.x = sin(a) * s;",
32      "  p.vel.y = -cos(a) * s;",
33      "}",
34      "",
35      "void update(inout Particle p) {",
36      "  p.vel.x += wind(p.age) * dt;",
37      "  p.scale = 3 - (1.5 * p.age);",
38      "  p.color = color(p.age);",
39      "}",
40      ""
41   ],
42   "Bindings": [
43      {
44         "Type": "SkCurveBinding",
45         "Name": "wind",
46         "Curve": {
47            "XValues": [],
48            "Segments": [
49               {
50                  "Type": "Cubic",
51                  "Ranged": false,
52                  "Bidirectional": true,
53                  "A0": 180,
54                  "B0": -90,
55                  "C0": -120,
56                  "D0": -200
57               }
58            ]
59         }
60      },
61      {
62         "Type": "SkColorCurveBinding",
63         "Name": "color",
64         "Curve": {
65            "XValues": [],
66            "Segments": [
67               {
68                  "Type": "Linear",
69                  "Ranged": true,
70                  "A0": [ 1, 0, 0, 1 ],
71                  "D0": [ 1, 0.735294, 0, 1 ],
72                  "A1": [ 1, 0.588235, 0, 1 ],
73                  "D1": [ 0.941177, 1, 0, 1 ]
74               }
75            ]
76         }
77      }
78   ]
79}