开源白板工具(SaaS),一体化白板,包含思维导图、流程图、自由画等。All in one open-source whiteboard tool with mind, flowchart, freehand and etc.
feat(freehand): improve freehand experience (#51)
pubuzhixing8ee4f8a2cdb32
diff --git a/packages/drawnix/src/plugins/freehand/freehand.generator.ts b/packages/drawnix/src/plugins/freehand/freehand.generator.tsindex 7442333..01457e0 100644--- a/packages/drawnix/src/plugins/freehand/freehand.generator.ts+++ b/packages/drawnix/src/plugins/freehand/freehand.generator.ts@@ -8,7 +8,7 @@ export class FreehandGenerator extends Generator<Freehand> {protected draw(element: Freehand): SVGGElement | undefined {const option: Options = { ...DefaultFreehand };const g = PlaitBoard.getRoughSVG(this.board).curve(- gaussianSmooth(element.points, 1, 3),+ gaussianSmooth(element.points, 1.2, 4),option);setStrokeLinecap(g, 'round');diff --git a/packages/drawnix/src/plugins/freehand/with-freehand-create.ts b/packages/drawnix/src/plugins/freehand/with-freehand-create.tsindex 313fcc6..bfab490 100644--- a/packages/drawnix/src/plugins/freehand/with-freehand-create.ts+++ b/packages/drawnix/src/plugins/freehand/with-freehand-create.ts@@ -54,27 +54,28 @@ export const withFreehandCreate = (board: PlaitBoard) => {board.pointerMove = (event: PointerEvent) => {if (isDrawing && previousScreenPoint) {- const distance = distanceBetweenPointAndPoint(previousScreenPoint[0], previousScreenPoint[1], event.x, event.y);- if (distance < 2) {+ const distance = distanceBetweenPointAndPoint(+ previousScreenPoint[0],+ previousScreenPoint[1],+ event.x,+ event.y+ );+ if (distance <= 0.5) {return;}previousScreenPoint = [event.x, event.y];- throttleRAF(board, 'with-freehand-creation', () => {- generator?.destroy();- if (isDrawing) {- const newPoint = toViewBoxPoint(- board,- toHostPoint(board, event.x, event.y)- );- points.push(newPoint);- const pointer = PlaitBoard.getPointer(board) as FreehandShape;- temporaryElement = createFreehandElement(pointer, points);- generator.processDrawing(- temporaryElement,- PlaitBoard.getElementActiveHost(board)- );- }- });+ generator?.destroy();+ const newPoint = toViewBoxPoint(+ board,+ toHostPoint(board, event.x, event.y)+ );+ points.push(newPoint);+ const pointer = PlaitBoard.getPointer(board) as FreehandShape;+ temporaryElement = createFreehandElement(pointer, points);+ generator.processDrawing(+ temporaryElement,+ PlaitBoard.getElementActiveHost(board)+ );return;}