mirror of
https://github.com/excalidraw/excalidraw
synced 2025-07-25 13:58:22 +08:00
support extraBold
for all element types
This commit is contained in:
@ -5,6 +5,7 @@ import {
|
|||||||
invariant,
|
invariant,
|
||||||
rescalePoints,
|
rescalePoints,
|
||||||
sizeOf,
|
sizeOf,
|
||||||
|
STROKE_WIDTH,
|
||||||
} from "@excalidraw/common";
|
} from "@excalidraw/common";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
@ -808,9 +809,15 @@ export const getArrowheadPoints = (
|
|||||||
// This value is selected by minimizing a minimum size with the last segment of the arrowhead
|
// This value is selected by minimizing a minimum size with the last segment of the arrowhead
|
||||||
const lengthMultiplier =
|
const lengthMultiplier =
|
||||||
arrowhead === "diamond" || arrowhead === "diamond_outline" ? 0.25 : 0.5;
|
arrowhead === "diamond" || arrowhead === "diamond_outline" ? 0.25 : 0.5;
|
||||||
const minSize = Math.min(size, length * lengthMultiplier);
|
// make arrowheads bigger for thick strokes
|
||||||
const xs = x2 - nx * minSize;
|
const strokeWidthMultiplier =
|
||||||
const ys = y2 - ny * minSize;
|
element.strokeWidth >= STROKE_WIDTH.extraBold ? 1.5 : 1;
|
||||||
|
|
||||||
|
const adjustedSize =
|
||||||
|
Math.min(size, length * lengthMultiplier) * strokeWidthMultiplier;
|
||||||
|
|
||||||
|
const xs = x2 - nx * adjustedSize;
|
||||||
|
const ys = y2 - ny * adjustedSize;
|
||||||
|
|
||||||
if (
|
if (
|
||||||
arrowhead === "dot" ||
|
arrowhead === "dot" ||
|
||||||
@ -859,7 +866,7 @@ export const getArrowheadPoints = (
|
|||||||
const [px, py] = element.points.length > 1 ? element.points[1] : [0, 0];
|
const [px, py] = element.points.length > 1 ? element.points[1] : [0, 0];
|
||||||
|
|
||||||
[ox, oy] = pointRotateRads(
|
[ox, oy] = pointRotateRads(
|
||||||
pointFrom(x2 + minSize * 2, y2),
|
pointFrom(x2 + adjustedSize * 2, y2),
|
||||||
pointFrom(x2, y2),
|
pointFrom(x2, y2),
|
||||||
Math.atan2(py - y2, px - x2) as Radians,
|
Math.atan2(py - y2, px - x2) as Radians,
|
||||||
);
|
);
|
||||||
@ -870,7 +877,7 @@ export const getArrowheadPoints = (
|
|||||||
: [0, 0];
|
: [0, 0];
|
||||||
|
|
||||||
[ox, oy] = pointRotateRads(
|
[ox, oy] = pointRotateRads(
|
||||||
pointFrom(x2 - minSize * 2, y2),
|
pointFrom(x2 - adjustedSize * 2, y2),
|
||||||
pointFrom(x2, y2),
|
pointFrom(x2, y2),
|
||||||
Math.atan2(y2 - py, x2 - px) as Radians,
|
Math.atan2(y2 - py, x2 - px) as Radians,
|
||||||
);
|
);
|
||||||
|
@ -21,6 +21,7 @@ import {
|
|||||||
assertNever,
|
assertNever,
|
||||||
COLOR_PALETTE,
|
COLOR_PALETTE,
|
||||||
LINE_POLYGON_POINT_MERGE_DISTANCE,
|
LINE_POLYGON_POINT_MERGE_DISTANCE,
|
||||||
|
STROKE_WIDTH,
|
||||||
} from "@excalidraw/common";
|
} from "@excalidraw/common";
|
||||||
|
|
||||||
import { RoughGenerator } from "roughjs/bin/generator";
|
import { RoughGenerator } from "roughjs/bin/generator";
|
||||||
@ -202,7 +203,7 @@ export const generateRoughOptions = (
|
|||||||
// hachureGap because if not specified, roughjs uses strokeWidth to
|
// hachureGap because if not specified, roughjs uses strokeWidth to
|
||||||
// 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: Math.min(element.strokeWidth, STROKE_WIDTH.bold) * 4,
|
||||||
roughness: adjustRoughness(element),
|
roughness: adjustRoughness(element),
|
||||||
stroke: element.strokeColor,
|
stroke: element.strokeColor,
|
||||||
preserveVertices:
|
preserveVertices:
|
||||||
|
@ -555,14 +555,7 @@ export const actionChangeStrokeWidth = register({
|
|||||||
<div className="buttonList">
|
<div className="buttonList">
|
||||||
<RadioSelection
|
<RadioSelection
|
||||||
group="stroke-width"
|
group="stroke-width"
|
||||||
options={
|
options={WIDTHS}
|
||||||
appState.activeTool.type === "freedraw" ||
|
|
||||||
app.scene
|
|
||||||
.getSelectedElements(app.state)
|
|
||||||
.every((element) => isFreeDrawElement(element))
|
|
||||||
? WIDTHS
|
|
||||||
: WIDTHS.slice(0, 3)
|
|
||||||
}
|
|
||||||
value={getFormValue(
|
value={getFormValue(
|
||||||
elements,
|
elements,
|
||||||
app,
|
app,
|
||||||
|
Reference in New Issue
Block a user