Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how SVG curveTo ( C ) works?

Tags:

math

svg

bezier

I need your help , I am confused a little.

My question is how SVG curveTo works, really I can't understand.

look for this example

<svg height="400" width="400">
 <path d="M 200 90 C 200  90 0 0 90  300 " stroke="black" fill="none" stroke-width="3"/>
</svg>

this code draws this shape

enter image description here

but really I can't understand how that done , I can't understand how the curve identified and what control points are and what 0 0 coordinate represents in my example.

like image 884
Mohamad Haidar Avatar asked Jun 08 '14 10:06

Mohamad Haidar


People also ask

How does a SVG path work?

A path is defined in SVG using the 'path' element. The basic shapes are all described in terms of what their equivalent path is, which is what their shape is as a path. (The equivalent path of a 'path' element is simply the path itself.)

How do you draw a curved line in SVG?

The other type of curved line that can be created using SVG is the arc, called with the A command. Arcs are sections of circles or ellipses. For a given x-radius and y-radius, there are two ellipses that can connect any two points (as long as they're within the radius of the circle).

What is d attribute in SVG?

The d attribute defines a path to be drawn. A path definition is a list of path commands where each command is composed of a command letter and numbers that represent the command parameters.

Which of the following command path paths creates cubic Bezier curves?

These three groups of commands draw curves: Cubic Bézier commands (C, c, S and s). A cubic Bézier segment is defined by a start point, an end point, and two control points.


2 Answers

You are drawing a Cubic Bezier curve (with two control points). But one of the control points has the same coordinates as the starting point.

  1. Move (M) to (200,90).
  2. Draw a Cubic (C) Bezier Curve

    a. starting at current position (200,90)
    b. first control point at (200,90) - same as starting point
    c. second control point at (0,0)
    d. ending at (90,300)

like image 57
helderdarocha Avatar answered Oct 01 '22 22:10

helderdarocha


Bezier curves are a bit tricky to get the sense of. Perhaps the section at http://www.w3.org/Graphics/SVG/IG/resources/svgprimer.html#path_C might help, and maybe the section before that on quadratic Beziers. As the earlier poster pointed out, having your start point and the control point coincident makes your case a bit odder, still, perhaps.

like image 23
user3665322 Avatar answered Oct 01 '22 21:10

user3665322