首页 > 编程 > C# > 正文

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

2020-01-24 01:44:22
字体:
来源:转载
供稿:网友

本文实例讲述了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#程序设计有所帮助。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表