CPSC 170 Post Lab 6
Bézier Curves
Due Before Class on Tuesday, February 28th

A Bézier curve is a method for representing curves popularized by the French engineer Pierre Bézier in the 1960's. Bézier used the curves in the design automobiles. The curves are still popular today in drawing and animation applications because they offer an intuitive control over curve shape. Bézier curves can also be approximated very easily using a recursive algorithm developed another Frenchman, Paul de Casteljau. You are going to create a program that allows users to draw a Bézier curve.

Details

Modify your drawing program from post-lab 2 to include a Bézier curve tool. If you would prefer, you can modify the drawing program in the zip file Drawing.zip. When the Bézier curve tool is selected, clicks on the drawing area should add control points. Each time a control point is added the display should update to reflect the changes in the Bézier curve currently being drawn. If the user double clicks (or just clicks in the same location twice in a row), no more points should be added to the curve currently being drawn. If the user clicks again, after the double click, while the Bézier curve tool is selected, a new Bézier curve should be created.

In order to draw a Bézier curve, you need to calculate a series of points on the curve. You can use the de Casteljau method you created in the sub-post-lab to calculate an arbitrary number of evenly spaced points on the curve. Then, draw lines between each pair of consecutive points, to draw the curve. The number of points on the curve that are calculated should be stored in a constant instance variable. The program does not need to draw the control points or the control structure, just the curve.


Submission: Submit your code as a zip file with your name as the zip file name on the course Inquire site.

Movable Control Points

Add the ability to modify a Bézier curve after it has been drawn by dragging its control points. Modify the program to draw the control points of a curve as small rectangles and add a new button to the drawing program for moving control points. When the move tool is selected and the user clicks and drags a control point the point should follow the mouse and redraw the curve.