Ejemplo n.º 1
0
            public void Render(float x, float y, float ox, float oy)
            {
                // modulate gain
                _Gain += _Parent.NextRandomFloat(-0.05f, 0.05f);
                _Gain  = _Gain.Clamp(0, 1);

                // calculate grains by distance
                //int grains = int(sqrt((ox-x)*(ox-x)+(oy-y)*(oy-y)));
                const int grains = 64;

                // lay down grains of sand (transparent pixels)
                float w = _Gain / (grains - 1);

                for (int i = 0; i < grains; i++)
                {
                    var cx = ox + (x - ox) * (float)Math.Sin(Math.Sin(i * w));
                    var cy = oy + (y - oy) * (float)Math.Sin(Math.Sin(i * w));

                    float a = 0.1f - (float)i / (grains * 10.0f);
                    a *= 10;

                    _Parent.DrawPoint(cx, cy, _Color.WithAlpha((int)(a * 256)));
                }
            }