C#中画三角形和填充三角形的简单实现

C#中画三角形和填充三角形的简单实现:

private void Form1_Paint(object sender, PaintEventArgs e)        
{            
    Graphics g = e.Graphics;                   
    //绘制三角形            
    DrawTriangle_1(g);            
       //填充三角形            
     FillTriangle_1(g);               
}

// 绘制三角形      
private void DrawTriangle_1(Graphics g)        
{            
    Point point1 = new Point(50, 20);            
    Point point2 = new Point(75, 50);            
    Point point3 = new Point(100, 20);            
    Point[] pntArr = { point1, point2, point3 };            
    g.DrawPolygon(new Pen(Color.Red), pntArr);        
}

// 填充三角形       
private void FillTriangle_1(Graphics g)        
{            
    Point point1 = new Point(50, 20);            
    Point point2 = new Point(75, 50);            
    Point point3 = new Point(100, 20);            
    Point[] pntArr = { point1, point2, point3 };            
    g.FillPolygon(Brushes.Red, pntArr);        
}

猜你喜欢

转载自www.cnblogs.com/ming-4/p/12204583.html