XML technologies / SVG / Using complex graphic elements and formatting / Using paths correctly / Creating Bézier curves / The C command

(Excerpt from “Das Einsteigerseminar SVG — Webgrafiken mit XML” by Helma Spona)

The C command draws cubic Bézier curves. Its syntax is:

C x1 y1 x2 y2 x y

Here, x and y specify the line’s endpoint. The point x1/y1 sets the control point at the line’s start, and x2/y2 the control point at its end.

The two control points determine the curve’s bend. They define imaginary guide lines, always running from the control points to the line’s start or end.

The instruction

<path d="M100 100 C150 0 250 200 350 100" style="stroke:rgb(0,0,0);stroke-width:3;fill:none"/>

draws the Bézier curve shown in the following figure, which also displays guide lines and control points for clarity.

Bézier curve created with the C command

Figure: Bézier curve created with the C command.

Move the control points to change the curve’s shape. The following figure shows the result of moving the right control point farther right and the left one farther left. The old gray line and new black line are superimposed to clarify the changes.

Changing the Bézier curve by moving its control points

Figure: Changing the Bézier curve by moving its control points.

   

 

 

 

back to top