Chinaunix首页 | 论坛 | 博客
  • 博客访问: 547672
  • 博文数量: 156
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 1183
  • 用 户 组: 普通用户
  • 注册时间: 2013-11-22 11:42
文章分类

全部博文(156)

文章存档

2015年(67)

2014年(89)

分类: C#/.net

2014-11-29 23:41:40



  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Threading;
  8. using System.Text;
  9. using System.Windows.Forms;

  10. namespace sin
  11. {
  12.     public partial class Form1 : Form
  13.     {
  14.         public Form1()
  15.         {
  16.             InitializeComponent();
  17.         }

  18.         private void button1_Click(object sender, EventArgs e)
  19.         {
  20.             Graphics DrawInterface = panel1.CreateGraphics();
  21.             Pen MyPenBlue = new Pen(Color.Blue, 5);
  22.             Pen MyPenBlack = new Pen(Color.Black, 5);
  23.             Pen MyPenControl = new Pen(Color.FromName("Control"), 3);
  24.             Pen MyPenRed = new Pen(Color.FromArgb(128, 255, 0, 0), 3);

  25.             DrawInterface.DrawLine(MyPenBlack, 0, 300, 800, 300); //画直线
  26.             int i;
  27.             double angle1;
  28.             float x1, y1, x2, y2;
  29.                     
  30.                    for (i = 0; i < 720; i+=30) //画正弦函数
  31.                    {
  32.                         angle1 = (float)i * 2 * 3.14 / 360;
  33.                         x1 = i;
  34.                         y1 = (float)(300 - 150 * Math.Sin(angle1));


  35.                         x2 = i + 30;
  36.                         float angle2 = (float)((i+30) * 2 * 3.14 / 360); //折线


  37.                         y2 = (float)(300 - 150 * Math.Sin(angle2));


  38.                         DrawInterface.DrawLine(MyPenBlue, x1, y1, x2, y2);
  39.                         Thread.Sleep(200);
  40.                  }
  41.             }
  42.         }
  43.     }



阅读(2694) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~