improve miter
This commit is contained in:
@@ -1258,6 +1258,7 @@ const getSvgPathFromPoints = (
|
|||||||
|
|
||||||
const FIXED_FREEDRAW_MIN_SMOOTH_ALIGNMENT = 0.6;
|
const FIXED_FREEDRAW_MIN_SMOOTH_ALIGNMENT = 0.6;
|
||||||
const FIXED_FREEDRAW_MIN_SMOOTH_SEGMENT_LENGTH = 0.2;
|
const FIXED_FREEDRAW_MIN_SMOOTH_SEGMENT_LENGTH = 0.2;
|
||||||
|
const FIXED_FREEDRAW_MIN_CORNER_ALIGNMENT = -0.25;
|
||||||
const FIXED_FREEDRAW_MIN_CORNER_ROUNDING = 0.75;
|
const FIXED_FREEDRAW_MIN_CORNER_ROUNDING = 0.75;
|
||||||
const FIXED_FREEDRAW_MAX_CORNER_ROUNDING = 6;
|
const FIXED_FREEDRAW_MAX_CORNER_ROUNDING = 6;
|
||||||
const FIXED_FREEDRAW_CORNER_ROUNDING_FACTOR = 0.35;
|
const FIXED_FREEDRAW_CORNER_ROUNDING_FACTOR = 0.35;
|
||||||
@@ -1310,7 +1311,10 @@ const getFixedFreeDrawRoundedCorner = (
|
|||||||
(previousDeltaX * nextDeltaX + previousDeltaY * nextDeltaY) /
|
(previousDeltaX * nextDeltaX + previousDeltaY * nextDeltaY) /
|
||||||
(previousSegmentLength * nextSegmentLength);
|
(previousSegmentLength * nextSegmentLength);
|
||||||
|
|
||||||
if (alignment >= FIXED_FREEDRAW_MIN_SMOOTH_ALIGNMENT) {
|
if (
|
||||||
|
alignment >= FIXED_FREEDRAW_MIN_SMOOTH_ALIGNMENT ||
|
||||||
|
alignment <= FIXED_FREEDRAW_MIN_CORNER_ALIGNMENT
|
||||||
|
) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,19 @@ describe("freedraw stroke shape", () => {
|
|||||||
expect(path).toBe("M0,0 L8.5,0 Q10,0 10,1.5 L10,10 ");
|
expect(path).toBe("M0,0 L8.5,0 Q10,0 10,1.5 L10,10 ");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("does not round fixed stroke hairpin turns", () => {
|
||||||
|
const element = API.createElement({
|
||||||
|
type: "freedraw",
|
||||||
|
strokeShape: "fixed",
|
||||||
|
strokeWidth: 1,
|
||||||
|
points: [pointFrom(0, 0), pointFrom(10, 0), pointFrom(9, 1)],
|
||||||
|
});
|
||||||
|
|
||||||
|
const [path] = ShapeCache.generateElementShape(element, null);
|
||||||
|
|
||||||
|
expect(path).toBe("M0,0 L10,0 L9,1 ");
|
||||||
|
});
|
||||||
|
|
||||||
it("smooths dense fixed stroke points without dropping them", () => {
|
it("smooths dense fixed stroke points without dropping them", () => {
|
||||||
const element = API.createElement({
|
const element = API.createElement({
|
||||||
type: "freedraw",
|
type: "freedraw",
|
||||||
|
|||||||
Reference in New Issue
Block a user