udated shapes

This commit is contained in:
omkarht
2024-09-04 18:48:25 +05:30
parent 5d3a175ed6
commit 8462f21c01
3 changed files with 15 additions and 19 deletions

View File

@@ -14,8 +14,8 @@ export const hourglass = async (parent: SVGAElement, node: Node) => {
node.labelStyle = labelStyles; node.labelStyle = labelStyles;
const { shapeSvg } = await labelHelper(parent, node, getNodeClasses(node)); const { shapeSvg } = await labelHelper(parent, node, getNodeClasses(node));
const w = 100; const w = Math.max(30, node?.width ?? 0);
const h = 100; const h = Math.max(30, node?.height ?? 0);
const { cssStyles } = node; const { cssStyles } = node;

View File

@@ -19,9 +19,9 @@ export const lightningBolt = (parent: SVG, node: Node) => {
.attr('class', getNodeClasses(node)) .attr('class', getNodeClasses(node))
.attr('id', node.domId ?? node.id); .attr('id', node.domId ?? node.id);
const { cssStyles } = node; const { cssStyles } = node;
const height = 80; const width = Math.max(35, node?.width ?? 0);
const width = 80; const height = Math.max(35, node?.height ?? 0);
const gap = 16; const gap = 7;
const points = [ const points = [
{ x: width, y: 0 }, { x: width, y: 0 },

View File

@@ -11,9 +11,10 @@ export const trapezoidalPentagon = async (parent: SVGAElement, node: Node) => {
const { labelStyles, nodeStyles } = styles2String(node); const { labelStyles, nodeStyles } = styles2String(node);
node.labelStyle = labelStyles; node.labelStyle = labelStyles;
const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node)); const { shapeSvg, bbox } = await labelHelper(parent, node, getNodeClasses(node));
const widthMultiplier = bbox.width < 40 ? 3 : 1.25; const minWidth = 60,
const w = (bbox.width + node.padding) * widthMultiplier; minHeight = 20;
const h = bbox.height + node.padding; const w = Math.max(minWidth, bbox.width + (node.padding ?? 0) * 2, node?.width ?? 0);
const h = Math.max(minHeight, bbox.height + (node.padding ?? 0) * 2, node?.height ?? 0);
const { cssStyles } = node; const { cssStyles } = node;
// @ts-ignore - rough is not typed // @ts-ignore - rough is not typed
@@ -25,16 +26,13 @@ export const trapezoidalPentagon = async (parent: SVGAElement, node: Node) => {
options.fillStyle = 'solid'; options.fillStyle = 'solid';
} }
const topOffset = 30;
const slopeHeight = 15;
const points = [ const points = [
{ x: topOffset, y: 0 }, { x: (-w / 2) * 0.8, y: -h / 2 },
{ x: w - topOffset, y: 0 }, { x: (w / 2) * 0.8, y: -h / 2 },
{ x: w, y: slopeHeight }, { x: w / 2, y: (-h / 2) * 0.6 },
{ x: w, y: h }, { x: w / 2, y: h / 2 },
{ x: 0, y: h }, { x: -w / 2, y: h / 2 },
{ x: 0, y: slopeHeight }, { x: -w / 2, y: (-h / 2) * 0.6 },
]; ];
const pathData = createPathFromPoints(points); const pathData = createPathFromPoints(points);
@@ -51,8 +49,6 @@ export const trapezoidalPentagon = async (parent: SVGAElement, node: Node) => {
polygon.selectChildren('path').attr('style', nodeStyles); polygon.selectChildren('path').attr('style', nodeStyles);
} }
polygon.attr('transform', `translate(${-w / 2}, ${-h / 2})`);
updateNodeBounds(node, polygon); updateNodeBounds(node, polygon);
node.intersect = function (point) { node.intersect = function (point) {