ajust roughness to size
This commit is contained in:
parent
725c3bafe1
commit
68e8636782
@ -389,6 +389,15 @@ export const setShapeForElement = <T extends ExcalidrawElement>(
|
|||||||
export const invalidateShapeForElement = (element: ExcalidrawElement) =>
|
export const invalidateShapeForElement = (element: ExcalidrawElement) =>
|
||||||
shapeCache.delete(element);
|
shapeCache.delete(element);
|
||||||
|
|
||||||
|
function adjustRoughness(size: number, roughness: number): number {
|
||||||
|
if (size >= 50) {
|
||||||
|
return roughness;
|
||||||
|
}
|
||||||
|
const factor = 2 + (50 - size) / 10;
|
||||||
|
|
||||||
|
return roughness / factor;
|
||||||
|
}
|
||||||
|
|
||||||
export const generateRoughOptions = (
|
export const generateRoughOptions = (
|
||||||
element: ExcalidrawElement,
|
element: ExcalidrawElement,
|
||||||
continuousPath = false,
|
continuousPath = false,
|
||||||
@ -415,7 +424,10 @@ export const generateRoughOptions = (
|
|||||||
// calculate them (and we don't want the fills to be modified)
|
// calculate them (and we don't want the fills to be modified)
|
||||||
fillWeight: element.strokeWidth / 2,
|
fillWeight: element.strokeWidth / 2,
|
||||||
hachureGap: element.strokeWidth * 4,
|
hachureGap: element.strokeWidth * 4,
|
||||||
roughness: element.roughness,
|
roughness: adjustRoughness(
|
||||||
|
Math.min(element.width, element.height),
|
||||||
|
element.roughness,
|
||||||
|
),
|
||||||
stroke: element.strokeColor,
|
stroke: element.strokeColor,
|
||||||
preserveVertices:
|
preserveVertices:
|
||||||
continuousPath || element.roughness < ROUGHNESS.cartoonist,
|
continuousPath || element.roughness < ROUGHNESS.cartoonist,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user