Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
CSharp_Graphics.doc
Скачиваний:
20
Добавлен:
16.11.2019
Размер:
3.1 Mб
Скачать

Изменение изгиба фундаментального сплайна

  • Чтобы изменить изгиб фундаментального сплайна, необходимо передать методу DrawCurve нужное значение параметра натяжения. В следующем примере показано, как можно нарисовать три фундаментальных сплайна, которые проходят через один и тот же набор точек. На следующем рисунке представлены три сплайна вместе с соответствующими значениями параметра натяжения. Обратите внимание, что в случае, когда параметр натяжения равен 0, точки соединяются прямыми линиями.

-----

Компиляция кода

Предыдущий пример предназначен для работы с Windows Forms, для него необходим объект PaintEventArgs e, передаваемый в качестве параметра обработчику события Paint.

How to: Draw a Single Bézier Spline

A Bézier spline is defined by four points: a start point, two control points, and an endpoint.

Example

The following example draws a Bézier spline with start point (10, 100) and endpoint (200, 100). The control points are (100, 10) and (150, 150).

The following illustration shows the resulting Bézier spline along with its start point, control points, and endpoint. The illustration also shows the spline's convex hull, which is a polygon formed by connecting the four points with straight lines.

Point p1 = new Point(10, 100); // Start point

Point c1 = new Point(100, 10); // First control point

Point c2 = new Point(150, 150); // Second control point

Point p2 = new Point(200, 100); // Endpoint

Pen pen = new Pen(Color.FromArgb(255, 0, 0, 255));

e.Graphics.DrawBezier(pen, p1, c1, c2, p2);

Compiling the Code

The preceding example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler.

Рисование отдельного сплайна Безье

Сплайн Безье задается четырьмя точками: начальной, двумя контрольными и конечной.

Пример

В приведенном ниже примере демонстрируется рисование сплайна Безье из начальной точки с координатами (10, 100) в конечную точку с координатами (200, 200), если контрольные точки имеют координаты (100, 10) и (150, 150).

На следующем рисунке показаны получившийся сплайн Безье, а также его начальная точка, конечная точка и контрольные точки. Также показана выпуклая оболочка сплайна, которая представляет собой многоугольник, получаемый при соединении четырех указанных точек отрезками прямых.

----

Компиляция кода

Предыдущий пример предназначен для работы с Windows Forms, для него необходим объект PaintEventArgs e, передаваемый в качестве параметра обработчику события Paint.

How to: Draw a Sequence of Bézier Splines

You can use the DrawBeziers method of the Graphics class to draw a sequence of connected Bézier splines.

Example

The following example draws a curve that consists of two connected Bézier splines. The endpoint of the first Bézier spline is the start point of the second Bézier spline.

The following illustration shows the connected splines along with the seven points.

Point[] p = {

new Point(10, 100), // start point of first spline

new Point(75, 10), // first control point of first spline

new Point(80, 50), // second control point of first spline

new Point(100, 150), // endpoint of first spline and

// start point of second spline

new Point(125, 80), // first control point of second spline

new Point(175, 200), // second control point of second spline

new Point(200, 80)}; // endpoint of second spline

Pen pen = new Pen(Color.Blue);

e.Graphics.DrawBeziers(pen, p);

Compiling the Code

The preceding example is designed for use with Windows Forms, and it requires PaintEventArgs e, which is a parameter of the Paint event handler.