mirror of
https://github.com/excalidraw/excalidraw
synced 2025-07-25 13:58:22 +08:00
Revert "differentiate between constant/variable stroke type"
This reverts commit 0199c82e98
.
This commit is contained in:
@ -8,10 +8,10 @@ import { round } from "../../packages/math/src";
|
||||
|
||||
export const FreedrawDebugSliders = () => {
|
||||
const [streamline, setStreamline] = useState<number>(
|
||||
DRAWING_CONFIGS.default.variable.streamline,
|
||||
DRAWING_CONFIGS.default.streamline,
|
||||
);
|
||||
const [simplify, setSimplify] = useState<number>(
|
||||
DRAWING_CONFIGS.default.variable.simplify,
|
||||
DRAWING_CONFIGS.default.simplify,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
@ -21,7 +21,7 @@ export const FreedrawDebugSliders = () => {
|
||||
if (!window.h.debugFreedraw) {
|
||||
window.h.debugFreedraw = {
|
||||
enabled: true,
|
||||
...DRAWING_CONFIGS.default.variable,
|
||||
...DRAWING_CONFIGS.default,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -8,70 +8,34 @@ import type { StrokeOptions } from "perfect-freehand";
|
||||
|
||||
import type { ExcalidrawFreeDrawElement, PointerType } from "./types";
|
||||
|
||||
type FreedrawStrokeType = "constant" | "variable";
|
||||
|
||||
export const getElementStrokeType = (
|
||||
element: ExcalidrawFreeDrawElement,
|
||||
): FreedrawStrokeType => {
|
||||
return element.drawingConfigs?.fixedStrokeWidth ? "constant" : "variable";
|
||||
};
|
||||
|
||||
export const DRAWING_CONFIGS: Record<
|
||||
PointerType | "default",
|
||||
Record<FreedrawStrokeType, { streamline: number; simplify: number }>
|
||||
{ streamline: number; simplify: number }
|
||||
> = {
|
||||
default: {
|
||||
constant: {
|
||||
streamline: 0.35,
|
||||
simplify: 0.1,
|
||||
},
|
||||
variable: {
|
||||
streamline: 0.35,
|
||||
simplify: 0.1,
|
||||
},
|
||||
},
|
||||
mouse: {
|
||||
constant: {
|
||||
streamline: 0.6,
|
||||
simplify: 0.1,
|
||||
},
|
||||
variable: {
|
||||
streamline: 0.6,
|
||||
simplify: 0.1,
|
||||
},
|
||||
},
|
||||
pen: {
|
||||
constant: {
|
||||
// for optimal performance, we use a lower streamline and simplify
|
||||
streamline: 0.2,
|
||||
simplify: 0.1,
|
||||
},
|
||||
variable: {
|
||||
// for optimal performance, we use a lower streamline and simplify
|
||||
streamline: 0.2,
|
||||
simplify: 0.1,
|
||||
},
|
||||
},
|
||||
touch: {
|
||||
constant: {
|
||||
streamline: 0.65,
|
||||
simplify: 0.1,
|
||||
},
|
||||
variable: {
|
||||
streamline: 0.65,
|
||||
simplify: 0.1,
|
||||
},
|
||||
},
|
||||
} as const;
|
||||
|
||||
export const getFreedrawConfig = (
|
||||
eventType: string | null | undefined,
|
||||
strokeType: FreedrawStrokeType,
|
||||
): { streamline: number; simplify: number } => {
|
||||
const inputConfig =
|
||||
export const getFreedrawConfig = (eventType: string | null | undefined) => {
|
||||
return (
|
||||
DRAWING_CONFIGS[(eventType as PointerType | null) || "default"] ||
|
||||
DRAWING_CONFIGS.default;
|
||||
return inputConfig[strokeType];
|
||||
DRAWING_CONFIGS.default
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
@ -141,11 +105,9 @@ export const getFreedrawStroke = (element: ExcalidrawFreeDrawElement) => {
|
||||
}
|
||||
|
||||
const streamline =
|
||||
element.drawingConfigs?.streamline ??
|
||||
getFreedrawConfig("default", getElementStrokeType(element)).streamline;
|
||||
element.drawingConfigs?.streamline ?? DRAWING_CONFIGS.default.streamline;
|
||||
const simplify =
|
||||
element.drawingConfigs?.simplify ??
|
||||
getFreedrawConfig("default", getElementStrokeType(element)).simplify;
|
||||
element.drawingConfigs?.simplify ?? DRAWING_CONFIGS.default.simplify;
|
||||
|
||||
const laser = new LaserPointer({
|
||||
size: element.strokeWidth,
|
||||
|
@ -7479,10 +7479,7 @@ class App extends React.Component<AppProps, AppState> {
|
||||
|
||||
window.__lastPressure__ = event.pressure;
|
||||
|
||||
const freedrawConfig = getFreedrawConfig(
|
||||
event.pointerType,
|
||||
this.state.currentItemFixedStrokeWidth ? "constant" : "variable",
|
||||
);
|
||||
const freedrawConfig = getFreedrawConfig(event.pointerType);
|
||||
|
||||
const element = newFreeDrawElement({
|
||||
type: elementType,
|
||||
@ -11174,7 +11171,7 @@ export const createTestHook = () => {
|
||||
// Initialize debug freedraw parameters
|
||||
window.h.debugFreedraw = {
|
||||
enabled: true,
|
||||
...(window.h.debugFreedraw || DRAWING_CONFIGS.default.variable),
|
||||
...(window.h.debugFreedraw || DRAWING_CONFIGS.default),
|
||||
};
|
||||
|
||||
Object.defineProperties(window.h, {
|
||||
|
Reference in New Issue
Block a user