update CHANGELOG with new version

This commit is contained in:
Anton Lavrenov
2020-02-16 07:39:42 -05:00
parent 2d04edef7e
commit 396297bdfc
5 changed files with 137 additions and 23 deletions

View File

@@ -104,12 +104,60 @@ export class Path extends Shape<PathConfig> {
var points = [];
this.dataArray.forEach(function(data) {
if (data.command === 'A') {
points = points.concat([
data.points[0] - data.points[2],
data.points[1] - data.points[3],
data.points[0] + data.points[2],
data.points[1] + data.points[3]
])
// Approximates by breaking curve into line segments
var start = data.points[4];
// 4 = theta
var dTheta = data.points[5];
// 5 = dTheta
var end = data.points[4] + dTheta;
var inc = Math.PI / 180.0;
// 1 degree resolution
if (Math.abs(start - end) < inc) {
inc = Math.abs(start - end);
}
if (dTheta < 0) {
// clockwise
for (let t = start - inc; t > end; t -= inc) {
const point = Path.getPointOnEllipticalArc(
data.points[0],
data.points[1],
data.points[2],
data.points[3],
t,
0
);
points.push(point.x, point.y);
}
} else {
// counter-clockwise
for (let t = start + inc; t < end; t += inc) {
const point = Path.getPointOnEllipticalArc(
data.points[0],
data.points[1],
data.points[2],
data.points[3],
t,
0
);
points.push(point.x, point.y);
}
}
} else if (data.command === 'C') {
// Approximates by breaking curve into 100 line segments
for (let t = 0.0; t <= 1; t += 0.01) {
const point = Path.getPointOnCubicBezier(
t,
data.start.x,
data.start.y,
data.points[0],
data.points[1],
data.points[2],
data.points[3],
data.points[4],
data.points[5]
);
points.push(point.x, point.y);
}
} else {
// TODO: how can we calculate bezier curves better?
points = points.concat(data.points);