|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace Curves
{
public partial class Form1 : Form
{
private List<double> ptList = new List<double>();
private BezierCurve bc = new BezierCurve();
public Form1()
{
InitializeComponent();
}
private void pictureBox1_MouseClick(object sender, MouseEventArgs e)
{
ptList.Add(e.X);
ptList.Add(e.Y);
g.DrawRectangle(px, new Rectangle(e.X, e.Y, 1, 1));
}
Pen px = new Pen(Brushes.Red);
Pen newpx = new Pen(Brushes.Magenta);
Graphics g;
private void button1_Click(object sender, EventArgs e)
{
// how many points do you need on the curve?
const int POINTS_ON_CURVE = 1000;
double[] ptind = new double[ptList.Count];
double[] p = new double[POINTS_ON_CURVE];
ptList.CopyTo(ptind, 0);
bc.Bezier2D(ptind, (POINTS_ON_CURVE) / 2, p);
//pictureBox1.Refresh();
// draw points
for (int i = 1; i != POINTS_ON_CURVE-1; i += 2)
{
g.DrawRectangle(newpx, new Rectangle((int)p[i + 1], (int)p[i], 1, 1));
g.Flush();
Application.DoEvents();
}
}
private void Form1_Load(object sender, EventArgs e)
{
g = Graphics.FromHwnd(pictureBox1.Handle);
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Currently, also an MSc. student in Technical University of Munich, I develop practical application in computer vision for more than 5 years. I design real-time solutions to industrial and practical vision problems, both 3D and 2D. Very interested in developing algorithms in C relating math and vision.
Please visit Gravi's web page (http://www.gravi.com.tr) and my page (http://www.tbirdal.me) to learn more about what we develop.
I admire performance in algorithms.
"Great minds never die, they just tend to infinity..."