feat: Better rendering of curved rectangles (#3562)

This commit is contained in:
Preet 2021-05-10 03:41:17 -07:00 committed by GitHub
parent 11b8cc2caa
commit f4fefbcee8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 6 deletions

View file

@ -228,7 +228,10 @@ export const getShapeForElement = (element: ExcalidrawElement) =>
export const invalidateShapeForElement = (element: ExcalidrawElement) =>
shapeCache.delete(element);
export const generateRoughOptions = (element: ExcalidrawElement): Options => {
export const generateRoughOptions = (
element: ExcalidrawElement,
continuousPath = false,
): Options => {
const options: Options = {
seed: element.seed,
strokeLineDash:
@ -253,6 +256,7 @@ export const generateRoughOptions = (element: ExcalidrawElement): Options => {
hachureGap: element.strokeWidth * 4,
roughness: element.roughness,
stroke: element.strokeColor,
preserveVertices: continuousPath,
};
switch (element.type) {
@ -314,7 +318,7 @@ const generateElementShape = (
} Q ${w} ${h}, ${w - r} ${h} L ${r} ${h} Q 0 ${h}, 0 ${
h - r
} L 0 ${r} Q 0 0, ${r} 0`,
generateRoughOptions(element),
generateRoughOptions(element, true),
);
} else {
shape = generator.rectangle(