polybezier

This function is used to draw three square Bezier curves.

void polybezier(
	const POINT *points,
	int num
);

Parameters

points

Describes the coordinate points of the three square Bezier curves. The coordinates are: starting point, control point 1, control point 2, end point (start point), control point 1, control point 2, end point (start point) 、......、 control point 2, end point 2, end point.

num

The number of coordinate points. Because it takes 4 points to describe a three-sided Bezier curve, and the starting point of the latter Bezier curve is the same as the end point of the previous one, it is important to ensure (num - 1) 3 s 0.

Return Value

None

Remarks

Each three square bezier curve consists of 4 points: starting point, control point 1, control point 2, end point. The Bezier curve draws from the starting point to the end, and the shape is affected by control point 1 and control point 2.

The starting point of the next Bezier curve is the end point of the previous one. If you want the connection points of the front and back two Bezier curves to be smooth, make sure that the three points are in the same line: the control point 2 of the previous one, the end point of the previous one (the starting point of the last), and the control point 1 of the last one.

This pattern will not be filled.

Examples

The following code draws two consecutive Bezier curves:

#include <graphics.h> 
#include <conio.h>

int main()
{ 
	initgraph(640, 480);	// Initialize the graphics window
	
	//				start		control 1	control 2	end/start	control 1	control 2	end
	POINT pts[] = {	{150, 200}, {160, 150}, {240, 150}, {250, 100}, {260, 150}, {340, 150}, {350, 200} };

	setlinecolor(DARKGRAY);
	polyline(pts, 7);		// Draw seven gray auxiliary lines

	setlinecolor(GREEN);
	polybezier(pts, 7);		// Draw two green Bezier curves

	getch();				// Press any key to exit
	closegraph();

	return 0;
}