Update renderElement.ts
This commit is contained in:
parent
08afb857c3
commit
a82ce8ce5a
@ -237,7 +237,16 @@ const drawElementOnCanvas = (
|
||||
rc.draw(fillShape);
|
||||
}
|
||||
|
||||
if (!fillShape && element.customData?.strokeOptions?.hasOutline) {
|
||||
context.lineWidth =
|
||||
(element.strokeWidth / 5) *
|
||||
element.customData.strokeOptions.outlineWidth ?? 1;
|
||||
context.strokeStyle = element.strokeColor;
|
||||
context.stroke(path);
|
||||
context.fillStyle = element.backgroundColor;
|
||||
} else {
|
||||
context.fillStyle = element.strokeColor;
|
||||
}
|
||||
context.fill(path);
|
||||
|
||||
context.restore();
|
||||
@ -1185,7 +1194,19 @@ export const renderElementToSvg = (
|
||||
);
|
||||
node.setAttribute("stroke", "none");
|
||||
const path = svgRoot.ownerDocument!.createElementNS(SVG_NS, "path");
|
||||
if (!shape && element.customData?.strokeOptions?.hasOutline) {
|
||||
path.setAttribute("fill", element.backgroundColor);
|
||||
path.setAttribute("stroke", element.strokeColor);
|
||||
path.setAttribute(
|
||||
"stroke-width",
|
||||
`${
|
||||
(element.strokeWidth / 5) *
|
||||
element.customData.strokeOptions.outlineWidth ?? 1
|
||||
}`,
|
||||
);
|
||||
} else {
|
||||
path.setAttribute("fill", element.strokeColor);
|
||||
}
|
||||
path.setAttribute("d", getFreeDrawSvgPath(element));
|
||||
node.appendChild(path);
|
||||
root.appendChild(node);
|
||||
@ -1328,7 +1349,9 @@ export function getFreeDrawSvgPath(element: ExcalidrawFreeDrawElement) {
|
||||
: [[0, 0, 0.5]];
|
||||
|
||||
// Consider changing the options for simulated pressure vs real pressure
|
||||
const options: StrokeOptions = {
|
||||
const options: StrokeOptions = element.customData?.strokeOptions?.options //zsviczian
|
||||
? { ...element.customData?.strokeOptions?.options }
|
||||
: {
|
||||
simulatePressure: element.simulatePressure,
|
||||
size: element.strokeWidth * 4.25,
|
||||
thinning: 0.6,
|
||||
@ -1338,6 +1361,15 @@ export function getFreeDrawSvgPath(element: ExcalidrawFreeDrawElement) {
|
||||
last: !!element.lastCommittedPoint, // LastCommittedPoint is added on pointerup
|
||||
};
|
||||
|
||||
if (element.customData?.strokeOptions?.options) {
|
||||
options.simulatePressure =
|
||||
options.simulatePressure ?? element.simulatePressure;
|
||||
options.size = options.size
|
||||
? (options.size * element.strokeWidth) / 4
|
||||
: element.strokeWidth * 4.25;
|
||||
options.last = !!element.lastCommittedPoint;
|
||||
}
|
||||
|
||||
return getSvgPathFromStroke(getStroke(inputPoints as number[][], options));
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user