Click here to Skip to main content
13,351,971 members (80,166 online)
Click here to Skip to main content


96 bookmarked
Posted 14 Apr 2008

Bezier Curves Made Simple

, 14 Apr 2008
A simple implementation of the famous Bezier curves in C#. Easy to understand.
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()

        private void pictureBox1_MouseClick(object sender, MouseEventArgs e)

            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);

            // 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));

        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.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Tolga Birdal
CEO Gravi Information Technologies and Consultancy Ltd
Turkey Turkey
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 ( and my page ( to learn more about what we develop.

I admire performance in algorithms.

"Great minds never die, they just tend to infinity..."

You may also be interested in...

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.180111.1 | Last Updated 14 Apr 2008
Article Copyright 2008 by Tolga Birdal
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid