When implementing "s"
(relative cubic Bezier arc) and "t"
(relative quadratic Bezier arc) commands are the coordinates of the implicitly defined control point used as base for next relative coordinate or not?
In other words consider the following cubic arc:
cp
current pointip
implicit control point computed mirroring last control point from previous arcep
explicit control pointfp
final point of the arcShould be the relative coordinates of ep
use as base ip
(the implicit point) or should they be relative to cp
(the current point of the path)?
In the official documentation I found this unclear and no example using relative coordinates in these cases.
The rules are
When using relative mode the coordinates are relative to the current point at the start of the command
In case of a command "chain" when multiple coordinates are given without repeating the command the base point is updated after each repetition
For example the simple path
m 100,100 100,0 0,100 -100,0 0,-100
describes a square from (100,100) to (200,200)
(the l
"line-to" command shown in red is implicit if multiple coordinates pairs are provided for a "m" command)
The important point to note is that the relative "base" for coordinates is updated at each turning point. This is somewhat deceiving in the documentation because the syntax of m
command is described as accepting (x,y)+
as parameter so the reader could be tricked into thinking that the relative base will change only at the end of the entire sequence of points.
Now let's consider the Bezier cubic path
m 100,100 c 25,25 75,25 100,0 s 25,125 0,100 -75,-25 -100,0
The two red control points are computed automatically by mirroring the last control point. The red s
command is implicit because four points followed s
.
For a cubic Bezier arc command the two control points and the end point are relative to the same start point (they're not relative to the previous in sequence) but at each arc the base point for relative coordinate computation is updated.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With