diff --git a/Tests/Kernels/GraphicTest/Kernel.cs b/Tests/Kernels/GraphicTest/Kernel.cs index 2f6f606a5e..214b928ae0 100644 --- a/Tests/Kernels/GraphicTest/Kernel.cs +++ b/Tests/Kernels/GraphicTest/Kernel.cs @@ -79,6 +79,9 @@ private void DoTest(Canvas aCanvas) pen.Color = Color.Chartreuse; aCanvas.DrawCircle(pen, 69, 69, 10); + pen.Color = Color.CadetBlue; + aCanvas.DrawArc(45, 45, 35, 35, pen, 90, 270); + pen.Color = Color.DimGray; aCanvas.DrawEllipse(pen, 100, 69, 10, 50); diff --git a/source/Cosmos.HAL2/PIT.cs b/source/Cosmos.HAL2/PIT.cs index 000626400e..faf21d92fa 100644 --- a/source/Cosmos.HAL2/PIT.cs +++ b/source/Cosmos.HAL2/PIT.cs @@ -1,4 +1,4 @@ -using System; +using System; using System.Collections.Generic; using Cosmos.Core; diff --git a/source/Cosmos.System2/Graphics/Canvas.cs b/source/Cosmos.System2/Graphics/Canvas.cs index cb6a1f5fb8..a6ca186d67 100644 --- a/source/Cosmos.System2/Graphics/Canvas.cs +++ b/source/Cosmos.System2/Graphics/Canvas.cs @@ -604,6 +604,32 @@ public virtual void DrawFilledEllipse(Pen pen, int x, int y, int height, int wid DrawFilledEllipse(pen, new Point(x, y), height, width); } + /// + /// Draws an arc. + /// + /// + /// + /// + /// + /// + /// + /// + public virtual void DrawArc(int x, int y, int width, int height, Pen pen, int StartAngle = 0, int EndAngle = 360) + { + if (width == 0 || height == 0) + { + return; + } + + for (double Angle = StartAngle; Angle < EndAngle; Angle += 0.5) + { + double Angle1 = Math.PI * Angle / 180; + int IX = (int)(width * Math.Cos(Angle1)); + int IY = (int)(height * Math.Sin(Angle1)); + DrawPoint(pen, x + IX, y + IY); + } + } + /// /// Draw polygon. ///