/// <summary> /// Adds a circular arc of the given radius to the current path. /// The arc is centered at (xc, yc), /// begins at angle1 and proceeds in the direction /// of increasing angles to end at angle2. /// If angle2 is less than angle1, /// it will be progressively increased by 1 degree until it is greater than angle1. /// If there is a current point, an initial line segment will be added to the path /// to connect the current point to the beginning of the arc. /// If this initial line is undesired, /// it can be avoided by calling NewPath() before calling Arc(). /// </summary> /// <param name='xc'> /// Xc. /// </param> /// <param name='yc'> /// Yc. /// </param> /// <param name='radius'> /// Radius. /// </param> /// <param name='angle1'> /// Angle1 in degrees /// </param> /// <param name='angle2'> /// Angle2 in degrees /// </param> public void Arc(double xc, double yc, double radius, double angle1, double angle2) { if (radius <= 0) { throw new ArgumentException("Radius must be greater than zero"); } handler.Arc(Backend, xc, yc, radius, angle1, angle2); }
internal void Draw(DrawingPathBackendHandler targetHandler, object ctx, VectorImageData cm) { int di = 0; int ci = 0; int ii = 0; int ri = 0; int oi = 0; int imi = 0; int ti = 0; ContextBackendHandler handler = targetHandler as ContextBackendHandler; DrawingPathBackendHandler pathHandler = targetHandler; for (int n = 0; n < cm.Commands.Length; n++) { switch (cm.Commands [n]) { case DrawingCommand.AppendPath: var p = cm.Objects [oi++]; if (p is VectorImageData) { Draw(targetHandler, ctx, (VectorImageData)p); } else { pathHandler.AppendPath(ctx, p); } break; case DrawingCommand.Arc: pathHandler.Arc(ctx, cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++]); break; case DrawingCommand.ArcNegative: pathHandler.ArcNegative(ctx, cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++]); break; case DrawingCommand.Clip: handler.Clip(ctx); break; case DrawingCommand.ClipPreserve: handler.ClipPreserve(ctx); break; case DrawingCommand.ClosePath: pathHandler.ClosePath(ctx); break; case DrawingCommand.CurveTo: pathHandler.CurveTo(ctx, cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++]); break; case DrawingCommand.DrawImage2: handler.DrawImage(ctx, cm.Images [imi++], cm.Rectangles [ri++], cm.Rectangles [ri++]); break; case DrawingCommand.DrawImage: handler.DrawImage(ctx, cm.Images [imi++], cm.Doubles [di++], cm.Doubles [di++]); break; case DrawingCommand.DrawTextLayout: var lad = (TextLayoutData)cm.TextLayouts [ti++]; var la = new TextLayout(toolkit); lad.InitLayout(la); handler.DrawTextLayout(ctx, la, cm.Doubles [di++], cm.Doubles [di++]); break; case DrawingCommand.Fill: handler.Fill(ctx); break; case DrawingCommand.FillPreserve: handler.FillPreserve(ctx); break; case DrawingCommand.LineTo: pathHandler.LineTo(ctx, cm.Doubles [di++], cm.Doubles [di++]); break; case DrawingCommand.MoveTo: pathHandler.MoveTo(ctx, cm.Doubles [di++], cm.Doubles [di++]); break; case DrawingCommand.NewPath: handler.NewPath(ctx); break; case DrawingCommand.Rectangle: pathHandler.Rectangle(ctx, cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++]); break; case DrawingCommand.RelCurveTo: pathHandler.RelCurveTo(ctx, cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++], cm.Doubles [di++]); break; case DrawingCommand.RelLineTo: pathHandler.RelLineTo(ctx, cm.Doubles [di++], cm.Doubles [di++]); break; case DrawingCommand.RelMoveTo: pathHandler.RelMoveTo(ctx, cm.Doubles [di++], cm.Doubles [di++]); break; case DrawingCommand.Restore: handler.Restore(ctx); break; case DrawingCommand.Rotate: handler.Rotate(ctx, cm.Doubles [di++]); break; case DrawingCommand.Save: handler.Save(ctx); break; case DrawingCommand.Scale: handler.Scale(ctx, cm.Doubles [di++], cm.Doubles [di++]); break; case DrawingCommand.SetColor: handler.SetColor(ctx, cm.Colors [ci++]); break; case DrawingCommand.SetGlobalAlpha: handler.SetGlobalAlpha(ctx, cm.Doubles [di++]); break; case DrawingCommand.SetLineDash: var off = cm.Doubles [di++]; var ds = new double [cm.Ints [ii++]]; for (int i = 0; i < ds.Length; i++) { ds [i] = cm.Doubles [di++]; } handler.SetLineDash(ctx, off, ds); break; case DrawingCommand.SetLineWidth: handler.SetLineWidth(ctx, cm.Doubles [di++]); break; case DrawingCommand.SetPattern: handler.SetPattern(ctx, cm.Objects [oi++]); break; case DrawingCommand.Stroke: handler.Stroke(ctx); break; case DrawingCommand.StrokePreserve: handler.StrokePreserve(ctx); break; case DrawingCommand.Translate: handler.Translate(ctx, cm.Doubles [di++], cm.Doubles [di++]); break; case DrawingCommand.SetStyles: handler.SetStyles(ctx, (StyleSet)cm.Objects [oi++]); break; } } }