public override void ApplyState( SceneModifier modifier, RectangleF diagramBounds, FunnelSeriesPointLayoutParameters funnelParameters, float progress ) { RectangleF funnelBounds = funnelParameters.Bounds; float fanCenterX = funnelBounds.Left + funnelBounds.Width / 2; float fanCenterY = funnelBounds.Bottom; float fanRadius = (float)Math.Sqrt( (funnelBounds.Left - fanCenterX) * (funnelBounds.Left - fanCenterX) + (funnelBounds.Height) * (funnelBounds.Height) ); float startAngle = AnimationStartAngle - HalfMaxSweepAngle * progress; float sweepAngle = MaxSweepAngle * progress; float endAngle = startAngle + sweepAngle; float fanLeftBoundEndX = fanCenterX + (float)Math.Cos(startAngle / 180 * Math.PI) * fanRadius; float fanLeftBoundEndY = fanCenterY + (float)Math.Sin(startAngle / 180 * Math.PI) * fanRadius; float fanRightBoundEndX = fanCenterX + (float)Math.Cos(endAngle / 180 * Math.PI) * fanRadius; float fanRightBoundEndY = fanCenterY + (float)Math.Sin(endAngle / 180 * Math.PI) * fanRadius; RectangleF fanBounds = new RectangleF( fanCenterX - fanRadius, fanCenterY - fanRadius, 2 * fanRadius, 2 * fanRadius ); GraphicsPath path = new GraphicsPath(); path.AddLine(fanCenterX, fanCenterY, fanLeftBoundEndX, fanLeftBoundEndY); path.AddArc(fanBounds, startAngle, sweepAngle); path.AddLine(fanRightBoundEndX, fanRightBoundEndY, fanCenterX, fanCenterY); modifier.Clip(path); }
public override void ApplyState( SceneModifier modifier, RectangleF diagramBounds, MarkerSeriesPointLayoutParameters markerParameters, float progress ) { RectangleF markerBounds = markerParameters.Bounds; float markerCenterX = markerBounds.Left + markerBounds.Width / 2; float markerCenterY = markerBounds.Top + markerBounds.Height / 2; float startAngle = 360 - progress * 180; float sweepAngle = 360 * progress; float endAngle = startAngle + sweepAngle; // To apply a fan animation we need to compute parameters of // a marker's circumscribed сircle sector. float circumscribedCircleRadius = (float)Math.Sqrt( (markerBounds.Left - markerCenterX) * (markerBounds.Left - markerCenterX) + (markerBounds.Top - markerCenterY) * (markerBounds.Top - markerCenterY) ); float circumscribedCircleSectorLeftBoundEndX = markerCenterX + (float)Math.Cos(startAngle / 180 * Math.PI) * circumscribedCircleRadius; float circumscribedCircleSectorLeftBoundEndY = markerCenterY + (float)Math.Sin(startAngle / 180 * Math.PI) * circumscribedCircleRadius; float circumscribedCircleSectorRightBoundEndX = markerCenterX + (float)Math.Cos(endAngle / 180 * Math.PI) * circumscribedCircleRadius; float circumscribedCircleSectorRightBoundEndY = markerCenterY + (float)Math.Sin(endAngle / 180 * Math.PI) * circumscribedCircleRadius; RectangleF circumscribedCircleBounds = new RectangleF( markerCenterX - circumscribedCircleRadius, markerCenterY - circumscribedCircleRadius, 2 * circumscribedCircleRadius, 2 * circumscribedCircleRadius ); // Path representing a marker's circumscribed circle sector. GraphicsPath path = new GraphicsPath(); path.AddLine( markerCenterX, markerCenterY, circumscribedCircleSectorLeftBoundEndX, circumscribedCircleSectorLeftBoundEndY ); path.AddArc( circumscribedCircleBounds, startAngle, sweepAngle ); path.AddLine( circumscribedCircleSectorRightBoundEndX, circumscribedCircleSectorRightBoundEndY, markerCenterX, markerCenterY ); modifier.Clip(path); }