spline-research
spline-research copied to clipboard
Closed all-smooth shapes not smooth
The following closed shape with three smooth point and no tangents doesn't appear smooth at the first point:
{"subpaths":[{"closed":true,"pts":[{"x":223.86,"y":168.2,"c":1},{"x":483.06,"y":64.2,"c":1},{"x":491.86,"y":273,"c":1}]}]}
Whereas setting explicit tangents on one point makes all points properly smooth.
{"subpaths":[{"closed":true,"pts":[{"x":223.86,"y":168.2,"c":1},{"x":483.06,"y":64.2,"c":1},{"x":491.86,"y":273,"c":1,"t":2.393}]}]}
I think a fix is to average the first and last ths after fixing endpoint tangents in iterdumb:
let avgth = (_ths[0] + _ths[n - 1]) / 2.
_ths[0] = avgth
_ths[n - 1] = avgth
}