码迷,mamicode.com
首页 > Windows程序 > 详细

C#.NEt-GDI+中的Pen测试

时间:2014-10-17 18:51:20      阅读:323      评论:0      收藏:0      [点我收藏+]

标签:blog   http   color   io   ar   for   sp   2014   art   

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

//1366*768
namespace PaintTest1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            System.Random r = new System.Random();
            Graphics g;
            g = this.CreateGraphics();
  /*         while(true)
           {
               int x1 = r.Next(0, 1366);
               int y1 = r.Next(0, 200);
               int x2 = x1;
               int y2 = y1 + r.Next(0, 400);
               for(int i=y1;i<=y2;i++)
               {
                   Pen greenPen = new Pen(Color.Green, r.Next(1, 15));
                   g.DrawLine(greenPen, x1, y1, x2, y2);
               }
           } */
            for (int i = 0; i < 5000; i++)
            {
                    Pen whitePen = new Pen(Color.FromArgb(r.Next(0,255), r.Next(0,255), r.Next(0,255)),8);
                   int x1 = r.Next(100,300);
                   int y1 = r.Next(100, 500);
                   int x2 = r.Next(100, 300);
                   int y2 = r.Next(100, 500);
                   // int x1 = 500;
                   // int y1 = 500;
                   // int x2 = i;
                   // int y2 = 1000 * 1000 - i * i;
                    g.DrawLine(whitePen, x1, y1, x2, y2);
         
            }
            for (int i = 0; i < 5000; i++)
            {
                Pen whitePen = new Pen(Color.FromArgb(r.Next(0, 255), r.Next(0, 255), r.Next(0, 255)),9);
                int x1 = 500; //650-900
                int y1 = 300; //100-500
                int x2 = r.Next(400, 600);
                int y2 = r.Next(100, 500);
                // int x1 = 500;
                // int y1 = 500;
                // int x2 = i;
                // int y2 = 1000 * 1000 - i * i;
                g.DrawLine(whitePen, x1, y1, x2, y2);

            }
            for (int i = 0; i < 5000; i++)
            {
                Pen whitePen = new Pen(Color.FromArgb(r.Next(0, 255), r.Next(0, 255), r.Next(0, 255)),10);
                int x1 = 900; //650-900
                int y1 = 100; //100-500
                int x2 = r.Next(700, 900);
                int y2 = r.Next(100, 500);
                // int x1 = 500;
                // int y1 = 500;
                // int x2 = i;
                // int y2 = 1000 * 1000 - i * i;
                g.DrawLine(whitePen, x1, y1, x2, y2);

            }
            for (int i = 0; i < 5000; i++)
            {
                Pen whitePen = new Pen(Color.FromArgb(r.Next(0, 255), r.Next(0, 255), r.Next(0, 255)),11);
                int x1 = 1000; //650-900
                int y1 = 500; //100-500
                int x2 = r.Next(1000, 1200);
                int y2 = r.Next(100, 500);
                // int x1 = 500;
                // int y1 = 500;
                // int x2 = i;
                // int y2 = 1000 * 1000 - i * i;
                g.DrawLine(whitePen, x1, y1, x2, y2);

            }
            for (int i = 0; i < 5000; i++)
            {
                Pen whitePen = new Pen(Color.FromArgb(r.Next(0, 255), r.Next(0, 255), r.Next(0, 255)),12);
                int x1 = r.Next(100,1200); ; //650-900
                int y1 = r.Next(600, 700); ; //100-500
                int x2 = r.Next(100, 1200);
                int y2 = r.Next(600, 700);
                // int x1 = 500;
                // int y1 = 500;
                // int x2 = i;
                // int y2 = 1000 * 1000 - i * i;
                g.DrawLine(whitePen, x1, y1, x2, y2);

            }
            for (int i = 0; i < 5000; i++)
            {
                Pen whitePen = new Pen(Color.FromArgb(r.Next(0, 255), r.Next(0, 255), r.Next(0, 255)),r.Next(1,15));
                int x1 = r.Next(100, 1200); ; //650-900
                int y1 = r.Next(600, 700); ; //100-500
                int x2 = r.Next(100, 1200);
                int y2 = r.Next(600, 700);
                // int x1 = 500;
                // int y1 = 500;
                // int x2 = i;
                // int y2 = 1000 * 1000 - i * i;
                g.DrawLine(whitePen, x1, y1, x2, y2);

            }  
        }
    }
}



效果图<这是一种动态的绘图,效果还行,下面将改为数字雨的模式测试,相关算法正在调试.bubuko.com,布布扣

C#.NEt-GDI+中的Pen测试

标签:blog   http   color   io   ar   for   sp   2014   art   

原文地址:http://blog.csdn.net/shinepan/article/details/40188903

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!