tldraw
Version:
A tiny little drawing editor.
54 lines (53 loc) • 2.42 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var GeoShapeBody_exports = {};
__export(GeoShapeBody_exports, {
GeoShapeBody: () => GeoShapeBody
});
module.exports = __toCommonJS(GeoShapeBody_exports);
var import_jsx_runtime = require("react/jsx-runtime");
var import_editor = require("@tldraw/editor");
var import_ShapeFill = require("../../shared/ShapeFill");
var import_default_shape_constants = require("../../shared/default-shape-constants");
var import_useDefaultColorTheme = require("../../shared/useDefaultColorTheme");
var import_getGeoShapePath = require("../getGeoShapePath");
function GeoShapeBody({
shape,
shouldScale,
forceSolid
}) {
const scaleToUse = shouldScale ? shape.props.scale : 1;
const theme = (0, import_useDefaultColorTheme.useDefaultColorTheme)();
const { props } = shape;
const { color, fill, dash, size } = props;
const strokeWidth = import_default_shape_constants.STROKE_SIZES[size] * scaleToUse;
const path = (0, import_getGeoShapePath.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__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_ShapeFill.ShapeFill, { theme, d: fillPath, color, fill, scale: scaleToUse }),
path.toSvg({
style: dash,
strokeWidth,
forceSolid,
randomSeed: shape.id,
props: { fill: "none", stroke: (0, import_editor.getColorValue)(theme, color, "solid") }
})
] });
}
//# sourceMappingURL=GeoShapeBody.js.map