Search code examples
svglanguage-lawyerbezier

SVG "Smooth curve" clarification


In the W3C standard for SVGs, I read for 'S' and 's':

(x2 y2 x y)+

Draws a cubic Bézier curve from the current point to (x,y). The first control point is assumed to be the reflection of the second control point on the previous command relative to the current point. (If there is no previous command or if the previous command was not an C, c, S or s, assume the first control point is coincident with the current point.) (x2,y2) is the second control point (i.e., the control point at the end of the curve). S (uppercase) indicates that absolute coordinates will follow; s (lowercase) indicates that relative coordinates will follow. Multiple sets of coordinates may be specified to draw a polybézier. At the end of the command the new current point becomes the final (x,y) coordinate pair used in the polybézier.

In the case of a polybezier, does the "current point" or "previous command" change during this subpath?

In other words, does implicitly calculated first control point ever change during a S or s subpath if multiple sets of coordinates are specified?

The standard says "at the end of the [S or s] command", so I suspect not.


Solution

  • I'm not sure I understand what you are asking, or what you mean by "change".

    The following example:

    M 0,0 S 100,100, 120,120, 200,200, 220,220
    

    is considered to be a shorthand for:

    M 0,0 S 100,100, 120,120 S 200,200, 220,220
    

    So when you get to the second set of S coordinates (the 200s), the "previous command" is considered to be the "S 100,100 120,120", not the "M 0,0".

    Is that what you are asking?