|
@@ -389,6 +389,16 @@ export const setShapeForElement = <T extends ExcalidrawElement>(
|
|
|
export const invalidateShapeForElement = (element: ExcalidrawElement) =>
|
|
|
shapeCache.delete(element);
|
|
|
|
|
|
+function adjustRoughness(size: number, roughness: number): number {
|
|
|
+ if (size >= 50) {
|
|
|
+ return roughness;
|
|
|
+ }
|
|
|
+ const factor = 2 + (50 - size) / 10;
|
|
|
+
|
|
|
+ // console.log({ ret: roughness / factor, roughness, factor, size });
|
|
|
+ return roughness / factor;
|
|
|
+}
|
|
|
+
|
|
|
export const generateRoughOptions = (
|
|
|
element: ExcalidrawElement,
|
|
|
continuousPath = false,
|
|
@@ -415,7 +425,10 @@ export const generateRoughOptions = (
|
|
|
// calculate them (and we don't want the fills to be modified)
|
|
|
fillWeight: element.strokeWidth / 2,
|
|
|
hachureGap: element.strokeWidth * 4,
|
|
|
- roughness: element.roughness,
|
|
|
+ roughness: adjustRoughness(
|
|
|
+ Math.min(element.width, element.height),
|
|
|
+ element.roughness,
|
|
|
+ ),
|
|
|
stroke: element.strokeColor,
|
|
|
preserveVertices: continuousPath,
|
|
|
};
|