c81378624f
Change-Id: Ic53dc7ecab1b44761fe06e6b528864d24cc5fa58 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/363940 Reviewed-by: Brian Osman <brianosman@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
52 lines
1.6 KiB
JSON
52 lines
1.6 KiB
JSON
{
|
|
"MaxCount": 300,
|
|
"Drawable": {
|
|
"Type": "SkCircleDrawable",
|
|
"Radius": 3
|
|
},
|
|
"Code": [
|
|
"void effectSpawn(inout Effect effect) {",
|
|
" // Phase one: Launch",
|
|
" effect.lifetime = 4;",
|
|
" effect.rate = 120;",
|
|
" float a = radians(mix(-20, 20, rand(effect.seed)) - 90);",
|
|
" float s = mix(200, 220, rand(effect.seed));",
|
|
" effect.vel.x = cos(a) * s;",
|
|
" effect.vel.y = sin(a) * s;",
|
|
" effect.color.rgb = float3(rand(effect.seed), rand(effect.seed), rand(effect.seed));",
|
|
" effect.pos.x = 0;",
|
|
" effect.pos.y = 0;",
|
|
" effect.scale = 0.25; // Also used as particle behavior flag",
|
|
"}",
|
|
"",
|
|
"void effectUpdate(inout Effect effect) {",
|
|
" if (effect.age > 0.5 && effect.rate > 0) {",
|
|
" // Phase two: Explode",
|
|
" effect.rate = 0;",
|
|
" effect.burst = 50;",
|
|
" effect.scale = 1;",
|
|
" } else {",
|
|
" effect.vel.y += dt * 90;",
|
|
" }",
|
|
"}",
|
|
"",
|
|
"void spawn(inout Particle p) {",
|
|
" bool explode = p.scale == 1;",
|
|
"",
|
|
" p.lifetime = explode ? (2 + rand(p.seed) * 0.5) : 0.5;",
|
|
" float a = radians(rand(p.seed) * 360);",
|
|
" float s = explode ? mix(90, 100, rand(p.seed)) : mix(5, 10, rand(p.seed));",
|
|
" p.vel.x = cos(a) * s;",
|
|
" p.vel.y = sin(a) * s;",
|
|
"}",
|
|
"",
|
|
"void update(inout Particle p) {",
|
|
" p.color.a = 1 - p.age;",
|
|
" if (p.scale == 1) {",
|
|
" p.vel.y += dt * 50;",
|
|
" }",
|
|
"}",
|
|
""
|
|
],
|
|
"Bindings": []
|
|
} |