Skip to content

Commit 9fe3c33

Browse files
committed
remove strength multiplication in smoothing function
1 parent 9f579cb commit 9fe3c33

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

internal/blobs.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ export const genBlob = (points: number, offset: () => number): Shape => {
2020
}
2121

2222
// https://math.stackexchange.com/a/873589/235756
23-
const smoothingStrength = ((4 / 3) * Math.tan(angle / 4)) / Math.sin(angle / 2);
23+
const smoothingStrength = ((4 / 3) * Math.tan(angle / 4)) / Math.sin(angle / 2) / 2;
2424

2525
return smooth(shape, smoothingStrength);
2626
};

internal/util.ts

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,7 @@ export const insertCount = (count: number, a: Point, b: Point): Shape => {
103103
// Smooths out the path made up of the given points.
104104
// Existing handles are ignored.
105105
export const smooth = (shape: Shape, strength: number): Shape => {
106-
if (shape.length < 3) throw new Error("not enough points to smooth shape");
107-
108106
const out: Shape = [];
109-
110107
for (let i = 0; i < shape.length; i++) {
111108
const curr = shape[i];
112109
const before = shape[mod(i - 1, shape.length)];
@@ -118,15 +115,14 @@ export const smooth = (shape: Shape, strength: number): Shape => {
118115
y: curr.y,
119116
handleIn: {
120117
angle: angle + Math.PI,
121-
length: strength * (1 / 2) * distance(curr, before),
118+
length: strength * distance(curr, before),
122119
},
123120
handleOut: {
124121
angle,
125-
length: strength * (1 / 2) * distance(curr, after),
122+
length: strength * distance(curr, after),
126123
},
127124
});
128125
}
129-
130126
return out;
131127
};
132128

0 commit comments

Comments
 (0)