一个用gdi+写的代码

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 WindowsApplication2


{



    public partial class Form1 : Form
    {


        protected override void OnPaint(PaintEventArgs e)
        {
            Brush linerbrush = new LinearGradientBrush(new Rectangle(10, 10, 59, 59), Color.Red , Color.White, 45);
            Graphics g = e.Graphics;
            g.FillRectangle(linerbrush, new Rectangle(10, 10, 590, 590));////作出来的效果那是一个棒!!
            linerbrush.Dispose();////这句那是相当的重要,我就忘了,机子就变得很慢了!
            Rectangle r1 = new Rectangle(10, 10, 59, 59);
            Region r = new Region(r1);////可以用这句把path或rectrangle等化为region,也可以用union加上一些东西。OK
            GraphicsPath path;
            path = new GraphicsPath(new Point[] { new Point(10, 10), new Point(150, 10), new Point(200, 150), new Point(10, 150), new Point(200, 160) },
                new byte[] { (byte)PathPointType.Start, (byte)PathPointType.Line, (byte)PathPointType.Line, (byte)PathPointType.Line, (byte)PathPointType.Line });
            //e.Graphics.DrawPath(Pens.Black, path);
            r.Union(path);
            //e.Graphics.FillRegion(Brushes.Black, r);////这句证明fillregion是用来画黑图的。
            //e.Graphics.DrawPath(Pens.Black, path);////这句证明了drawpath是用来画路径的 draw的都是path,而fill的都是region。

        }////为了能够重载,所以放在了这里。
  
  /// <summary>
  /// 只要是可以认真分析出来的图形,都可以画出来。
  /// </summary>
    
 
        public Form1()
        {
            InitializeComponent();



        }

        private void Form1_Load(object sender, EventArgs e)
        {

        }
    }



}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值