向区域中追加文本
Graphics g;//画板 GraphicsPath path;//路径 private void button1_Click(object sender, EventArgs e) { //从路径中构造区域 Region region = new Region(path); //填充区域 g.FillRegion(Brushes.Green, region); } private void Form2_Paint(object sender, PaintEventArgs e) { g = this.CreateGraphics();//画板对象 g.Clear(Color.White);//画板背景色 //设定文本输出质量 g.TextRenderingHint = TextRenderingHint.AntiAlias; g.SmoothingMode = SmoothingMode.AntiAlias; //创建路径区域 path = new GraphicsPath( FillMode.Alternate); //向区域中追加文本 path.AddString("wjshan0808", new FontFamily("微软雅黑"), (int)FontStyle.Regular, 60.0f, new Point(0, 0), new StringFormat()); //绘制路径 g.DrawPath(new Pen(Color.Red), path); g.TranslateTransform(0, 80); }