mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: better default radius sizes for rectangles (#5553)
Co-authored-by: Ryan <diweihao@bytedance.com> Co-authored-by: dwelle <luzar.david@gmail.com>
This commit is contained in:
parent
65d84a5d5a
commit
5854ac3eed
39 changed files with 1861 additions and 818 deletions
|
@ -378,7 +378,7 @@ const generateLinearElementShape = (
|
|||
const options = generateRoughOptions(element);
|
||||
|
||||
const method = (() => {
|
||||
if (element.strokeSharpness !== "sharp") {
|
||||
if (element.roundness) {
|
||||
return "curve";
|
||||
}
|
||||
if (options.fill) {
|
||||
|
@ -561,16 +561,12 @@ export const getResizedElementAbsoluteCoords = (
|
|||
} else {
|
||||
// Line
|
||||
const gen = rough.generator();
|
||||
const curve =
|
||||
element.strokeSharpness === "sharp"
|
||||
? gen.linearPath(
|
||||
points as [number, number][],
|
||||
generateRoughOptions(element),
|
||||
)
|
||||
: gen.curve(
|
||||
points as [number, number][],
|
||||
generateRoughOptions(element),
|
||||
);
|
||||
const curve = !element.roundness
|
||||
? gen.linearPath(
|
||||
points as [number, number][],
|
||||
generateRoughOptions(element),
|
||||
)
|
||||
: gen.curve(points as [number, number][], generateRoughOptions(element));
|
||||
|
||||
const ops = getCurvePathOps(curve);
|
||||
bounds = getMinMaxXYFromCurvePathOps(ops);
|
||||
|
@ -588,12 +584,11 @@ export const getResizedElementAbsoluteCoords = (
|
|||
export const getElementPointsCoords = (
|
||||
element: ExcalidrawLinearElement,
|
||||
points: readonly (readonly [number, number])[],
|
||||
sharpness: ExcalidrawElement["strokeSharpness"],
|
||||
): [number, number, number, number] => {
|
||||
// This might be computationally heavey
|
||||
const gen = rough.generator();
|
||||
const curve =
|
||||
sharpness === "sharp"
|
||||
element.roundness == null
|
||||
? gen.linearPath(
|
||||
points as [number, number][],
|
||||
generateRoughOptions(element),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue