SVG path commands "s" and "t"

When implementing the "s" (relative cubic Bezier arc) and "t" (relative quadratic Bezier arc), the commands are the coordinates of an implicitly defined control point used as a base for the next relative coordinate or not?

In other words, consider the following cubic arc:

cubic arc example

  • cp current point
  • ip implicit control point computed mirroring of the last control point from the previous arc
  • ep explicit breakpoint
  • fp end point of the arc

Should the relative coordinates of ep be used as the base ip (implicit point) or should be relative to cp (current waypoint)?

In the official documentation, I found this unclear and there is no example using relative coordinates in these cases.

+7
source share
2 answers

The documentation states that in upper case S, absolute coordinates are expected, and in lower case s expects relative coordinates. Similar for T (absolute) and t (relative).

EDIT - relative to the current point - sorry, should have been explicit. The same document associated with the above includes the following:

For relative versions of commands, all coordinate values ​​refer to the current point at the beginning of the command

+2
source

rules

  • When using relative mode, the coordinates refer to the current point at the beginning of the command

  • In the case of the chain command, when several coordinates are specified without repeating the command, the base point is updated after each repetition

For example, a simple way

 m 100,100 100,0 0,100 -100,0 0,-100 

describes a square from (100, 100) to (200 200)

simple relative path

(the l "line-to" command shown in red is implicit if there are several coordinate pairs for the m command)

It is important to note that the relative β€œbase” for coordinates is updated at each pivot point. This is somewhat misleading in the documentation, because the syntax of the m command is described as taking (x,y)+ as a parameter, so the reader could be fooled into thinking that the relative base will change only at the end of the whole sequence of points.

Now consider the Bezier Cubic Path

 m 100,100 c 25,25 75,25 100,0 s 25,125 0,100 -75,-25 -100,0 

bezier arcs example

The two red control points are calculated automatically, mirroring the last control point. The red s command is implicit, because four s points follow it.

For a cubic Bezier arc command, two control points and an end point refer to the same starting point (they do not belong to the previous sequence), but the base point is updated on each arc to calculate relative coordinates.

+8
source