要实现的目的是,在画板上画一个圆形,
点击按钮填充画板非圆形的区域,就是填充环形封闭区域,
大家有做过的么?
是不是可以用 Graphics 的 FillRegion(Point[],Color) 来实现,
可是这个 Ponit[] 也就是圆形图形上的每一个点怎么获取啊?
有做过的朋友么,请教一下~

解决方案 »

  1.   

    环形,画一个大圆,以此构造一个GraphicsPath,从中减去一个上圆,就成环了
    再填充此GraphicsPath
      

  2.   


    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 WindowsApplication253
    {
        public partial class Form1 : Form
        {
            PictureBox PB = new PictureBox();        public Form1()
            {
                InitializeComponent();            PB.Parent = this;
                PB.Dock = DockStyle.Fill;
                PB.Image = new Bitmap(500, 500);            using (Graphics G = Graphics.FromImage(PB.Image))
                {
                    GraphicsPath GP = new GraphicsPath();                GP.AddEllipse(new Rectangle(50, 50, 100, 100));                Region R = new Region(this.ClientRectangle);
                    R.Exclude(new Region(GP));                G.FillRegion(Brushes.Red, R);
                }
            }
        }
    }