feat: preserve vertices on roughness < 2

This commit is contained in:
dwelle 2023-06-07 18:36:31 +02:00
parent 84bd9bd4ff
commit 776e5a1cc8
2 changed files with 10 additions and 2 deletions

View File

@ -263,6 +263,12 @@ export const ROUNDNESS = {
* collaboration */
export const PRECEDING_ELEMENT_KEY = "__precedingElement__";
export const ROUGHNESS = {
architect: 0,
artist: 1,
cartoonist: 2,
} as const;
export const DEFAULT_ELEMENT_PROPS: {
strokeColor: ExcalidrawElement["strokeColor"];
backgroundColor: ExcalidrawElement["backgroundColor"];
@ -278,7 +284,7 @@ export const DEFAULT_ELEMENT_PROPS: {
fillStyle: "hachure",
strokeWidth: 1,
strokeStyle: "solid",
roughness: 1,
roughness: ROUGHNESS.artist,
opacity: 100,
locked: false,
};

View File

@ -36,6 +36,7 @@ import {
BOUND_TEXT_PADDING,
MAX_DECIMALS_FOR_SVG_EXPORT,
MIME_TYPES,
ROUGHNESS,
SVG_NS,
} from "../constants";
import { getStroke, StrokeOptions } from "perfect-freehand";
@ -416,7 +417,8 @@ export const generateRoughOptions = (
hachureGap: element.strokeWidth * 4,
roughness: element.roughness,
stroke: element.strokeColor,
preserveVertices: continuousPath,
preserveVertices:
continuousPath || element.roughness < ROUGHNESS.cartoonist,
};
switch (element.type) {