mirror of
https://github.com/excalidraw/excalidraw
synced 2025-07-25 13:58:22 +08:00
remove debug and provide value for stylus
This commit is contained in:
@ -134,7 +134,6 @@ import DebugCanvas, {
|
||||
} from "./components/DebugCanvas";
|
||||
import { AIComponents } from "./components/AI";
|
||||
import { ExcalidrawPlusIframeExport } from "./ExcalidrawPlusIframeExport";
|
||||
import { FreedrawDebugSliders } from "./components/FreedrawDebugSliders";
|
||||
|
||||
import "./index.scss";
|
||||
|
||||
@ -1143,7 +1142,6 @@ const ExcalidrawWrapper = () => {
|
||||
ref={debugCanvasRef}
|
||||
/>
|
||||
)}
|
||||
<FreedrawDebugSliders />
|
||||
</Excalidraw>
|
||||
</div>
|
||||
);
|
||||
|
@ -1,89 +0,0 @@
|
||||
import { DRAWING_CONFIGS } from "@excalidraw/element";
|
||||
import { useState, useEffect } from "react";
|
||||
|
||||
export const FreedrawDebugSliders = () => {
|
||||
const [streamline, setStreamline] = useState<number>(
|
||||
DRAWING_CONFIGS.default.streamline,
|
||||
);
|
||||
const [simplify, setSimplify] = useState<number>(
|
||||
DRAWING_CONFIGS.default.simplify,
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if (!window.h) {
|
||||
window.h = {} as any;
|
||||
}
|
||||
if (!window.h.debugFreedraw) {
|
||||
window.h.debugFreedraw = DRAWING_CONFIGS.default;
|
||||
}
|
||||
|
||||
setStreamline(window.h.debugFreedraw.streamline);
|
||||
setSimplify(window.h.debugFreedraw.simplify);
|
||||
}, []);
|
||||
|
||||
const handleStreamlineChange = (value: number) => {
|
||||
setStreamline(value);
|
||||
if (window.h && window.h.debugFreedraw) {
|
||||
window.h.debugFreedraw.streamline = value;
|
||||
}
|
||||
};
|
||||
|
||||
const handleSimplifyChange = (value: number) => {
|
||||
setSimplify(value);
|
||||
if (window.h && window.h.debugFreedraw) {
|
||||
window.h.debugFreedraw.simplify = value;
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
position: "absolute",
|
||||
bottom: "10px",
|
||||
left: "50%",
|
||||
transform: "translateX(-50%)",
|
||||
zIndex: 9999,
|
||||
background: "rgba(255, 255, 255, 0.9)",
|
||||
padding: "10px",
|
||||
borderRadius: "8px",
|
||||
border: "1px solid #ccc",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
gap: "8px",
|
||||
fontSize: "12px",
|
||||
fontFamily: "monospace",
|
||||
}}
|
||||
>
|
||||
<div>
|
||||
<label>
|
||||
Streamline: {streamline.toFixed(2)}
|
||||
<br />
|
||||
<input
|
||||
type="range"
|
||||
min="0"
|
||||
max="1"
|
||||
step="0.01"
|
||||
value={streamline}
|
||||
onChange={(e) => handleStreamlineChange(parseFloat(e.target.value))}
|
||||
style={{ width: "150px" }}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
<div>
|
||||
<label>
|
||||
Simplify: {simplify.toFixed(2)}
|
||||
<br />
|
||||
<input
|
||||
type="range"
|
||||
min="0"
|
||||
max="1"
|
||||
step="0.01"
|
||||
value={simplify}
|
||||
onChange={(e) => handleSimplifyChange(parseFloat(e.target.value))}
|
||||
style={{ width: "150px" }}
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
@ -11,6 +11,11 @@ import type { ExcalidrawFreeDrawElement } from "./types";
|
||||
export const DRAWING_CONFIGS = {
|
||||
default: {
|
||||
streamline: 0.25,
|
||||
simplify: 0.25,
|
||||
},
|
||||
// for optimal performance, we use a lower streamline and simplify
|
||||
stylus: {
|
||||
streamline: 0.1,
|
||||
simplify: 0.1,
|
||||
},
|
||||
} as const;
|
||||
|
@ -7594,11 +7594,9 @@ class App extends React.Component<AppProps, AppState> {
|
||||
simulatePressure,
|
||||
drawingConfigs: {
|
||||
pressureSensitivity: this.state.currentItemPressureSensitivity,
|
||||
streamline:
|
||||
window.h?.debugFreedraw?.streamline ??
|
||||
DRAWING_CONFIGS.default.streamline,
|
||||
simplify:
|
||||
window.h?.debugFreedraw?.simplify ?? DRAWING_CONFIGS.default.simplify,
|
||||
...(event.pointerType === "pen"
|
||||
? DRAWING_CONFIGS.stylus
|
||||
: DRAWING_CONFIGS.default),
|
||||
},
|
||||
locked: false,
|
||||
frameId: topLayerFrame ? topLayerFrame.id : null,
|
||||
@ -11382,10 +11380,6 @@ declare global {
|
||||
app: InstanceType<typeof App>;
|
||||
history: History;
|
||||
store: Store;
|
||||
debugFreedraw?: {
|
||||
streamline: number;
|
||||
simplify: number;
|
||||
};
|
||||
};
|
||||
}
|
||||
}
|
||||
@ -11394,9 +11388,6 @@ export const createTestHook = () => {
|
||||
if (isTestEnv() || isDevEnv()) {
|
||||
window.h = window.h || ({} as Window["h"]);
|
||||
|
||||
// Initialize debug freedraw parameters
|
||||
window.h.debugFreedraw = window.h.debugFreedraw || DRAWING_CONFIGS.default;
|
||||
|
||||
Object.defineProperties(window.h, {
|
||||
elements: {
|
||||
configurable: true,
|
||||
|
@ -8910,6 +8910,11 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte
|
||||
"backgroundColor": "transparent",
|
||||
"boundElements": null,
|
||||
"customData": undefined,
|
||||
"drawingConfigs": {
|
||||
"pressureSensitivity": 1,
|
||||
"simplify": "0.25000",
|
||||
"streamline": "0.25000",
|
||||
},
|
||||
"fillStyle": "solid",
|
||||
"frameId": null,
|
||||
"groupIds": [],
|
||||
@ -8942,7 +8947,6 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte
|
||||
50,
|
||||
],
|
||||
],
|
||||
"pressureSensitivity": 1,
|
||||
"pressures": [],
|
||||
"roughness": 1,
|
||||
"roundness": null,
|
||||
@ -9015,6 +9019,11 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte
|
||||
"backgroundColor": "transparent",
|
||||
"boundElements": null,
|
||||
"customData": undefined,
|
||||
"drawingConfigs": {
|
||||
"pressureSensitivity": 1,
|
||||
"simplify": "0.25000",
|
||||
"streamline": "0.25000",
|
||||
},
|
||||
"fillStyle": "solid",
|
||||
"frameId": null,
|
||||
"groupIds": [],
|
||||
@ -9046,7 +9055,6 @@ exports[`history > multiplayer undo/redo > should not let remote changes to inte
|
||||
50,
|
||||
],
|
||||
],
|
||||
"pressureSensitivity": 1,
|
||||
"pressures": [],
|
||||
"roughness": 1,
|
||||
"roundness": null,
|
||||
@ -12064,6 +12072,11 @@ exports[`history > singleplayer undo/redo > should create entry when selecting f
|
||||
"backgroundColor": "transparent",
|
||||
"boundElements": null,
|
||||
"customData": undefined,
|
||||
"drawingConfigs": {
|
||||
"pressureSensitivity": 1,
|
||||
"simplify": "0.25000",
|
||||
"streamline": "0.25000",
|
||||
},
|
||||
"fillStyle": "solid",
|
||||
"frameId": null,
|
||||
"groupIds": [],
|
||||
@ -12092,7 +12105,6 @@ exports[`history > singleplayer undo/redo > should create entry when selecting f
|
||||
10,
|
||||
],
|
||||
],
|
||||
"pressureSensitivity": 1,
|
||||
"pressures": [],
|
||||
"roughness": 1,
|
||||
"roundness": null,
|
||||
@ -12115,6 +12127,11 @@ exports[`history > singleplayer undo/redo > should create entry when selecting f
|
||||
"backgroundColor": "transparent",
|
||||
"boundElements": null,
|
||||
"customData": undefined,
|
||||
"drawingConfigs": {
|
||||
"pressureSensitivity": 1,
|
||||
"simplify": "0.25000",
|
||||
"streamline": "0.25000",
|
||||
},
|
||||
"fillStyle": "solid",
|
||||
"frameId": null,
|
||||
"groupIds": [],
|
||||
@ -12143,7 +12160,6 @@ exports[`history > singleplayer undo/redo > should create entry when selecting f
|
||||
10,
|
||||
],
|
||||
],
|
||||
"pressureSensitivity": 1,
|
||||
"pressures": [],
|
||||
"roughness": 1,
|
||||
"roundness": null,
|
||||
@ -12256,6 +12272,11 @@ exports[`history > singleplayer undo/redo > should create entry when selecting f
|
||||
"backgroundColor": "transparent",
|
||||
"boundElements": null,
|
||||
"customData": undefined,
|
||||
"drawingConfigs": {
|
||||
"pressureSensitivity": 1,
|
||||
"simplify": "0.25000",
|
||||
"streamline": "0.25000",
|
||||
},
|
||||
"fillStyle": "solid",
|
||||
"frameId": null,
|
||||
"groupIds": [],
|
||||
@ -12283,7 +12304,6 @@ exports[`history > singleplayer undo/redo > should create entry when selecting f
|
||||
10,
|
||||
],
|
||||
],
|
||||
"pressureSensitivity": 1,
|
||||
"pressures": [],
|
||||
"roughness": 1,
|
||||
"roundness": null,
|
||||
|
@ -6877,6 +6877,11 @@ exports[`regression tests > draw every type of shape > [end of test] undo stack
|
||||
"backgroundColor": "transparent",
|
||||
"boundElements": null,
|
||||
"customData": undefined,
|
||||
"drawingConfigs": {
|
||||
"pressureSensitivity": 1,
|
||||
"simplify": "0.25000",
|
||||
"streamline": "0.25000",
|
||||
},
|
||||
"fillStyle": "solid",
|
||||
"frameId": null,
|
||||
"groupIds": [],
|
||||
@ -6904,7 +6909,6 @@ exports[`regression tests > draw every type of shape > [end of test] undo stack
|
||||
10,
|
||||
],
|
||||
],
|
||||
"pressureSensitivity": 1,
|
||||
"pressures": [],
|
||||
"roughness": 1,
|
||||
"roundness": null,
|
||||
@ -9152,6 +9156,11 @@ exports[`regression tests > key 7 selects freedraw tool > [end of test] undo sta
|
||||
"backgroundColor": "transparent",
|
||||
"boundElements": null,
|
||||
"customData": undefined,
|
||||
"drawingConfigs": {
|
||||
"pressureSensitivity": 1,
|
||||
"simplify": "0.25000",
|
||||
"streamline": "0.25000",
|
||||
},
|
||||
"fillStyle": "solid",
|
||||
"frameId": null,
|
||||
"groupIds": [],
|
||||
@ -9179,7 +9188,6 @@ exports[`regression tests > key 7 selects freedraw tool > [end of test] undo sta
|
||||
10,
|
||||
],
|
||||
],
|
||||
"pressureSensitivity": 1,
|
||||
"pressures": [],
|
||||
"roughness": 1,
|
||||
"roundness": null,
|
||||
@ -10156,6 +10164,11 @@ exports[`regression tests > key p selects freedraw tool > [end of test] undo sta
|
||||
"backgroundColor": "transparent",
|
||||
"boundElements": null,
|
||||
"customData": undefined,
|
||||
"drawingConfigs": {
|
||||
"pressureSensitivity": 1,
|
||||
"simplify": "0.25000",
|
||||
"streamline": "0.25000",
|
||||
},
|
||||
"fillStyle": "solid",
|
||||
"frameId": null,
|
||||
"groupIds": [],
|
||||
@ -10183,7 +10196,6 @@ exports[`regression tests > key p selects freedraw tool > [end of test] undo sta
|
||||
10,
|
||||
],
|
||||
],
|
||||
"pressureSensitivity": 1,
|
||||
"pressures": [],
|
||||
"roughness": 1,
|
||||
"roundness": null,
|
||||
|
@ -170,6 +170,11 @@ exports[`restoreElements > should restore freedraw element correctly 1`] = `
|
||||
"backgroundColor": "transparent",
|
||||
"boundElements": [],
|
||||
"customData": undefined,
|
||||
"drawingConfigs": {
|
||||
"pressureSensitivity": 1,
|
||||
"simplify": "0.10000",
|
||||
"streamline": "0.25000",
|
||||
},
|
||||
"fillStyle": "solid",
|
||||
"frameId": null,
|
||||
"groupIds": [],
|
||||
@ -191,7 +196,6 @@ exports[`restoreElements > should restore freedraw element correctly 1`] = `
|
||||
10,
|
||||
],
|
||||
],
|
||||
"pressureSensitivity": 1,
|
||||
"pressures": [],
|
||||
"roughness": 1,
|
||||
"roundness": {
|
||||
|
Reference in New Issue
Block a user