skia2/resources/particles/swirl.json
Brian Osman 8a97782956 Move common particle code to an automatically-injected header
Change-Id: If99e1802c8187ebd98b67717d744c6695bb25900
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/238118
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Brian Osman <brianosman@google.com>
2019-08-29 18:49:33 +00:00

65 lines
1.6 KiB
JSON

{
"MaxCount": 4096,
"Duration": 1,
"Rate": 400,
"Drawable": {
"Type": "SkCircleDrawable",
"Radius": 2
},
"Code": [
"// float rand; Every read returns a random float [0 .. 1)",
"",
"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 ]
}
]
}
}
]
}