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);        
}
posted @ 2020-01-17 10:30  小大大小  阅读(4042)  评论(0编辑  收藏  举报