c#图形区域组合操作
来源:互联网 发布:js prompt函数 编辑:程序博客网 时间:2024/04/29 21:43
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Text;
- using System.Windows.Forms;
- namespace advanced_drawing
- {
- public partial class Form17 : Form
- {
- public Form17()
- {
- InitializeComponent();
- }
- private void Form17_Paint(object sender, PaintEventArgs e)
- {
- Rectangle regionRect = new Rectangle(20, 20, 100, 100);
- e.Graphics.DrawRectangle(Pens.Black, regionRect);
- RectangleF unionRect = new RectangleF(90, 30, 100, 100);
- e.Graphics.DrawRectangle(Pens.Red, Rectangle.Round(unionRect));
- Region myRegion = new Region(regionRect);
-
-
-
-
- myRegion.Xor(unionRect);
- SolidBrush myBrush = new SolidBrush(Color.Blue);
- e.Graphics.FillRegion(myBrush, myRegion);
- }
- }
- }