blob: 3063d49986df350ca0ba31d5779e086e88472d8f [file] [log] [blame]
{
"MaxCount": 4096,
"Duration": 1,
"Rate": 400,
"Drawable": {
"Type": "SkCircleDrawable",
"Radius": 2
},
"Code": [
"// float rand; Every read returns a random float [0 .. 1)",
"layout(ctype=float) in uniform float dt;",
"layout(ctype=float) in uniform float effectAge;",
"",
"struct Particle {",
" float age;",
" float lifetime;",
" float2 pos;",
" float2 dir;",
" float scale;",
" float2 vel;",
" float spin;",
" float4 color;",
" float frame;",
"};",
"",
"void spawn(inout Particle p) {",
" p.lifetime = 1 + 2 * rand;",
" p.pos.x = rand * 50;",
" float a = radians(-10 + 20 * rand);",
" float s = 50 + 10 * rand;",
" p.vel.x = sin(a) * s;",
" p.vel.y = -cos(a) * s;",
"}",
"",
"void update(inout Particle p) {",
" p.vel.x += wind(p.age) * dt;",
" p.scale = 3 - (1.5 * p.age);",
" p.color = color(p.age);",
"}",
""
],
"Bindings": [
{
"Type": "SkCurveBinding",
"Name": "wind",
"Curve": {
"XValues": [],
"Segments": [
{
"Type": "Cubic",
"Ranged": false,
"Bidirectional": true,
"A0": 180,
"B0": -90,
"C0": -120,
"D0": -200
}
]
}
},
{
"Type": "SkColorCurveBinding",
"Name": "color",
"Curve": {
"XValues": [],
"Segments": [
{
"Type": "Linear",
"Ranged": true,
"A0": [ 1, 0, 0, 1 ],
"D0": [ 1, 0.735294, 0, 1 ],
"A1": [ 1, 0.588235, 0, 1 ],
"D1": [ 0.941177, 1, 0, 1 ]
}
]
}
}
]
}