{ "version": 3, "sources": ["../../../../../src/lib/shapes/line/components/getLinePath.ts"], "sourcesContent": ["import { CubicSpline2d, Polyline2d, TLLineShape, getSvgPathFromPoints } from '@tldraw/editor'\nimport { getStrokeOutlinePoints } from '../../shared/freehand/getStrokeOutlinePoints'\nimport { getStrokePoints } from '../../shared/freehand/getStrokePoints'\nimport { setStrokePointRadii } from '../../shared/freehand/setStrokePointRadii'\nimport { getSvgPathFromStrokePoints } from '../../shared/freehand/svg'\nimport { getSvgPathForLineGeometry } from './svg'\n\nexport function getLineDrawFreehandOptions(strokeWidth: number) {\n\treturn {\n\t\tsize: strokeWidth,\n\t\tthinning: 0.4,\n\t\tstreamline: 0,\n\t\tsmoothing: 0.5,\n\t\tsimulatePressure: true,\n\t\tlast: true,\n\t}\n}\n\nexport function getLineSolidFreehandOptions(strokeWidth: number) {\n\treturn {\n\t\tsize: strokeWidth,\n\t\tthinning: 0,\n\t\tstreamline: 0,\n\t\tsmoothing: 0.5,\n\t\tsimulatePressure: false,\n\t\tlast: true,\n\t}\n}\n\nexport function getLineStrokePoints(\n\tshape: TLLineShape,\n\tspline: CubicSpline2d | Polyline2d,\n\tstrokeWidth: number\n) {\n\t// const points = getLinePoints(spline)\n\tconst points = spline.vertices\n\tconst options = getLineDrawFreehandOptions(strokeWidth)\n\treturn getStrokePoints(points, options)\n}\n\nexport function getLineDrawStrokeOutlinePoints(\n\tshape: TLLineShape,\n\tspline: CubicSpline2d | Polyline2d,\n\tstrokeWidth: number\n) {\n\tconst options = getLineDrawFreehandOptions(strokeWidth)\n\treturn getStrokeOutlinePoints(\n\t\tsetStrokePointRadii(getLineStrokePoints(shape, spline, strokeWidth), options),\n\t\toptions\n\t)\n}\n\nexport function getLineSolidStrokeOutlinePoints(\n\tshape: TLLineShape,\n\tspline: CubicSpline2d | Polyline2d,\n\tstrokeWidth: number\n) {\n\tconst options = getLineSolidFreehandOptions(strokeWidth)\n\treturn getStrokeOutlinePoints(getLineStrokePoints(shape, spline, strokeWidth), options)\n}\n\nexport function getLineDrawPath(\n\tshape: TLLineShape,\n\tspline: CubicSpline2d | Polyline2d,\n\tstrokeWidth: number\n) {\n\tconst stroke = getLineDrawStrokeOutlinePoints(shape, spline, strokeWidth)\n\treturn getSvgPathFromPoints(stroke)\n}\n\nexport function getLineSolidPath(\n\tshape: TLLineShape,\n\tspline: CubicSpline2d | Polyline2d,\n\tstrokeWidth: number\n) {\n\tconst outlinePoints = getLineSolidStrokeOutlinePoints(shape, spline, strokeWidth)\n\treturn getSvgPathFromPoints(outlinePoints)\n}\n\nexport function getLineIndicatorPath(\n\tshape: TLLineShape,\n\tspline: CubicSpline2d | Polyline2d,\n\tstrokeWidth: number\n) {\n\tif (shape.props.dash === 'draw') {\n\t\tconst strokePoints = getLineStrokePoints(shape, spline, strokeWidth)\n\t\treturn getSvgPathFromStrokePoints(strokePoints)\n\t}\n\n\treturn getSvgPathForLineGeometry(spline)\n}\n"], "mappings": "AAAA,SAAiD,4BAA4B;AAC7E,SAAS,8BAA8B;AACvC,SAAS,uBAAuB;AAChC,SAAS,2BAA2B;AACpC,SAAS,kCAAkC;AAC3C,SAAS,iCAAiC;AAEnC,SAAS,2BAA2B,aAAqB;AAC/D,SAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB,MAAM;AAAA,EACP;AACD;AAEO,SAAS,4BAA4B,aAAqB;AAChE,SAAO;AAAA,IACN,MAAM;AAAA,IACN,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,WAAW;AAAA,IACX,kBAAkB;AAAA,IAClB,MAAM;AAAA,EACP;AACD;AAEO,SAAS,oBACf,OACA,QACA,aACC;AAED,QAAM,SAAS,OAAO;AACtB,QAAM,UAAU,2BAA2B,WAAW;AACtD,SAAO,gBAAgB,QAAQ,OAAO;AACvC;AAEO,SAAS,+BACf,OACA,QACA,aACC;AACD,QAAM,UAAU,2BAA2B,WAAW;AACtD,S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