Draw Path - CSharp System.Drawing

CSharp examples for System.Drawing:Graphics

Description

Draw Path

Demo Code


using System.Threading.Tasks;
using System.Text;
using System.Linq;
using System.Drawing;
using System.Collections.Generic;
using System;//from  w w  w.ja  va2  s  . com

public class Main{
        public static void DrawPath(Graphics grahic, List<Point> points)
        {
            for(int i=0;i<points.Count-1;i++)
            {
                grahic.DrawLine(myPen, points[i], points[i + 1]);
            }
        }
        public static void DrawLine(Graphics grahic, int x1, int y1, int x2, int y2,int num)
        {
            grahic.DrawLine(myPen, x1, y1, x2, y2);
            grahic.DrawString(num.ToString(), new Font(FontFamily.GenericSerif, 8), Brushes.Beige, (x1 + x2) / 2, (y1 + y2) / 2);
        }
        public static void DrawLine(Graphics grahic,int x1,int y1,int x2,int y2)
        {
            grahic.DrawLine(myPen, x1,y1,x2,y2);
        }
}

Related Tutorials