C# PathGradientBrush 处理颜色渐渐变

来源:互联网 发布:怎样用vba编写软件 编辑:程序博客网 时间:2024/06/05 09:15

效果

 

 

复制代码到Form.cs下

 

        protected override void OnPaint(PaintEventArgs e)
        {
            Point _Left1 = new Point(0, 0);
            Point _Left2 = new Point(this.Width / 2, 0);
            Point _Left3 = new Point(this.Width / 2, this.Height);
            Point _Left4 = new Point(0, this.Height);

            Point[] _Point = new Point[] { _Left1, _Left2, _Left3, _Left4 };
            PathGradientBrush _SetBruhs = new PathGradientBrush(_Point, WrapMode.TileFlipX);
            _SetBruhs.CenterPoint = new PointF(0, 0);
            _SetBruhs.FocusScales = new PointF(0, this.Height);
            _SetBruhs.CenterColor = Color.Red;
            _SetBruhs.SurroundColors=new Color[]{Color.Yellow};

            e.Graphics.FillRectangle(_SetBruhs, new Rectangle(0, 0, this.Width, this.Height));

            base.OnPaint(e);
        }

原创粉丝点击