C# tutorial-C# drawing arc

C# drawing arcs

To draw a curved shape using graphic object, you need to use its drawArc() method. This method accepts four parameters. The firs parameter is the pen object. Second parameter is the rectangle object that determines the boundaries of  arc shapes. The third and fourth parameters are start angle and end angle(respectively).

Example: drawing five arcs on the form


using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;


namespace WindowsFormsApplication2


    public partial class Form2 : Form


        public Form2()





        private void Form2_Paint(object sender, PaintEventArgs e)



            //Create graphic object for the current form

            Graphics gs = this.CreateGraphics();

            //Create pen objects with thick width

            Pen p = new Pen(new SolidBrush(Color.Blue), 10);

           //Create a rectangle

            Rectangle rt = new Rectangle(100, 50, 200, 200);

            Rectangle rt1 = new Rectangle(120, 60, 160, 210);

            Rectangle rt2 = new Rectangle(140, 70, 120, 220);

            Rectangle rt3 = new Rectangle(160, 80, 80, 230);

            Rectangle rt4 = new Rectangle(180, 90, 40, 240);

          //Draw arcs


            gs.DrawArc(p, rt, 0, -180);

            gs.DrawArc(p, rt1, 0, -180);

            gs.DrawArc(p, rt2, 0, -180);

            gs.DrawArc(p, rt3, 0, -180);

            gs.DrawArc(p, rt4, 0, -180);





  C# to fill shapes with gradient brush


This website intents to provide free and high quality tutorials, examples, exercises and solutions, questions and answers of programming and scripting languages:
C, C++, C#, Java, VB.NET, Python, VBA,PHP & Mysql, SQL, JSP, ASP.NET,HTML, CSS, JQuery, JavaScript and other applications such as MS Excel, MS Access, and MS Word. However, we don't guarantee all things of the web are accurate. If you find any error, please report it then we will take actions to correct it as soon as possible.