skia2/resources/particles/writing.json
Brian Osman 95c26efc90 Pure SkSL RNG for particles
Change-Id: I2cb6255a553852a292427d6dc9ef8c5ed7f8286d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/252926
Commit-Queue: Brian Osman <brianosman@google.com>
Reviewed-by: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
2020-04-10 17:20:07 +00:00

43 lines
999 B
JSON

{
"MaxCount": 4000,
"Drawable": {
"Type": "SkCircleDrawable",
"Radius": 2
},
"EffectCode": [
"void effectSpawn(inout Effect effect) {",
" effect.lifetime = 4;",
"}",
"",
"void effectUpdate(inout Effect effect) {",
" effect.color.r = 0;",
" effect.color.g = 1 - effect.age;",
" effect.color.b = effect.age;",
"",
" effect.rate = effect.age < 0.75 ? 800 : 0;",
"}",
""
],
"Code": [
"uniform float2 mouse_pos;",
"",
"void spawn(inout Particle p) {",
" p.lifetime = 4;",
" p.pos = mouse_pos;",
" p.frame = effect.age / 0.75 + mix(-0.05, 0.05, rand(p.seed));",
"}",
"",
"void update(inout Particle p) {",
" p.pos = mix(p.pos, text(p.frame).xy, 0.05);",
"}",
""
],
"Bindings": [
{
"Type": "SkTextBinding",
"Name": "text",
"Text": "HELLO WORLD",
"FontSize": 96
}
]
}