/// <summary> /// Draws a raindrop on canvas at the current position. /// </summary> public void Draw(RainyDay rainyday, CanvasDrawingSession context) { float orgR = r; r = 0.95f * r; if (r < 3) { clipGeo = CanvasGeometry.CreateCircle(context, new Vector2(x, y), r); } else if (colliding != null || yspeed > 2) { if (colliding != null) { var collider = colliding; r = 1.001f * (r > collider.r ? r : collider.r); x += (collider.x - x); colliding = null; } float yr = 1 + 0.1f * yspeed; using (CanvasPathBuilder path = new CanvasPathBuilder(context)) { path.BeginFigure(x - r / yr, y); path.AddCubicBezier(new Vector2(x - r, y - r * 2), new Vector2(x + r, y - r * 2), new Vector2(x + r / yr, y)); path.AddCubicBezier(new Vector2(x + r, y + yr * r), new Vector2(x - r, y + yr * r), new Vector2(x - r / yr, y)); path.EndFigure(CanvasFigureLoop.Closed); clipGeo = CanvasGeometry.CreatePath(path); } } else { clipGeo = CanvasGeometry.CreateCircle(context, new Vector2(x, y), 0.9f * r); } r = orgR; if (rainyday.Reflection != null) { using (context.CreateLayer(1, clipGeo)) { rainyday.Reflection(context, this); } } if (clipGeo != null) { clipGeo.Dispose(); } }