【问题标题】:Drawing a curve绘制曲线
【发布时间】:2014-01-25 19:45:14
【问题描述】:

尝试绘制一个二次函数,其中用户输入 a、b、c (ax^2 + bx + c)。我已经制作了一个计算根的函数,现在我必须尝试绘制图形。我复制了微软的贝塞尔曲线示例,它可以编译,但没有输出。任何帮助都会很棒

    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;


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

    private void Form1_Load(object sender, EventArgs e)
    {

    }

    public void drawBeziers(Pen pen, Point[] coordinates)
    {
    }
    private void quadGraph(PaintEventArgs e)
    {
      Pen blackPen = new Pen(Color.Black, 3);

      Point start = new Point(100, 100);
      Point control1 = new Point(200, 10);
      Point control2 = new Point(350, 50);
      Point end1 = new Point(500, 100);
      Point control3 = new Point(600, 150);
      Point control4 = new Point(650, 250);
      Point end2 = new Point(500, 300);
      Point[] bezierPoints = 
                 {
                     start, control1, control2, end1, 
                     control3, control4, end2
                 };

      e.Graphics.DrawBeziers(blackPen, bezierPoints);



    }

【问题讨论】:

  • 你甚至不调用 quadGraph()....

标签: c# graph


【解决方案1】:

你甚至不调用 quadGraph(),把它添加到你的类中:

protected override void OnPaint(PaintEventArgs pe)
{
   base.OnPaint(pe);
   quadGraph(pe);
}

【讨论】:

    猜你喜欢
    • 2015-09-11
    • 1970-01-01
    • 1970-01-01
    • 2013-12-18
    • 2019-08-31
    • 2016-02-04
    • 1970-01-01
    • 1970-01-01
    • 2023-04-06
    相关资源
    最近更新 更多