GDI+练习(画正弦曲线)

 题目要求:

编写一个能够显示正弦曲线的Window应用程序


输入代码:

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

namespace zhengxuan
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Paint(object sender, PaintEventArgs e)
        {
            Graphics g = this.CreateGraphics();     
            Pen P = new Pen(Color.Blue, 3);
            Point A = new Point(30, 30); //Point a = new Point(30, this.ClientSize.Height - 200); 
            Point B = new Point(30, 300);// Point b = new Point(this.ClientSize.Width - 100,this.ClientSize.Height - 200);
            Point C = new Point(500, 300); // Point c = new Point(30, 30); 
            g.DrawLine(P, B, A);//Y轴
            g.DrawLine(P, B, C);//X轴
            Font f = new Font("宋体", 12, FontStyle.Bold);
            g.DrawString("x", f, P.Brush, C);
            g.DrawString("y", f, P.Brush, 10, 10);
            Graphics g2 = e.Graphics;
            Point[] points = { new Point(30, 300), new Point(80, 220), new Point(130, 300),new Point(180,370),new Point(230,300) };
            g2.DrawCurve(P, points, 0.8f);
            g2.Dispose();
        }
    }
}


运行截图:

GDI+练习(画正弦曲线)_第1张图片


总结:

算术不好,只能描点了。。。




你可能感兴趣的:(.net学习笔记)