From c1313c7480aa4af8cdb14eb06bdec48b8d2c77f6 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Mon, 13 Feb 2023 11:19:06 -0800 Subject: [PATCH 1/4] add ovals e2e test --- e2etests/stable_test.go | 35 ++ .../stable/ovals/dagre/board.exp.json | 499 ++++++++++++++++++ .../stable/ovals/dagre/sketch.exp.svg | 52 ++ .../testdata/stable/ovals/elk/board.exp.json | 499 ++++++++++++++++++ .../testdata/stable/ovals/elk/sketch.exp.svg | 52 ++ 5 files changed, 1137 insertions(+) create mode 100644 e2etests/testdata/stable/ovals/dagre/board.exp.json create mode 100644 e2etests/testdata/stable/ovals/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/stable/ovals/elk/board.exp.json create mode 100644 e2etests/testdata/stable/ovals/elk/sketch.exp.svg diff --git a/e2etests/stable_test.go b/e2etests/stable_test.go index bca51d2e7..757b8df54 100644 --- a/e2etests/stable_test.go +++ b/e2etests/stable_test.go @@ -2069,6 +2069,41 @@ g: ---------------------------------------------------------------- 3.width: 128 4.width: 512 +# entering both width and height overrides aspect ratio limit +5.height: 256 +5.width: 32 +`, + }, + { + name: "ovals", + script: ` +a.shape: oval +b.shape: oval +c.shape: oval +d.shape: oval +e.shape: oval +f.shape: oval +g.shape: oval + +a: - +b: -- +c: ---- +d: -------- +e: ---------------- +f: -------------------------------- +g: ---------------------------------------------------------------- + +1.shape: oval +2.shape: oval +3.shape: oval +4.shape: oval +5.shape: oval + +1.width: 16 +2.width: 64 +3.width: 128 +4.width: 512 + # entering both width and height overrides aspect ratio limit 5.height: 256 5.width: 32 diff --git a/e2etests/testdata/stable/ovals/dagre/board.exp.json b/e2etests/testdata/stable/ovals/dagre/board.exp.json new file mode 100644 index 000000000..404f1902f --- /dev/null +++ b/e2etests/testdata/stable/ovals/dagre/board.exp.json @@ -0,0 +1,499 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "a", + "type": "oval", + "pos": { + "x": 1052, + "y": 83 + }, + "width": 35, + "height": 90, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "-", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 5, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "b", + "type": "oval", + "pos": { + "x": 1147, + "y": 86 + }, + "width": 53, + "height": 85, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "--", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 11, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "c", + "type": "oval", + "pos": { + "x": 1260, + "y": 90 + }, + "width": 77, + "height": 77, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "----", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 21, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "d", + "type": "oval", + "pos": { + "x": 1397, + "y": 96 + }, + "width": 118, + "height": 64, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "--------", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 43, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "e", + "type": "oval", + "pos": { + "x": 1575, + "y": 102 + }, + "width": 182, + "height": 53, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "----------------", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 85, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "f", + "type": "oval", + "pos": { + "x": 1817, + "y": 105 + }, + "width": 304, + "height": 46, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "--------------------------------", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 170, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "g", + "type": "oval", + "pos": { + "x": 2181, + "y": 107 + }, + "width": 545, + "height": 42, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "----------------------------------------------------------------", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 340, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "1", + "type": "oval", + "pos": { + "x": 0, + "y": 86 + }, + "width": 16, + "height": 84, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "1", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 7, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "2", + "type": "oval", + "pos": { + "x": 76, + "y": 87 + }, + "width": 64, + "height": 83, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "2", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 8, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "3", + "type": "oval", + "pos": { + "x": 200, + "y": 87 + }, + "width": 128, + "height": 83, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "3", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 8, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "4", + "type": "oval", + "pos": { + "x": 388, + "y": 87 + }, + "width": 512, + "height": 82, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "4", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 9, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "5", + "type": "oval", + "pos": { + "x": 960, + "y": 0 + }, + "width": 32, + "height": 256, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "5", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 8, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [] +} diff --git a/e2etests/testdata/stable/ovals/dagre/sketch.exp.svg b/e2etests/testdata/stable/ovals/dagre/sketch.exp.svg new file mode 100644 index 000000000..4b48bbaf7 --- /dev/null +++ b/e2etests/testdata/stable/ovals/dagre/sketch.exp.svg @@ -0,0 +1,52 @@ + +-------------------------------------------------------------------------------------------------------------------------------12345 + + + \ No newline at end of file diff --git a/e2etests/testdata/stable/ovals/elk/board.exp.json b/e2etests/testdata/stable/ovals/elk/board.exp.json new file mode 100644 index 000000000..531fe7841 --- /dev/null +++ b/e2etests/testdata/stable/ovals/elk/board.exp.json @@ -0,0 +1,499 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "a", + "type": "oval", + "pos": { + "x": 12, + "y": 95 + }, + "width": 35, + "height": 90, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "-", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 5, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "b", + "type": "oval", + "pos": { + "x": 67, + "y": 97 + }, + "width": 53, + "height": 85, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "--", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 11, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "c", + "type": "oval", + "pos": { + "x": 140, + "y": 101 + }, + "width": 77, + "height": 77, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "----", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 21, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "d", + "type": "oval", + "pos": { + "x": 237, + "y": 108 + }, + "width": 118, + "height": 64, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "--------", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 43, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "e", + "type": "oval", + "pos": { + "x": 375, + "y": 113 + }, + "width": 182, + "height": 53, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "----------------", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 85, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "f", + "type": "oval", + "pos": { + "x": 577, + "y": 117 + }, + "width": 304, + "height": 46, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "--------------------------------", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 170, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "g", + "type": "oval", + "pos": { + "x": 901, + "y": 119 + }, + "width": 545, + "height": 42, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "----------------------------------------------------------------", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 340, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "1", + "type": "oval", + "pos": { + "x": 1466, + "y": 98 + }, + "width": 16, + "height": 84, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "1", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 7, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "2", + "type": "oval", + "pos": { + "x": 1502, + "y": 98 + }, + "width": 64, + "height": 83, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "2", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 8, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "3", + "type": "oval", + "pos": { + "x": 1586, + "y": 98 + }, + "width": 128, + "height": 83, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "3", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 8, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "4", + "type": "oval", + "pos": { + "x": 1734, + "y": 99 + }, + "width": 512, + "height": 82, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "4", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 9, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "5", + "type": "oval", + "pos": { + "x": 2266, + "y": 12 + }, + "width": 32, + "height": 256, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "5", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 8, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [] +} diff --git a/e2etests/testdata/stable/ovals/elk/sketch.exp.svg b/e2etests/testdata/stable/ovals/elk/sketch.exp.svg new file mode 100644 index 000000000..5f425052e --- /dev/null +++ b/e2etests/testdata/stable/ovals/elk/sketch.exp.svg @@ -0,0 +1,52 @@ + +-------------------------------------------------------------------------------------------------------------------------------12345 + + + \ No newline at end of file From 4de1f767510b48dad5dc4cac613a6fb0f9090e04 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Mon, 13 Feb 2023 11:16:26 -0800 Subject: [PATCH 2/4] limit oval shape aspect ratio --- d2graph/d2graph.go | 5 ++++- d2layouts/d2sequence/sequence_diagram.go | 2 +- lib/shape/shape_oval.go | 8 +++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index d907c1999..317e30eee 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -1296,8 +1296,11 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler obj.Width = sideLength obj.Height = sideLength } else if desiredHeight == 0 || desiredWidth == 0 { - if s.GetType() == shape.PERSON_TYPE { + switch s.GetType() { + case shape.PERSON_TYPE: obj.Width, obj.Height = shape.LimitAR(obj.Width, obj.Height, shape.PERSON_AR_LIMIT) + case shape.OVAL_TYPE: + obj.Width, obj.Height = shape.LimitAR(obj.Width, obj.Height, shape.OVAL_AR_LIMIT) } } } diff --git a/d2layouts/d2sequence/sequence_diagram.go b/d2layouts/d2sequence/sequence_diagram.go index 53cdc8e86..cac36e113 100644 --- a/d2layouts/d2sequence/sequence_diagram.go +++ b/d2layouts/d2sequence/sequence_diagram.go @@ -107,7 +107,7 @@ func newSequenceDiagram(objects []*d2graph.Object, messages []*d2graph.Edge) *se if actor.Width < MIN_ACTOR_WIDTH { dslShape := strings.ToLower(actor.Attributes.Shape.Value) switch dslShape { - case d2target.ShapePerson, d2target.ShapeSquare, d2target.ShapeCircle: + case d2target.ShapePerson, d2target.ShapeOval, d2target.ShapeSquare, d2target.ShapeCircle: // scale shape up to min width uniformly actor.Height *= MIN_ACTOR_WIDTH / actor.Width } diff --git a/lib/shape/shape_oval.go b/lib/shape/shape_oval.go index 9e75242eb..8e035f845 100644 --- a/lib/shape/shape_oval.go +++ b/lib/shape/shape_oval.go @@ -7,6 +7,8 @@ import ( "oss.terrastruct.com/util-go/go2" ) +const OVAL_AR_LIMIT = 3. + type shapeOval struct { *baseShape } @@ -38,7 +40,11 @@ func (s shapeOval) GetDimensionsToFit(width, height, paddingX, paddingY float64) paddedWidth := width + paddingX*math.Cos(theta) paddedHeight := height + paddingY*math.Sin(theta) // see https://stackoverflow.com/questions/433371/ellipse-bounding-a-rectangle - return math.Ceil(math.Sqrt2 * paddedWidth), math.Ceil(math.Sqrt2 * paddedHeight) + totalWidth, totalHeight := math.Ceil(math.Sqrt2*paddedWidth), math.Ceil(math.Sqrt2*paddedHeight) + + // prevent oval from becoming too flat + totalWidth, totalHeight = LimitAR(totalWidth, totalHeight, OVAL_AR_LIMIT) + return totalWidth, totalHeight } func (s shapeOval) GetInsidePlacement(width, height, paddingX, paddingY float64) geo.Point { From 491049766cfcbde62d8ffa6ed089b286d7b60f5d Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Mon, 13 Feb 2023 11:25:28 -0800 Subject: [PATCH 3/4] update tests --- .../stable/ovals/dagre/board.exp.json | 40 +++++++++---------- .../stable/ovals/dagre/sketch.exp.svg | 6 +-- .../testdata/stable/ovals/elk/board.exp.json | 26 ++++++------ .../testdata/stable/ovals/elk/sketch.exp.svg | 6 +-- .../dagre/board.exp.json | 4 +- .../dagre/sketch.exp.svg | 4 +- .../elk/board.exp.json | 4 +- .../elk/sketch.exp.svg | 4 +- 8 files changed, 47 insertions(+), 47 deletions(-) diff --git a/e2etests/testdata/stable/ovals/dagre/board.exp.json b/e2etests/testdata/stable/ovals/dagre/board.exp.json index 404f1902f..d02eb88a7 100644 --- a/e2etests/testdata/stable/ovals/dagre/board.exp.json +++ b/e2etests/testdata/stable/ovals/dagre/board.exp.json @@ -6,7 +6,7 @@ "id": "a", "type": "oval", "pos": { - "x": 1052, + "x": 1064, "y": 83 }, "width": 35, @@ -47,7 +47,7 @@ "id": "b", "type": "oval", "pos": { - "x": 1147, + "x": 1159, "y": 86 }, "width": 53, @@ -88,7 +88,7 @@ "id": "c", "type": "oval", "pos": { - "x": 1260, + "x": 1272, "y": 90 }, "width": 77, @@ -129,7 +129,7 @@ "id": "d", "type": "oval", "pos": { - "x": 1397, + "x": 1409, "y": 96 }, "width": 118, @@ -170,11 +170,11 @@ "id": "e", "type": "oval", "pos": { - "x": 1575, - "y": 102 + "x": 1587, + "y": 98 }, "width": 182, - "height": 53, + "height": 61, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -211,11 +211,11 @@ "id": "f", "type": "oval", "pos": { - "x": 1817, - "y": 105 + "x": 1829, + "y": 78 }, "width": 304, - "height": 46, + "height": 101, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -252,11 +252,11 @@ "id": "g", "type": "oval", "pos": { - "x": 2181, - "y": 107 + "x": 2193, + "y": 37 }, "width": 545, - "height": 42, + "height": 182, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -296,7 +296,7 @@ "x": 0, "y": 86 }, - "width": 16, + "width": 28, "height": 84, "opacity": 1, "strokeDash": 0, @@ -334,7 +334,7 @@ "id": "2", "type": "oval", "pos": { - "x": 76, + "x": 88, "y": 87 }, "width": 64, @@ -375,7 +375,7 @@ "id": "3", "type": "oval", "pos": { - "x": 200, + "x": 212, "y": 87 }, "width": 128, @@ -416,11 +416,11 @@ "id": "4", "type": "oval", "pos": { - "x": 388, - "y": 87 + "x": 400, + "y": 43 }, "width": 512, - "height": 82, + "height": 171, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -457,7 +457,7 @@ "id": "5", "type": "oval", "pos": { - "x": 960, + "x": 972, "y": 0 }, "width": 32, diff --git a/e2etests/testdata/stable/ovals/dagre/sketch.exp.svg b/e2etests/testdata/stable/ovals/dagre/sketch.exp.svg index 4b48bbaf7..9020ec05e 100644 --- a/e2etests/testdata/stable/ovals/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/ovals/dagre/sketch.exp.svg @@ -3,7 +3,7 @@ id="d2-svg" style="background: white;" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" -width="2930" height="460" viewBox="-102 -102 2930 460">