feat: renderer tweaks (#6698)

This commit is contained in:
David Luzar 2023-10-20 17:45:37 +02:00 committed by GitHub
parent d2a508104e
commit afea0df141
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 1075 additions and 1127 deletions

View File

@ -296,6 +296,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"];
@ -308,10 +314,10 @@ export const DEFAULT_ELEMENT_PROPS: {
} = {
strokeColor: COLOR_PALETTE.black,
backgroundColor: COLOR_PALETTE.transparent,
fillStyle: "hachure",
strokeWidth: 1,
fillStyle: "solid",
strokeWidth: 2,
strokeStyle: "solid",
roughness: 1,
roughness: ROUGHNESS.artist,
opacity: 100,
locked: false,
};

View File

@ -14,7 +14,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"type": "arrow",
},
],
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 300,
@ -28,7 +28,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"seed": Any<Number>,
"strokeColor": "#66a80f",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "ellipse",
"updated": 1,
"version": 3,
@ -49,7 +49,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"type": "arrow",
},
],
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 100,
@ -63,7 +63,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"seed": Any<Number>,
"strokeColor": "#9c36b5",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "diamond",
"updated": 1,
"version": 2,
@ -85,7 +85,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"focus": -0.008153707962747813,
"gap": 1,
},
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 35,
@ -116,7 +116,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
},
"strokeColor": "#1864ab",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 3,
@ -138,7 +138,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"focus": 0.10666666666666667,
"gap": 3.834326468444573,
},
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 0,
@ -169,7 +169,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
},
"strokeColor": "#e67700",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 3,
@ -190,7 +190,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"type": "arrow",
},
],
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 300,
@ -204,7 +204,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing s
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 2,
@ -227,7 +227,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
},
],
"containerId": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -245,7 +245,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
"seed": Any<Number>,
"strokeColor": "#c2255c",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "HEYYYYY",
"textAlign": "left",
"type": "text",
@ -271,7 +271,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
},
],
"containerId": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -289,7 +289,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "Whats up ?",
"textAlign": "left",
"type": "text",
@ -319,7 +319,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
"focus": 0,
"gap": 5,
},
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 0,
@ -350,7 +350,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
},
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 3,
@ -368,7 +368,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
"baseline": 0,
"boundElements": null,
"containerId": "id43",
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -386,7 +386,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to existing t
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "HELLO WORLD!!",
"textAlign": "center",
"type": "text",
@ -416,7 +416,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to shapes whe
"focus": 0,
"gap": 1,
},
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 0,
@ -447,7 +447,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to shapes whe
},
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 3,
@ -465,7 +465,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to shapes whe
"baseline": 0,
"boundElements": null,
"containerId": "id32",
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -483,7 +483,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to shapes whe
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "HELLO WORLD!!",
"textAlign": "center",
"type": "text",
@ -507,7 +507,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to shapes whe
"type": "arrow",
},
],
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 100,
@ -521,7 +521,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to shapes whe
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 2,
@ -542,7 +542,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to shapes whe
"type": "arrow",
},
],
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 100,
@ -556,7 +556,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to shapes whe
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "ellipse",
"updated": 1,
"version": 2,
@ -583,7 +583,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
"focus": 0,
"gap": 1,
},
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 0,
@ -614,7 +614,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
},
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 3,
@ -632,7 +632,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
"baseline": 0,
"boundElements": null,
"containerId": "id36",
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -650,7 +650,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "HELLO WORLD!!",
"textAlign": "center",
"type": "text",
@ -676,7 +676,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
},
],
"containerId": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -694,7 +694,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "HEYYYYY",
"textAlign": "left",
"type": "text",
@ -720,7 +720,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
},
],
"containerId": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -738,7 +738,7 @@ exports[`Test Transform > Test arrow bindings > should bind arrows to text when
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "WHATS UP ?",
"textAlign": "left",
"type": "text",
@ -757,7 +757,7 @@ exports[`Test Transform > should not allow duplicate ids 1`] = `
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 200,
@ -771,7 +771,7 @@ exports[`Test Transform > should not allow duplicate ids 1`] = `
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 1,
@ -789,7 +789,7 @@ exports[`Test Transform > should transform linear elements 1`] = `
"boundElements": null,
"endArrowhead": "arrow",
"endBinding": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 0,
@ -816,7 +816,7 @@ exports[`Test Transform > should transform linear elements 1`] = `
"startBinding": null,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 1,
@ -834,7 +834,7 @@ exports[`Test Transform > should transform linear elements 2`] = `
"boundElements": null,
"endArrowhead": "triangle",
"endBinding": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 0,
@ -879,7 +879,7 @@ exports[`Test Transform > should transform linear elements 3`] = `
"boundElements": null,
"endArrowhead": null,
"endBinding": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 0,
@ -906,7 +906,7 @@ exports[`Test Transform > should transform linear elements 3`] = `
"startBinding": null,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "line",
"updated": 1,
"version": 1,
@ -924,7 +924,7 @@ exports[`Test Transform > should transform linear elements 4`] = `
"boundElements": null,
"endArrowhead": null,
"endBinding": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 0,
@ -967,7 +967,7 @@ exports[`Test Transform > should transform regular shapes 1`] = `
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 100,
@ -981,7 +981,7 @@ exports[`Test Transform > should transform regular shapes 1`] = `
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 1,
@ -997,7 +997,7 @@ exports[`Test Transform > should transform regular shapes 2`] = `
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 100,
@ -1011,7 +1011,7 @@ exports[`Test Transform > should transform regular shapes 2`] = `
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "ellipse",
"updated": 1,
"version": 1,
@ -1027,7 +1027,7 @@ exports[`Test Transform > should transform regular shapes 3`] = `
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 100,
@ -1041,7 +1041,7 @@ exports[`Test Transform > should transform regular shapes 3`] = `
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "diamond",
"updated": 1,
"version": 1,
@ -1057,7 +1057,7 @@ exports[`Test Transform > should transform regular shapes 4`] = `
"angle": 0,
"backgroundColor": "#c0eb75",
"boundElements": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 100,
@ -1149,7 +1149,7 @@ exports[`Test Transform > should transform text element 1`] = `
"baseline": 0,
"boundElements": null,
"containerId": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -1167,7 +1167,7 @@ exports[`Test Transform > should transform text element 1`] = `
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "HELLO WORLD!",
"textAlign": "left",
"type": "text",
@ -1188,7 +1188,7 @@ exports[`Test Transform > should transform text element 2`] = `
"baseline": 0,
"boundElements": null,
"containerId": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -1206,7 +1206,7 @@ exports[`Test Transform > should transform text element 2`] = `
"seed": Any<Number>,
"strokeColor": "#5f3dc4",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "STYLED HELLO WORLD!",
"textAlign": "left",
"type": "text",
@ -1232,7 +1232,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
],
"endArrowhead": "arrow",
"endBinding": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 0,
@ -1259,7 +1259,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
"startBinding": null,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 1,
@ -1282,7 +1282,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
],
"endArrowhead": "arrow",
"endBinding": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 0,
@ -1309,7 +1309,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
"startBinding": null,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 1,
@ -1332,7 +1332,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
],
"endArrowhead": "arrow",
"endBinding": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 130,
@ -1382,7 +1382,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
],
"endArrowhead": "arrow",
"endBinding": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 130,
@ -1427,7 +1427,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
"baseline": 0,
"boundElements": null,
"containerId": "id24",
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -1445,7 +1445,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "LABELED ARROW",
"textAlign": "center",
"type": "text",
@ -1466,7 +1466,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
"baseline": 0,
"boundElements": null,
"containerId": "id25",
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -1484,7 +1484,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
"seed": Any<Number>,
"strokeColor": "#099268",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "STYLED LABELED ARROW",
"textAlign": "center",
"type": "text",
@ -1505,7 +1505,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
"baseline": 0,
"boundElements": null,
"containerId": "id26",
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -1523,7 +1523,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
"seed": Any<Number>,
"strokeColor": "#1098ad",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "ANOTHER STYLED
LABELLED ARROW",
"textAlign": "center",
@ -1545,7 +1545,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
"baseline": 0,
"boundElements": null,
"containerId": "id27",
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -1563,7 +1563,7 @@ exports[`Test Transform > should transform to labelled arrows when label provide
"seed": Any<Number>,
"strokeColor": "#099268",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "ANOTHER STYLED
LABELLED ARROW",
"textAlign": "center",
@ -1588,7 +1588,7 @@ exports[`Test Transform > should transform to text containers when label provide
"type": "text",
},
],
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 35,
@ -1602,7 +1602,7 @@ exports[`Test Transform > should transform to text containers when label provide
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 3,
@ -1623,7 +1623,7 @@ exports[`Test Transform > should transform to text containers when label provide
"type": "text",
},
],
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 85,
@ -1637,7 +1637,7 @@ exports[`Test Transform > should transform to text containers when label provide
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "ellipse",
"updated": 1,
"version": 2,
@ -1658,7 +1658,7 @@ exports[`Test Transform > should transform to text containers when label provide
"type": "text",
},
],
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 170,
@ -1672,7 +1672,7 @@ exports[`Test Transform > should transform to text containers when label provide
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "diamond",
"updated": 1,
"version": 2,
@ -1693,7 +1693,7 @@ exports[`Test Transform > should transform to text containers when label provide
"type": "text",
},
],
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 120,
@ -1728,7 +1728,7 @@ exports[`Test Transform > should transform to text containers when label provide
"type": "text",
},
],
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 85,
@ -1742,7 +1742,7 @@ exports[`Test Transform > should transform to text containers when label provide
"seed": Any<Number>,
"strokeColor": "#c2255c",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 2,
@ -1763,7 +1763,7 @@ exports[`Test Transform > should transform to text containers when label provide
"type": "text",
},
],
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 120,
@ -1777,7 +1777,7 @@ exports[`Test Transform > should transform to text containers when label provide
"seed": Any<Number>,
"strokeColor": "#f08c00",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "ellipse",
"updated": 1,
"version": 2,
@ -1795,7 +1795,7 @@ exports[`Test Transform > should transform to text containers when label provide
"baseline": 0,
"boundElements": null,
"containerId": "id12",
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -1813,7 +1813,7 @@ exports[`Test Transform > should transform to text containers when label provide
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "RECTANGLE TEXT CONTAINER",
"textAlign": "center",
"type": "text",
@ -1834,7 +1834,7 @@ exports[`Test Transform > should transform to text containers when label provide
"baseline": 0,
"boundElements": null,
"containerId": "id13",
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -1852,7 +1852,7 @@ exports[`Test Transform > should transform to text containers when label provide
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "ELLIPSE TEXT
CONTAINER",
"textAlign": "center",
@ -1874,7 +1874,7 @@ exports[`Test Transform > should transform to text containers when label provide
"baseline": 0,
"boundElements": null,
"containerId": "id14",
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -1893,7 +1893,7 @@ TEXT CONTAINER",
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "DIAMOND
TEXT
CONTAINER",
@ -1916,7 +1916,7 @@ exports[`Test Transform > should transform to text containers when label provide
"baseline": 0,
"boundElements": null,
"containerId": "id15",
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -1934,7 +1934,7 @@ exports[`Test Transform > should transform to text containers when label provide
"seed": Any<Number>,
"strokeColor": "#099268",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "STYLED DIAMOND
TEXT CONTAINER",
"textAlign": "center",
@ -1956,7 +1956,7 @@ exports[`Test Transform > should transform to text containers when label provide
"baseline": 0,
"boundElements": null,
"containerId": "id16",
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -1974,7 +1974,7 @@ exports[`Test Transform > should transform to text containers when label provide
"seed": Any<Number>,
"strokeColor": "#c2255c",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "TOP LEFT ALIGNED
RECTANGLE TEXT
CONTAINER",
@ -1997,7 +1997,7 @@ exports[`Test Transform > should transform to text containers when label provide
"baseline": 0,
"boundElements": null,
"containerId": "id17",
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 20,
"frameId": null,
@ -2015,7 +2015,7 @@ exports[`Test Transform > should transform to text containers when label provide
"seed": Any<Number>,
"strokeColor": "#c2255c",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "STYLED
ELLIPSE TEXT
CONTAINER",

View File

@ -1425,7 +1425,7 @@ describe("textWysiwyg", () => {
type: "text",
},
],
fillStyle: "hachure",
fillStyle: "solid",
groupIds: [],
height: 35,
isDeleted: false,
@ -1438,7 +1438,7 @@ describe("textWysiwyg", () => {
},
strokeColor: "#1e1e1e",
strokeStyle: "solid",
strokeWidth: 1,
strokeWidth: 2,
type: "rectangle",
updated: 1,
version: 1,

View File

@ -13,11 +13,21 @@ import { isPathALoop, getCornerRadius } from "../math";
import { generateFreeDrawShape } from "../renderer/renderElement";
import { isTransparent, assertNever } from "../utils";
import { simplify } from "points-on-curve";
import { ROUGHNESS } from "../constants";
const getDashArrayDashed = (strokeWidth: number) => [8, 8 + strokeWidth];
const getDashArrayDotted = (strokeWidth: number) => [1.5, 6 + strokeWidth];
function adjustRoughness(size: number, roughness: number): number {
if (size >= 50) {
return roughness;
}
const factor = 2 + (50 - size) / 10;
return roughness / factor;
}
export const generateRoughOptions = (
element: ExcalidrawElement,
continuousPath = false,
@ -44,9 +54,13 @@ 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,
preserveVertices:
continuousPath || element.roughness < ROUGHNESS.cartoonist,
};
switch (element.type) {

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"boundElements": null,
"endArrowhead": "arrow",
"endBinding": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 50,
@ -38,7 +38,7 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"startBinding": null,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 3,
@ -56,7 +56,7 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 50,
@ -72,7 +72,7 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"seed": 1278240551,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "diamond",
"updated": 1,
"version": 2,
@ -90,7 +90,7 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 50,
@ -106,7 +106,7 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"seed": 1278240551,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "ellipse",
"updated": 1,
"version": 2,
@ -124,7 +124,7 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"boundElements": null,
"endArrowhead": null,
"endBinding": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 50,
@ -153,7 +153,7 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"startBinding": null,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "line",
"updated": 1,
"version": 3,
@ -171,7 +171,7 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 50,
@ -187,7 +187,7 @@ exports[`Test dragCreate > add element to the scene when pointer dragging long e
"seed": 1278240551,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 2,

View File

@ -5,7 +5,7 @@ exports[`duplicate element on move when ALT is clicked > rectangle 1`] = `
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 50,
@ -21,7 +21,7 @@ exports[`duplicate element on move when ALT is clicked > rectangle 1`] = `
"seed": 1014066025,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 4,
@ -37,7 +37,7 @@ exports[`duplicate element on move when ALT is clicked > rectangle 2`] = `
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 50,
@ -53,7 +53,7 @@ exports[`duplicate element on move when ALT is clicked > rectangle 2`] = `
"seed": 1278240551,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 4,
@ -69,7 +69,7 @@ exports[`move element > rectangle 1`] = `
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 50,
@ -85,7 +85,7 @@ exports[`move element > rectangle 1`] = `
"seed": 1278240551,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 3,
@ -106,7 +106,7 @@ exports[`move element > rectangles with binding arrow 1`] = `
"type": "arrow",
},
],
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 100,
@ -122,7 +122,7 @@ exports[`move element > rectangles with binding arrow 1`] = `
"seed": 1278240551,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 3,
@ -143,7 +143,7 @@ exports[`move element > rectangles with binding arrow 2`] = `
"type": "arrow",
},
],
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 300,
@ -159,7 +159,7 @@ exports[`move element > rectangles with binding arrow 2`] = `
"seed": 2019559783,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 6,
@ -181,7 +181,7 @@ exports[`move element > rectangles with binding arrow 3`] = `
"focus": -0.46666666666666673,
"gap": 10,
},
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 81.48231043525051,
@ -214,7 +214,7 @@ exports[`move element > rectangles with binding arrow 3`] = `
},
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "line",
"updated": 1,
"version": 11,

View File

@ -7,7 +7,7 @@ exports[`multi point mode in linear elements > arrow 1`] = `
"boundElements": null,
"endArrowhead": "arrow",
"endBinding": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 110,
@ -43,7 +43,7 @@ exports[`multi point mode in linear elements > arrow 1`] = `
"startBinding": null,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 7,
@ -61,7 +61,7 @@ exports[`multi point mode in linear elements > line 1`] = `
"boundElements": null,
"endArrowhead": null,
"endBinding": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 110,
@ -97,7 +97,7 @@ exports[`multi point mode in linear elements > line 1`] = `
"startBinding": null,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "line",
"updated": 1,
"version": 7,

File diff suppressed because it is too large Load Diff

View File

@ -7,7 +7,7 @@ exports[`select single element on the scene > arrow 1`] = `
"boundElements": null,
"endArrowhead": "arrow",
"endBinding": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 50,
@ -36,7 +36,7 @@ exports[`select single element on the scene > arrow 1`] = `
"startBinding": null,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 3,
@ -54,7 +54,7 @@ exports[`select single element on the scene > arrow escape 1`] = `
"boundElements": null,
"endArrowhead": null,
"endBinding": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 50,
@ -83,7 +83,7 @@ exports[`select single element on the scene > arrow escape 1`] = `
"startBinding": null,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "line",
"updated": 1,
"version": 3,
@ -99,7 +99,7 @@ exports[`select single element on the scene > diamond 1`] = `
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 50,
@ -115,7 +115,7 @@ exports[`select single element on the scene > diamond 1`] = `
"seed": 1278240551,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "diamond",
"updated": 1,
"version": 2,
@ -131,7 +131,7 @@ exports[`select single element on the scene > ellipse 1`] = `
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 50,
@ -147,7 +147,7 @@ exports[`select single element on the scene > ellipse 1`] = `
"seed": 1278240551,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "ellipse",
"updated": 1,
"version": 2,
@ -163,7 +163,7 @@ exports[`select single element on the scene > rectangle 1`] = `
"angle": 0,
"backgroundColor": "transparent",
"boundElements": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 50,
@ -179,7 +179,7 @@ exports[`select single element on the scene > rectangle 1`] = `
"seed": 1278240551,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "rectangle",
"updated": 1,
"version": 2,

View File

@ -7,7 +7,7 @@ exports[`restoreElements > should restore arrow element correctly 1`] = `
"boundElements": [],
"endArrowhead": null,
"endBinding": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 100,
@ -36,7 +36,7 @@ exports[`restoreElements > should restore arrow element correctly 1`] = `
"startBinding": null,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "arrow",
"updated": 1,
"version": 1,
@ -160,7 +160,7 @@ exports[`restoreElements > should restore freedraw element correctly 1`] = `
"angle": 0,
"backgroundColor": "transparent",
"boundElements": [],
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 0,
@ -180,7 +180,7 @@ exports[`restoreElements > should restore freedraw element correctly 1`] = `
"simulatePressure": true,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "freedraw",
"updated": 1,
"version": 1,
@ -198,7 +198,7 @@ exports[`restoreElements > should restore line and draw elements correctly 1`] =
"boundElements": [],
"endArrowhead": null,
"endBinding": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 100,
@ -227,7 +227,7 @@ exports[`restoreElements > should restore line and draw elements correctly 1`] =
"startBinding": null,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "line",
"updated": 1,
"version": 1,
@ -245,7 +245,7 @@ exports[`restoreElements > should restore line and draw elements correctly 2`] =
"boundElements": [],
"endArrowhead": null,
"endBinding": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"frameId": null,
"groupIds": [],
"height": 100,
@ -274,7 +274,7 @@ exports[`restoreElements > should restore line and draw elements correctly 2`] =
"startBinding": null,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"type": "line",
"updated": 1,
"version": 1,
@ -292,7 +292,7 @@ exports[`restoreElements > should restore text element correctly passing value f
"baseline": 0,
"boundElements": [],
"containerId": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 14,
"frameId": null,
@ -312,7 +312,7 @@ exports[`restoreElements > should restore text element correctly passing value f
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "text",
"textAlign": "center",
"type": "text",
@ -333,7 +333,7 @@ exports[`restoreElements > should restore text element correctly with unknown fo
"baseline": 0,
"boundElements": [],
"containerId": null,
"fillStyle": "hachure",
"fillStyle": "solid",
"fontFamily": 1,
"fontSize": 10,
"frameId": null,
@ -353,7 +353,7 @@ exports[`restoreElements > should restore text element correctly with unknown fo
"seed": Any<Number>,
"strokeColor": "#1e1e1e",
"strokeStyle": "solid",
"strokeWidth": 1,
"strokeWidth": 2,
"text": "",
"textAlign": "left",
"type": "text",

View File

@ -14,7 +14,7 @@ exports[`exportToSvg > with default arguments 1`] = `
"currentChartType": "bar",
"currentItemBackgroundColor": "transparent",
"currentItemEndArrowhead": "arrow",
"currentItemFillStyle": "hachure",
"currentItemFillStyle": "solid",
"currentItemFontFamily": 1,
"currentItemFontSize": 20,
"currentItemOpacity": 100,
@ -23,7 +23,7 @@ exports[`exportToSvg > with default arguments 1`] = `
"currentItemStartArrowhead": null,
"currentItemStrokeColor": "#1e1e1e",
"currentItemStrokeStyle": "solid",
"currentItemStrokeWidth": 1,
"currentItemStrokeWidth": 2,
"currentItemTextAlign": "left",
"cursorButton": "up",
"defaultSidebarDockedPreference": false,

View File

@ -6,7 +6,7 @@ export const getTextEditor = async (waitForEditor = true) => {
".excalidraw-textEditorContainer > textarea",
) as HTMLTextAreaElement;
if (waitForEditor) {
waitFor(() => expect(query()).not.toBe(null));
await waitFor(() => expect(query()).not.toBe(null));
return query();
}
return query();

File diff suppressed because one or more lines are too long