C#使用Region对图形区域构造和填充的方法


本文实例讲述了C#使用Region对图形区域构造和填充的方法。分享给大家供大家参考。具体如下:

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 Form15 : Form
  {
    public Form15()
    {
      InitializeComponent();
    }
    private void Form15_Paint(object sender, PaintEventArgs e)
    {
      GraphicsPath myPath = new GraphicsPath();
      string stringText = "zhuzhao";
      FontFamily family = new FontFamily("Arial");
      int fontStyle = (int)FontStyle.Italic;
      int emSize = 26;
      Point origin = new Point(20, 20);
      StringFormat format = StringFormat.GenericDefault;
      myPath.AddString(stringText,family,fontStyle,emSize,origin,format);
      Region region = new Region(myPath);
      e.Graphics.FillRegion(Brushes.Red, region);
    }
  }
}

希望本文所述对大家的C#程序设计有所帮助。


« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3