implemented neo-fication and shape resize for flippedTriangle, taggedRect, triangle waveEdgedRectangle shapes

This commit is contained in:
omkarht
2024-09-03 15:21:57 +05:30
parent 0764dca3ce
commit 46aba3dfe9
3 changed files with 15 additions and 7 deletions

View File

@@ -14,8 +14,11 @@ export const flippedTriangle = async (parent: SVGAElement, node: Node): Promise<
node.labelStyle = labelStyles; node.labelStyle = labelStyles;
const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node)); const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node));
const w = bbox.width + (node.padding ?? 0); const nodePadding = node.padding ?? 0;
const h = w + bbox.height; const labelPaddingX = node.look === 'neo' ? nodePadding * 2 : nodePadding;
const labelPaddingY = node.look === 'neo' ? nodePadding * 1 : nodePadding;
const w = Math.max(bbox.width + (labelPaddingX ?? 0), node?.width ?? 0);
const h = Math.max(w + bbox.height, node?.width ?? 0);
const tw = w + bbox.height; const tw = w + bbox.height;
const points = [ const points = [
@@ -55,7 +58,7 @@ export const flippedTriangle = async (parent: SVGAElement, node: Node): Promise<
label.attr( label.attr(
'transform', 'transform',
`translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${-h / 2 + (node.padding ?? 0) / 2 + (bbox.y - (bbox.top ?? 0))})` `translate(${-bbox.width / 2 - (bbox.x - (bbox.left ?? 0))}, ${-h / 2 + (labelPaddingY ?? 0) / 2 + (bbox.y - (bbox.top ?? 0))})`
); );
node.intersect = function (point) { node.intersect = function (point) {

View File

@@ -11,8 +11,11 @@ export const taggedRect = 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 w = Math.max(bbox.width + (node.padding ?? 0) * 2, node?.width ?? 0); const nodePadding = node.padding ?? 0;
const h = Math.max(bbox.height + (node.padding ?? 0) * 2, node?.height ?? 0); const labelPaddingX = node.look === 'neo' ? nodePadding * 2 : nodePadding;
const labelPaddingY = node.look === 'neo' ? nodePadding * 1 : nodePadding;
const w = Math.max(bbox.width + (labelPaddingX ?? 0) * 2, node?.width ?? 0);
const h = Math.max(bbox.height + (labelPaddingY ?? 0) * 2, node?.height ?? 0);
const x = -w / 2; const x = -w / 2;
const y = -h / 2; const y = -h / 2;
const tagWidth = 0.2 * w; const tagWidth = 0.2 * w;

View File

@@ -14,8 +14,10 @@ export const triangle = async (parent: SVGAElement, node: Node): Promise<SVGAEle
node.labelStyle = labelStyles; node.labelStyle = labelStyles;
const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node)); const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node));
const w = bbox.width + (node.padding ?? 0); const nodePadding = node.padding ?? 0;
const h = w + bbox.height; const labelPaddingX = node.look === 'neo' ? nodePadding * 2 : nodePadding;
const w = Math.max(bbox.width + (labelPaddingX ?? 0), node?.width ?? 0);
const h = Math.max(w + bbox.height, node?.height ?? 0);
const tw = w + bbox.height; const tw = w + bbox.height;
const points = [ const points = [