mirror of
https://github.com/excalidraw/excalidraw
synced 2025-07-25 13:58:22 +08:00
fix: funky shape corners for freedraw
This commit is contained in:
@ -20,8 +20,6 @@ import { canChangeRoundness } from "./comparisons";
|
|||||||
import { generateFreeDrawShape } from "./renderElement";
|
import { generateFreeDrawShape } from "./renderElement";
|
||||||
import { getArrowheadPoints, getDiamondPoints } from "./bounds";
|
import { getArrowheadPoints, getDiamondPoints } from "./bounds";
|
||||||
|
|
||||||
import { getFreedrawStroke } from "./freedraw";
|
|
||||||
|
|
||||||
import type {
|
import type {
|
||||||
ExcalidrawElement,
|
ExcalidrawElement,
|
||||||
NonDeletedExcalidrawElement,
|
NonDeletedExcalidrawElement,
|
||||||
@ -514,19 +512,18 @@ export const _generateElementShape = (
|
|||||||
generateFreeDrawShape(element);
|
generateFreeDrawShape(element);
|
||||||
|
|
||||||
if (isPathALoop(element.points)) {
|
if (isPathALoop(element.points)) {
|
||||||
let points;
|
const points =
|
||||||
if (element.pressureSensitivity === null) {
|
element.pressureSensitivity === null
|
||||||
// legacy freedraw
|
? simplify(element.points as LocalPoint[], 0.75)
|
||||||
points = simplify(element.points as LocalPoint[], 0.75);
|
: simplify(element.points as LocalPoint[], 1.5);
|
||||||
} else {
|
|
||||||
// new freedraw
|
|
||||||
const stroke = getFreedrawStroke(element);
|
|
||||||
points = stroke
|
|
||||||
.slice(0, Math.floor(stroke.length / 2))
|
|
||||||
.map((p) => pointFrom(p[0], p[1]));
|
|
||||||
}
|
|
||||||
|
|
||||||
shape = generator.curve(points, {
|
shape =
|
||||||
|
element.pressureSensitivity === null
|
||||||
|
? generator.curve(points, {
|
||||||
|
...generateRoughOptions(element),
|
||||||
|
stroke: "none",
|
||||||
|
})
|
||||||
|
: generator.polygon(points, {
|
||||||
...generateRoughOptions(element),
|
...generateRoughOptions(element),
|
||||||
stroke: "none",
|
stroke: "none",
|
||||||
});
|
});
|
||||||
|
@ -8943,15 +8943,10 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
"pressureSensitivity": 1,
|
"pressureSensitivity": 1,
|
||||||
"pressures": [
|
"pressures": [],
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
],
|
|
||||||
"roughness": 1,
|
"roughness": 1,
|
||||||
"roundness": null,
|
"roundness": null,
|
||||||
"simulatePressure": false,
|
"simulatePressure": true,
|
||||||
"strokeColor": "#1e1e1e",
|
"strokeColor": "#1e1e1e",
|
||||||
"strokeStyle": "solid",
|
"strokeStyle": "solid",
|
||||||
"strokeWidth": 2,
|
"strokeWidth": 2,
|
||||||
@ -9052,15 +9047,10 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
"pressureSensitivity": 1,
|
"pressureSensitivity": 1,
|
||||||
"pressures": [
|
"pressures": [],
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
],
|
|
||||||
"roughness": 1,
|
"roughness": 1,
|
||||||
"roundness": null,
|
"roundness": null,
|
||||||
"simulatePressure": false,
|
"simulatePressure": true,
|
||||||
"strokeColor": "#1e1e1e",
|
"strokeColor": "#1e1e1e",
|
||||||
"strokeStyle": "solid",
|
"strokeStyle": "solid",
|
||||||
"strokeWidth": 2,
|
"strokeWidth": 2,
|
||||||
@ -12103,14 +12093,10 @@ exports[`history > singleplayer undo/redo > should create entry when selecting f
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
"pressureSensitivity": 1,
|
"pressureSensitivity": 1,
|
||||||
"pressures": [
|
"pressures": [],
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
],
|
|
||||||
"roughness": 1,
|
"roughness": 1,
|
||||||
"roundness": null,
|
"roundness": null,
|
||||||
"simulatePressure": false,
|
"simulatePressure": true,
|
||||||
"strokeColor": "#1e1e1e",
|
"strokeColor": "#1e1e1e",
|
||||||
"strokeStyle": "solid",
|
"strokeStyle": "solid",
|
||||||
"strokeWidth": 2,
|
"strokeWidth": 2,
|
||||||
@ -12158,14 +12144,10 @@ exports[`history > singleplayer undo/redo > should create entry when selecting f
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
"pressureSensitivity": 1,
|
"pressureSensitivity": 1,
|
||||||
"pressures": [
|
"pressures": [],
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
],
|
|
||||||
"roughness": 1,
|
"roughness": 1,
|
||||||
"roundness": null,
|
"roundness": null,
|
||||||
"simulatePressure": false,
|
"simulatePressure": true,
|
||||||
"strokeColor": "#e03131",
|
"strokeColor": "#e03131",
|
||||||
"strokeStyle": "solid",
|
"strokeStyle": "solid",
|
||||||
"strokeWidth": 2,
|
"strokeWidth": 2,
|
||||||
@ -12302,14 +12284,10 @@ exports[`history > singleplayer undo/redo > should create entry when selecting f
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
"pressureSensitivity": 1,
|
"pressureSensitivity": 1,
|
||||||
"pressures": [
|
"pressures": [],
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
],
|
|
||||||
"roughness": 1,
|
"roughness": 1,
|
||||||
"roundness": null,
|
"roundness": null,
|
||||||
"simulatePressure": false,
|
"simulatePressure": true,
|
||||||
"strokeColor": "#e03131",
|
"strokeColor": "#e03131",
|
||||||
"strokeStyle": "solid",
|
"strokeStyle": "solid",
|
||||||
"strokeWidth": 2,
|
"strokeWidth": 2,
|
||||||
|
@ -6905,14 +6905,10 @@ exports[`regression tests > draw every type of shape > [end of test] undo stack
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
"pressureSensitivity": 1,
|
"pressureSensitivity": 1,
|
||||||
"pressures": [
|
"pressures": [],
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
],
|
|
||||||
"roughness": 1,
|
"roughness": 1,
|
||||||
"roundness": null,
|
"roundness": null,
|
||||||
"simulatePressure": false,
|
"simulatePressure": true,
|
||||||
"strokeColor": "#1e1e1e",
|
"strokeColor": "#1e1e1e",
|
||||||
"strokeStyle": "solid",
|
"strokeStyle": "solid",
|
||||||
"strokeWidth": 2,
|
"strokeWidth": 2,
|
||||||
@ -9184,14 +9180,10 @@ exports[`regression tests > key 7 selects freedraw tool > [end of test] undo sta
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
"pressureSensitivity": 1,
|
"pressureSensitivity": 1,
|
||||||
"pressures": [
|
"pressures": [],
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
],
|
|
||||||
"roughness": 1,
|
"roughness": 1,
|
||||||
"roundness": null,
|
"roundness": null,
|
||||||
"simulatePressure": false,
|
"simulatePressure": true,
|
||||||
"strokeColor": "#1e1e1e",
|
"strokeColor": "#1e1e1e",
|
||||||
"strokeStyle": "solid",
|
"strokeStyle": "solid",
|
||||||
"strokeWidth": 2,
|
"strokeWidth": 2,
|
||||||
@ -10192,14 +10184,10 @@ exports[`regression tests > key p selects freedraw tool > [end of test] undo sta
|
|||||||
],
|
],
|
||||||
],
|
],
|
||||||
"pressureSensitivity": 1,
|
"pressureSensitivity": 1,
|
||||||
"pressures": [
|
"pressures": [],
|
||||||
0,
|
|
||||||
0,
|
|
||||||
0,
|
|
||||||
],
|
|
||||||
"roughness": 1,
|
"roughness": 1,
|
||||||
"roundness": null,
|
"roundness": null,
|
||||||
"simulatePressure": false,
|
"simulatePressure": true,
|
||||||
"strokeColor": "#1e1e1e",
|
"strokeColor": "#1e1e1e",
|
||||||
"strokeStyle": "solid",
|
"strokeStyle": "solid",
|
||||||
"strokeWidth": 2,
|
"strokeWidth": 2,
|
||||||
|
Reference in New Issue
Block a user