Closed francoisthire closed 6 months ago
Aren't these easily implementable via the current API ?
I may have missed something, but I don't think so.
For example, let's take the SVG commands s
or S
in the simple case when the command is followed by two points (generally, it could be a list of two points). S c2 y
defines a new cubic Bezier curve defined by the 4-uples (x,c1,c2,y)
where 'x' is the last point of the path, and c1
is the reflection of the second control point of the last Bezier curve with relatively to the point x
(see SVG path specification).
With the current API, it is easy to get x
using Vg.P.last_pt
, however, it is not easy to get c1
easily if I am not mistaken: One must go through the path using Vg.P.fold
or maintain a wrapper on top of Vg.P.t
to remember the second control point of Bezier curves.
Moreover, in the case of the command s
where points are defined relatively from the last point, it can be tricky to get c1
right.
The SVG specification specifies what should be c1
if the last element of the path is not a cubic Bezier curve.
Besides s
and S
, there are also t
and T
for quadratic curves.
I would be happy to write a PR if you think it is worth it. For example implementing derived path functions such as:
val smooth_ccurve : ?rel:bool -> Gg.p2 -> Gg.p2 -> path -> path
val smooth_qcurve : ?rel:bool -> Gg.p2 -> path -> path
Okay then. I'm happy with a PR.
Solved by #34. Thanks.
The SVG path format support also supports constructions such as
s
,S
,t
,T
. Those constructions enable smooth curves so that the one control point can be computed from the previous curve in the path. It would be interesting that theVg.P
module also exports smart constructors supporting those SVG constructions.