fix for min size for more shapes

This commit is contained in:
Ashish Jain
2024-10-02 09:45:55 +02:00
parent f1674b8b04
commit a2d64a82c5
3 changed files with 39 additions and 34 deletions

View File

@@ -40,26 +40,26 @@ export const curlyBraceLeft = async (parent: SVGAElement, node: Node) => {
const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node)); const { shapeSvg, bbox, label } = await labelHelper(parent, node, getNodeClasses(node));
const paddingX = node.look === 'neo' ? (node.padding ?? 0) * 2 : (node.padding ?? 0); const paddingX = node.look === 'neo' ? (node.padding ?? 0) * 2 : (node.padding ?? 0);
const paddingY = node.look === 'neo' ? (node.padding ?? 0) * 1 : (node.padding ?? 0); const paddingY = node.look === 'neo' ? (node.padding ?? 0) * 1 : (node.padding ?? 0);
if (node.width || node.height) { if (node.width || node.height) {
node.width = (node?.width ?? 0) - paddingX * 2; let radius = 5;
if (node.width < 50) { const cal_height = (((node?.height ?? 0) - paddingY * 2) * 10) / 11;
node.width = 50; if (cal_height / 10 > 5) {
radius = cal_height / 10;
} }
// Adjustments for circular arc node.height = (node?.height ?? 0) - paddingY * 2 - 2 * radius;
const radiusAdjustment = Math.max(5, (node.height ?? 0) * 0.16667); if (node.height < 10) {
node.height = 10;
node.height = (node?.height ?? 0) - paddingY * 2 - radiusAdjustment; }
if (node.height < 50) { node.width = (node?.width ?? 0) - paddingX * 2 - 2 * radius;
node.height = 50; if (node.width < 10) {
node.width = 10;
} }
} }
const w = Math.max(bbox.width, node.width ?? 0) + (paddingX ?? 0) * 2; const w = (node.width ? node.width : bbox.width) + (paddingX ?? 0) * 2;
const h = Math.max(bbox.height, node.height ?? 0) + (paddingY ?? 0) * 2; const h = (node.height ? node.height : bbox.height) + (paddingY ?? 0) * 2;
const radius = Math.max(5, h * 0.1); const radius = Math.max(5, h * 0.1);
const { cssStyles } = node; const { cssStyles } = node;
const points = [ const points = [

View File

@@ -42,22 +42,25 @@ export const curlyBraceRight = async (parent: SVGAElement, node: Node) => {
const labelPaddingY = node.look === 'neo' ? (node.padding ?? 0) * 1 : (node.padding ?? 0); const labelPaddingY = node.look === 'neo' ? (node.padding ?? 0) * 1 : (node.padding ?? 0);
if (node.width || node.height) { if (node.width || node.height) {
node.width = (node?.width ?? 0) - labelPaddingX * 2; let radius = 5;
if (node.width < 50) { const cal_height = (((node?.height ?? 0) - labelPaddingY * 2) * 10) / 11;
node.width = 50; if (cal_height / 10 > 5) {
radius = cal_height / 10;
} }
// Adjustments for circular arc node.width = (node?.width ?? 0) - labelPaddingX * 2 - radius * 2;
const radiusAdjustment = Math.max(5, (node.height ?? 0) * 0.16667); if (node.width < 10) {
node.width = 10;
}
node.height = (node?.height ?? 0) - labelPaddingY * 2 - radiusAdjustment; node.height = (node?.height ?? 0) - labelPaddingY * 2 - radius * 2;
if (node.height < 50) { if (node.height < 10) {
node.height = 50; node.height = 10;
} }
} }
const w = Math.max(bbox.width, node.width ?? 0) + (labelPaddingX ?? 0) * 2; const w = (node.width ? node.width : bbox.width) + (labelPaddingX ?? 0) * 2;
const h = Math.max(bbox.height, node.height ?? 0) + (labelPaddingY ?? 0) * 2; const h = (node.height ? node.height : bbox.height) + (labelPaddingY ?? 0) * 2;
const radius = Math.max(5, h * 0.1); const radius = Math.max(5, h * 0.1);
const { cssStyles } = node; const { cssStyles } = node;

View File

@@ -42,24 +42,26 @@ export const curlyBraces = async (parent: SVGAElement, node: Node) => {
const labelPaddingY = node.look === 'neo' ? (node.padding ?? 0) * 1 : (node.padding ?? 0); const labelPaddingY = node.look === 'neo' ? (node.padding ?? 0) * 1 : (node.padding ?? 0);
if (node.width || node.height) { if (node.width || node.height) {
node.width = (node?.width ?? 0) - labelPaddingX * 2; let radius = 5;
if (node.width < 50) { const cal_height = (((node?.height ?? 0) - labelPaddingY * 2) * 10) / 11;
node.width = 50; if (cal_height / 10 > 5) {
radius = cal_height / 10;
} }
// Adjustments for circular arc node.width = (node?.width ?? 0) - labelPaddingX * 2 - radius * 2.5;
const radiusAdjustment = Math.max(5, (node.height ?? 0) * 0.16667); if (node.width < 10) {
node.width = 10;
}
node.height = (node?.height ?? 0) - labelPaddingY * 2 - radiusAdjustment; node.height = (node?.height ?? 0) - labelPaddingY * 2 - radius * 2;
if (node.height < 50) { if (node.height < 10) {
node.height = 50; node.height = 10;
} }
} }
const w = Math.max(bbox.width, node.width ?? 0) + (labelPaddingX ?? 0) * 2; const w = (node.width ? node.width : bbox.width) + (labelPaddingX ?? 0) * 2;
const h = Math.max(bbox.height, node.height ?? 0) + (labelPaddingY ?? 0) * 2; const h = (node.height ? node.height : bbox.height) + (labelPaddingY ?? 0) * 2;
const radius = Math.max(5, h * 0.1); const radius = Math.max(5, h * 0.1);
const { cssStyles } = node; const { cssStyles } = node;
const leftCurlyBracePoints = [ const leftCurlyBracePoints = [