From 74f708a2ea2ac8ec1a510f85e22263926bb91d92 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sat, 14 Dec 2024 19:35:18 -0700 Subject: [PATCH] allow animated: true for shape --- d2compiler/compile.go | 3 - d2exporter/export.go | 3 + d2renderers/d2svg/d2svg.go | 21 + d2target/d2target.go | 1 + .../txtar/shape-animate/dagre/board.exp.json | 1115 +++++++++++++++++ .../txtar/shape-animate/dagre/sketch.exp.svg | 168 +++ .../txtar/shape-animate/elk/board.exp.json | 906 ++++++++++++++ .../txtar/shape-animate/elk/sketch.exp.svg | 168 +++ e2etests/txtar.txt | 54 + 9 files changed, 2436 insertions(+), 3 deletions(-) create mode 100644 e2etests/testdata/txtar/shape-animate/dagre/board.exp.json create mode 100644 e2etests/testdata/txtar/shape-animate/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/txtar/shape-animate/elk/board.exp.json create mode 100644 e2etests/testdata/txtar/shape-animate/elk/sketch.exp.svg diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 3d46bea2d..65b5ee76e 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -341,9 +341,6 @@ func (c *compiler) compileField(obj *d2graph.Object, f *d2ir.Field) { return } c.compileStyle(&obj.Attributes, f.Map()) - if obj.Style.Animated != nil { - c.errorf(obj.Style.Animated.MapKey, `key "animated" can only be applied to edges`) - } return } diff --git a/d2exporter/export.go b/d2exporter/export.go index 0a078a1ff..8b676e554 100644 --- a/d2exporter/export.go +++ b/d2exporter/export.go @@ -194,6 +194,9 @@ func toShape(obj *d2graph.Object, g *d2graph.Graph) d2target.Shape { if obj.Tooltip != nil { shape.Tooltip = obj.Tooltip.Value } + if obj.Style.Animated != nil { + shape.Animated, _ = strconv.ParseBool(obj.Style.Animated.Value) + } if obj.Link != nil { shape.Link = obj.Link.Value shape.PrettyLink = toPrettyLink(g, obj.Link.Value) diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index ae702341c..cb14ff041 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -975,6 +975,10 @@ func drawShape(writer, appendixWriter io.Writer, diagramHash string, targetShape fmt.Fprint(writer, clipPathForBorderRadius(diagramHash, targetShape)) } classStr := "" + if targetShape.Animated { + // the animated class applies to the whole svg group to include the label, unlike connections + targetShape.Classes = append(targetShape.Classes, "animated-shape") + } if len(targetShape.Classes) > 0 { classStr = fmt.Sprintf(` class="%s"`, strings.Join(targetShape.Classes, " ")) } @@ -1633,6 +1637,23 @@ func EmbedFonts(buf *bytes.Buffer, diagramHash, source string, fontFamily *d2fon `, ) + appendOnTrigger( + buf, + source, + []string{ + `animated-shape`, + }, + ` +@keyframes shapeappear { + 0%, 100% { transform: translateY(0); filter: drop-shadow(0px 0px 0px rgba(0,0,0,0)); } + 50% { transform: translateY(-4px); filter: drop-shadow(0px 12.6px 25.2px rgba(50,50,93,0.25)) drop-shadow(0px 7.56px 15.12px rgba(0,0,0,0.1)); } +} +.animated-shape { + animation: shapeappear 1s linear infinite; +} +`, + ) + appendOnTrigger( buf, source, diff --git a/d2target/d2target.go b/d2target/d2target.go index a2c6d680d..11da29688 100644 --- a/d2target/d2target.go +++ b/d2target/d2target.go @@ -469,6 +469,7 @@ type Shape struct { FillPattern string `json:"fillPattern,omitempty"` Stroke string `json:"stroke"` + Animated bool `json:"animated"` Shadow bool `json:"shadow"` ThreeDee bool `json:"3d"` Multiple bool `json:"multiple"` diff --git a/e2etests/testdata/txtar/shape-animate/dagre/board.exp.json b/e2etests/testdata/txtar/shape-animate/dagre/board.exp.json new file mode 100644 index 000000000..17f451a0e --- /dev/null +++ b/e2etests/testdata/txtar/shape-animate/dagre/board.exp.json @@ -0,0 +1,1115 @@ +{ + "name": "", + "config": { + "sketch": null, + "themeID": 300, + "darkThemeID": null, + "pad": null, + "center": null, + "layoutEngine": "elk" + }, + "isFolderOnly": false, + "fontFamily": "SourceCodePro", + "shapes": [ + { + "id": "network", + "type": "rectangle", + "pos": { + "x": 9, + "y": 227 + }, + "width": 404, + "height": 1198, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B4", + "fillPattern": "dots", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": true, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "NETWORK", + "fontSize": 28, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 116, + "labelHeight": 36, + "labelPosition": "OUTSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "network.cell tower", + "type": "rectangle", + "pos": { + "x": 130, + "y": 268 + }, + "width": 253, + "height": 323, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B5", + "fillPattern": "dots", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "CELL TOWER", + "fontSize": 24, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 143, + "labelHeight": 31, + "labelPosition": "OUTSIDE_TOP_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "network.cell tower.satellites", + "type": "stored_data", + "pos": { + "x": 176, + "y": 308 + }, + "width": 161, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "AA5", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": true, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "SATELLITES", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 96, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 3 + }, + { + "id": "network.cell tower.transmitter", + "type": "rectangle", + "pos": { + "x": 181, + "y": 495 + }, + "width": 151, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B6", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "TRANSMITTER", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 106, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 3 + }, + { + "id": "network.online portal", + "type": "rectangle", + "pos": { + "x": 39, + "y": 1266 + }, + "width": 125, + "height": 129, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B5", + "fillPattern": "dots", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "ONLINE PORTAL", + "fontSize": 24, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 185, + "labelHeight": 31, + "labelPosition": "OUTSIDE_TOP_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "network.online portal.ui", + "type": "hexagon", + "pos": { + "x": 69, + "y": 1296 + }, + "width": 65, + "height": 69, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "N5", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "UI", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 18, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 3 + }, + { + "id": "network.data processor", + "type": "rectangle", + "pos": { + "x": 171, + "y": 742 + }, + "width": 182, + "height": 188, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B5", + "fillPattern": "dots", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "DATA PROCESSOR", + "fontSize": 24, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 200, + "labelHeight": 31, + "labelPosition": "OUTSIDE_TOP_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "network.data processor.storage", + "type": "cylinder", + "pos": { + "x": 201, + "y": 782 + }, + "width": 112, + "height": 118, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "AA5", + "stroke": "B1", + "animated": true, + "shadow": false, + "3d": false, + "multiple": true, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "STORAGE", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 67, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 3 + }, + { + "id": "user", + "type": "person", + "pos": { + "x": 85, + "y": 0 + }, + "width": 130, + "height": 87, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B3", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "USER", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 38, + "labelHeight": 21, + "labelPosition": "OUTSIDE_BOTTOM_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "api server", + "type": "rectangle", + "pos": { + "x": 497, + "y": 1050 + }, + "width": 142, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B6", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "API SERVER", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 97, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "logs", + "type": "page", + "pos": { + "x": 527, + "y": 1287 + }, + "width": 82, + "height": 87, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "AB4", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": true, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "LOGS", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 37, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "network.cell tower.(satellites -> transmitter)[0]", + "src": "network.cell tower.satellites", + "srcArrow": "none", + "dst": "network.cell tower.transmitter", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "label": "SEND", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 38, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 228, + "y": 374 + }, + { + "x": 188.39999389648438, + "y": 422.3999938964844 + }, + { + "x": 188.5, + "y": 446.70001220703125 + }, + { + "x": 228.5, + "y": 495.5 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "network.cell tower.(satellites -> transmitter)[1]", + "src": "network.cell tower.satellites", + "srcArrow": "none", + "dst": "network.cell tower.transmitter", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "label": "SEND", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 38, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 256, + "y": 374 + }, + { + "x": 256.39898681640625, + "y": 422.3999938964844 + }, + { + "x": 256.5, + "y": 446.70001220703125 + }, + { + "x": 256.5, + "y": 495.5 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "network.cell tower.(satellites -> transmitter)[2]", + "src": "network.cell tower.satellites", + "srcArrow": "none", + "dst": "network.cell tower.transmitter", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "label": "SEND", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 38, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 285, + "y": 374 + }, + { + "x": 324.6000061035156, + "y": 422.3999938964844 + }, + { + "x": 324.5, + "y": 446.70001220703125 + }, + { + "x": 284.5, + "y": 495.5 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "network.(cell tower.transmitter -> data processor.storage)[0]", + "src": "network.cell tower.transmitter", + "srcArrow": "none", + "dst": "network.data processor.storage", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "label": "PHONE LOGS", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 96, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 256.5, + "y": 561 + }, + { + "x": 256.5, + "y": 601 + }, + { + "x": 256.5, + "y": 623.0999755859375 + }, + { + "x": 256.5, + "y": 641.25 + }, + { + "x": 256.5, + "y": 659.4000244140625 + }, + { + "x": 256.6000061035156, + "y": 740 + }, + { + "x": 257, + "y": 772 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(user -> network.cell tower)[0]", + "src": "user", + "srcArrow": "none", + "dst": "network.cell tower", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "label": "MAKE CALL", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 86, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 195, + "y": 87 + }, + { + "x": 244.1999969482422, + "y": 135.39999389648438 + }, + { + "x": 256.5, + "y": 212.8000030517578 + }, + { + "x": 256.5, + "y": 232 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(user -> network.online portal.ui)[0]", + "src": "user", + "srcArrow": "none", + "dst": "network.online portal.ui", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 3, + "strokeWidth": 2, + "stroke": "B2", + "label": "ACCESS", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 58, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 119, + "y": 87 + }, + { + "x": 84.80000305175781, + "y": 135.39999389648438 + }, + { + "x": 76.25, + "y": 159.60000610351562 + }, + { + "x": 76.25, + "y": 177.75 + }, + { + "x": 76.25, + "y": 195.89999389648438 + }, + { + "x": 76.25, + "y": 218 + }, + { + "x": 76.25, + "y": 233 + }, + { + "x": 76.25, + "y": 248 + }, + { + "x": 76.25, + "y": 274.6000061035156 + }, + { + "x": 76.25, + "y": 299.5 + }, + { + "x": 76.25, + "y": 324.3999938964844 + }, + { + "x": 76.25, + "y": 359.70001220703125 + }, + { + "x": 76.25, + "y": 387.75 + }, + { + "x": 76.25, + "y": 415.79998779296875 + }, + { + "x": 76.25, + "y": 453.20001220703125 + }, + { + "x": 76.25, + "y": 481.25 + }, + { + "x": 76.25, + "y": 509.29998779296875 + }, + { + "x": 76.25, + "y": 544.5999755859375 + }, + { + "x": 76.25, + "y": 569.5 + }, + { + "x": 76.25, + "y": 594.4000244140625 + }, + { + "x": 76.25, + "y": 623.0999755859375 + }, + { + "x": 76.25, + "y": 641.25 + }, + { + "x": 76.25, + "y": 659.4000244140625 + }, + { + "x": 76.25, + "y": 683.5999755859375 + }, + { + "x": 76.25, + "y": 701.75 + }, + { + "x": 76.25, + "y": 719.9000244140625 + }, + { + "x": 76.25, + "y": 753.7999877929688 + }, + { + "x": 76.25, + "y": 786.5 + }, + { + "x": 76.25, + "y": 819.2000122070312 + }, + { + "x": 76.25, + "y": 862.7999877929688 + }, + { + "x": 76.25, + "y": 895.5 + }, + { + "x": 76.25, + "y": 928.2000122070312 + }, + { + "x": 76.25, + "y": 960 + }, + { + "x": 76.25, + "y": 975 + }, + { + "x": 76.25, + "y": 990 + }, + { + "x": 76.25, + "y": 1016.5999755859375 + }, + { + "x": 76.25, + "y": 1041.5 + }, + { + "x": 76.25, + "y": 1066.4000244140625 + }, + { + "x": 76.25, + "y": 1101.699951171875 + }, + { + "x": 76.25, + "y": 1129.75 + }, + { + "x": 76.25, + "y": 1157.800048828125 + }, + { + "x": 79.4000015258789, + "y": 1248.800048828125 + }, + { + "x": 92, + "y": 1296 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(api server -> network.online portal.ui)[0]", + "src": "api server", + "srcArrow": "none", + "dst": "network.online portal.ui", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "label": "DISPLAY", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 69, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 496.75, + "y": 1098.9189453125 + }, + { + "x": 203.9499969482422, + "y": 1160.9830322265625 + }, + { + "x": 127, + "y": 1248.800048828125 + }, + { + "x": 112, + "y": 1296 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(api server -> logs)[0]", + "src": "api server", + "srcArrow": "none", + "dst": "logs", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "label": "PERSIST", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 68, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 567.75, + "y": 1115.5 + }, + { + "x": 567.75, + "y": 1164.300048828125 + }, + { + "x": 567.7999877929688, + "y": 1245 + }, + { + "x": 568, + "y": 1277 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(network.data processor -> api server)[0]", + "src": "network.data processor", + "srcArrow": "none", + "dst": "api server", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "label": "", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 256.5, + "y": 930 + }, + { + "x": 256.5, + "y": 986 + }, + { + "x": 304.54998779296875, + "y": 1012.552978515625 + }, + { + "x": 496.75, + "y": 1062.7659912109375 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ], + "root": { + "id": "", + "type": "", + "pos": { + "x": 0, + "y": 0 + }, + "width": 0, + "height": 0, + "opacity": 0, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "N7", + "stroke": "", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 0 + } +} diff --git a/e2etests/testdata/txtar/shape-animate/dagre/sketch.exp.svg b/e2etests/testdata/txtar/shape-animate/dagre/sketch.exp.svg new file mode 100644 index 000000000..4f3f5774a --- /dev/null +++ b/e2etests/testdata/txtar/shape-animate/dagre/sketch.exp.svg @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +NETWORKUSERAPI SERVERLOGSCELL TOWERONLINE PORTALDATA PROCESSORSATELLITESTRANSMITTERUISTORAGE SENDSENDSENDPHONE LOGSMAKE CALL ACCESSDISPLAYPERSIST + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/e2etests/testdata/txtar/shape-animate/elk/board.exp.json b/e2etests/testdata/txtar/shape-animate/elk/board.exp.json new file mode 100644 index 000000000..54216fb87 --- /dev/null +++ b/e2etests/testdata/txtar/shape-animate/elk/board.exp.json @@ -0,0 +1,906 @@ +{ + "name": "", + "config": { + "sketch": null, + "themeID": 300, + "darkThemeID": null, + "pad": null, + "center": null, + "layoutEngine": "elk" + }, + "isFolderOnly": false, + "fontFamily": "SourceCodePro", + "shapes": [ + { + "id": "network", + "type": "rectangle", + "pos": { + "x": 12, + "y": 311 + }, + "width": 621, + "height": 922, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B4", + "fillPattern": "dots", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": true, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "NETWORK", + "fontSize": 28, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 116, + "labelHeight": 36, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "network.cell tower", + "type": "rectangle", + "pos": { + "x": 62, + "y": 361 + }, + "width": 271, + "height": 423, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B5", + "fillPattern": "dots", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "CELL TOWER", + "fontSize": 24, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 143, + "labelHeight": 31, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "network.cell tower.satellites", + "type": "stored_data", + "pos": { + "x": 112, + "y": 421 + }, + "width": 161, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "AA5", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": true, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "SATELLITES", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 96, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 3 + }, + { + "id": "network.cell tower.transmitter", + "type": "rectangle", + "pos": { + "x": 122, + "y": 668 + }, + "width": 151, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B6", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "TRANSMITTER", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 106, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 3 + }, + { + "id": "network.online portal", + "type": "rectangle", + "pos": { + "x": 353, + "y": 366 + }, + "width": 230, + "height": 169, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B5", + "fillPattern": "dots", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "ONLINE PORTAL", + "fontSize": 24, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 185, + "labelHeight": 31, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "network.online portal.ui", + "type": "hexagon", + "pos": { + "x": 428, + "y": 416 + }, + "width": 80, + "height": 69, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "N5", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "UI", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 18, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 3 + }, + { + "id": "network.data processor", + "type": "rectangle", + "pos": { + "x": 75, + "y": 955 + }, + "width": 245, + "height": 228, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B5", + "fillPattern": "dots", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "DATA PROCESSOR", + "fontSize": 24, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 200, + "labelHeight": 31, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "network.data processor.storage", + "type": "cylinder", + "pos": { + "x": 136, + "y": 1015 + }, + "width": 112, + "height": 118, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "AA5", + "stroke": "B1", + "animated": true, + "shadow": false, + "3d": false, + "multiple": true, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "STORAGE", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 67, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 3 + }, + { + "id": "user", + "type": "person", + "pos": { + "x": 218, + "y": 12 + }, + "width": 130, + "height": 87, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B3", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "USER", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 38, + "labelHeight": 21, + "labelPosition": "OUTSIDE_BOTTOM_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "api server", + "type": "rectangle", + "pos": { + "x": 341, + "y": 1388 + }, + "width": 142, + "height": 66, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "B6", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "API SERVER", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 97, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "logs", + "type": "page", + "pos": { + "x": 366, + "y": 1625 + }, + "width": 82, + "height": 87, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "AB4", + "stroke": "B1", + "animated": false, + "shadow": false, + "3d": false, + "multiple": true, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "LOGS", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N1", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 37, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "network.cell tower.(satellites -> transmitter)[0]", + "src": "network.cell tower.satellites", + "srcArrow": "none", + "dst": "network.cell tower.transmitter", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "label": "SEND", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 38, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 148, + "y": 487 + }, + { + "x": 148.5, + "y": 668 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "network.cell tower.(satellites -> transmitter)[1]", + "src": "network.cell tower.satellites", + "srcArrow": "none", + "dst": "network.cell tower.transmitter", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "label": "SEND", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 38, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 197, + "y": 487 + }, + { + "x": 198, + "y": 668 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "network.cell tower.(satellites -> transmitter)[2]", + "src": "network.cell tower.satellites", + "srcArrow": "none", + "dst": "network.cell tower.transmitter", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "label": "SEND", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 38, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 246, + "y": 487 + }, + { + "x": 246.5, + "y": 668 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "network.(cell tower.transmitter -> data processor.storage)[0]", + "src": "network.cell tower.transmitter", + "srcArrow": "none", + "dst": "network.data processor.storage", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "label": "PHONE LOGS", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 96, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 197.5, + "y": 734 + }, + { + "x": 198, + "y": 1005 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(user -> network.cell tower)[0]", + "src": "user", + "srcArrow": "none", + "dst": "network.cell tower", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "label": "MAKE CALL", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 86, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 261.6659851074219, + "y": 125 + }, + { + "x": 261.6659851074219, + "y": 165 + }, + { + "x": 117.91600036621094, + "y": 165 + }, + { + "x": 117.91600036621094, + "y": 361 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(user -> network.online portal.ui)[0]", + "src": "user", + "srcArrow": "none", + "dst": "network.online portal.ui", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 3, + "strokeWidth": 2, + "stroke": "B2", + "label": "ACCESS", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 58, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 305, + "y": 125 + }, + { + "x": 305, + "y": 165 + }, + { + "x": 448.75, + "y": 165 + }, + { + "x": 449, + "y": 416 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(api server -> network.online portal.ui)[0]", + "src": "api server", + "srcArrow": "none", + "dst": "network.online portal.ui", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "label": "DISPLAY", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 69, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 435.6659851074219, + "y": 1388 + }, + { + "x": 435.6659851074219, + "y": 1348 + }, + { + "x": 687.5, + "y": 1348 + }, + { + "x": 687.5, + "y": 266 + }, + { + "x": 481.3330078125, + "y": 266 + }, + { + "x": 481, + "y": 416 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(api server -> logs)[0]", + "src": "api server", + "srcArrow": "none", + "dst": "logs", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "label": "PERSIST", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 68, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 412, + "y": 1454 + }, + { + "x": 412, + "y": 1615 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(network.data processor -> api server)[0]", + "src": "network.data processor", + "srcArrow": "none", + "dst": "api server", + "dstArrow": "triangle", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "B1", + "label": "", + "fontSize": 16, + "fontFamily": "mono", + "language": "", + "color": "N2", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "link": "", + "route": [ + { + "x": 136.5, + "y": 1183 + }, + { + "x": 136.5, + "y": 1348 + }, + { + "x": 388.3330078125, + "y": 1348 + }, + { + "x": 388.3330078125, + "y": 1388 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ], + "root": { + "id": "", + "type": "", + "pos": { + "x": 0, + "y": 0 + }, + "width": 0, + "height": 0, + "opacity": 0, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "N7", + "stroke": "", + "animated": false, + "shadow": false, + "3d": false, + "multiple": false, + "double-border": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 0 + } +} diff --git a/e2etests/testdata/txtar/shape-animate/elk/sketch.exp.svg b/e2etests/testdata/txtar/shape-animate/elk/sketch.exp.svg new file mode 100644 index 000000000..25e22380c --- /dev/null +++ b/e2etests/testdata/txtar/shape-animate/elk/sketch.exp.svg @@ -0,0 +1,168 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +NETWORKUSERAPI SERVERLOGSCELL TOWERONLINE PORTALDATA PROCESSORSATELLITESTRANSMITTERUISTORAGE SENDSENDSENDPHONE LOGSMAKE CALL ACCESSDISPLAYPERSIST + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/e2etests/txtar.txt b/e2etests/txtar.txt index d3560277d..004b0eae7 100644 --- a/e2etests/txtar.txt +++ b/e2etests/txtar.txt @@ -684,3 +684,57 @@ layers: { d } } + +-- shape-animate -- +vars: { + d2-config: { + layout-engine: elk + # Terminal theme code + theme-id: 300 + } +} +network: { + cell tower: { + satellites: { + shape: stored_data + style.multiple: true + } + + transmitter + + satellites -> transmitter: send + satellites -> transmitter: send + satellites -> transmitter: send + } + + online portal: { + ui: {shape: hexagon} + } + + data processor: { + storage: { + style.animated: true + shape: cylinder + style.multiple: true + } + } + + cell tower.transmitter -> data processor.storage: phone logs +} + +user: { + shape: person + width: 130 +} + +user -> network.cell tower: make call +user -> network.online portal.ui: access { + style.stroke-dash: 3 +} + +api server -> network.online portal.ui: display +api server -> logs: persist +logs: {shape: page; style.multiple: true} + +network.data processor -> api server +