Skip to content

Commit

Permalink
#27 SVG spline interpolation count is proportional to number of contr…
Browse files Browse the repository at this point in the history
…ol points - improves SVG fidelity for large splines
  • Loading branch information
bjnortier committed Jul 12, 2018
1 parent 0a67047 commit 6424faf
Show file tree
Hide file tree
Showing 4 changed files with 21,493 additions and 4 deletions.
8 changes: 6 additions & 2 deletions src/entityToPolyline.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,8 +199,12 @@ module.exports = function (entity) {
const order = entity.degree + 1
const knots = entity.knots
polyline = []
for (let t = 0; t <= 100; t += 1) {
const p = bspline(t / 100, order, controlPoints, knots)
// In trying to keep the polyline size to a reasonable value,
// the number of interpolated points is proportional to the
// number of control points
const numInterpolations = controlPoints.length * 100
for (let t = 0; t <= numInterpolations; t += 1) {
const p = bspline(t / numInterpolations, order, controlPoints, knots)
polyline.push(p)
}
}
Expand Down
1 change: 1 addition & 0 deletions test/functional/svgentities.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,5 @@ describe('svg entities', function () {
createTest('floorplan')
createTest('Ceco.NET-Architecture-Tm-53')
createTest('issue21')
createTest('issue27')
})
Loading

0 comments on commit 6424faf

Please sign in to comment.