Implementation Method of C Graphic Area Cutting

  • 2021-06-28 13:40:34
  • OfStack

This paper gives an example of how to cut the C#graphic area.Share it for your reference.Specifically as follows:


using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Drawing.Drawing2D;
namespace advanced_drawing
{
  public partial class Form16 : Form
  {
    public Form16()
    {
      InitializeComponent();
    }
    private void Form16_Paint(object sender, PaintEventArgs e)
    {
      Graphics g = e.Graphics;
      GraphicsPath path = new GraphicsPath();
      path.AddEllipse(this.ClientRectangle);
      Region regoin = new Region(path);
      g.DrawPath(Pens.Red, path);
      g.Clip = regoin;
      Rectangle rect = this.ClientRectangle;
      rect.Offset(10, 10);
      rect.Width -= 20;
      rect.Height -= 20;
      g.FillRectangle(Brushes.Black, rect);
      g.DrawString("zhuzhao", this.Font, Brushes.Blue, 100, 100);
    }
  }
}

I hope that the description in this paper will be helpful to everyone's C#program design.


Related articles: