UNPKG

tldraw

Version:

A tiny little drawing editor.

34 lines (33 loc) 1.29 kB
import { Fragment, jsx, jsxs } from "react/jsx-runtime"; import { getColorValue } from "@tldraw/editor"; import { ShapeFill } from "../../shared/ShapeFill.mjs"; import { STROKE_SIZES } from "../../shared/default-shape-constants.mjs"; import { useDefaultColorTheme } from "../../shared/useDefaultColorTheme.mjs"; import { getGeoShapePath } from "../getGeoShapePath.mjs"; function GeoShapeBody({ shape, shouldScale, forceSolid }) { const scaleToUse = shouldScale ? shape.props.scale : 1; const theme = useDefaultColorTheme(); const { props } = shape; const { color, fill, dash, size } = props; const strokeWidth = STROKE_SIZES[size] * scaleToUse; const path = getGeoShapePath(shape); const fillPath = dash === "draw" && !forceSolid ? path.toDrawD({ strokeWidth, randomSeed: shape.id, passes: 1, offset: 0, onlyFilled: true }) : path.toD({ onlyFilled: true }); return /* @__PURE__ */ jsxs(Fragment, { children: [ /* @__PURE__ */ jsx(ShapeFill, { theme, d: fillPath, color, fill, scale: scaleToUse }), path.toSvg({ style: dash, strokeWidth, forceSolid, randomSeed: shape.id, props: { fill: "none", stroke: getColorValue(theme, color, "solid") } }) ] }); } export { GeoShapeBody }; //# sourceMappingURL=GeoShapeBody.mjs.map