Avoid in-place modifications when expanding contours

This commit is contained in:
be5invis 2021-07-31 13:38:15 -07:00
parent 1bd83fe9ca
commit fe35f3dff7

View file

@ -128,13 +128,15 @@ class DiSpiroGeometry extends GeometryBase {
asContours() {
if (this.m_cachedContours) return this.m_cachedContours;
const { lhs, rhs } = this.expand();
const expandResult = this.expand();
const lhs = [...expandResult.lhs];
const rhs = [...expandResult.rhs];
let rawGeometry;
if (this.m_closed) {
rawGeometry = new CombineGeometry([
new SpiroGeometry(Transform.Id(), this.m_closed, lhs.slice(0, -1)),
new SpiroGeometry(Transform.Id(), this.m_closed, rhs.reverse().slice(0, -1))
new SpiroGeometry(Transform.Id(), true, lhs.slice(0, -1)),
new SpiroGeometry(Transform.Id(), true, rhs.reverse().slice(0, -1))
]);
} else {
lhs[0].type = lhs[lhs.length - 1].type = "corner";