From 23097370e2c02a421e4da25679315cc156329521 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Fri, 20 Jan 2023 20:04:59 -0800 Subject: [PATCH 01/35] set up shape specific inner bounding boxes for labels --- d2graph/d2graph.go | 15 +++++-- d2renderers/d2svg/d2svg.go | 49 +++++++++++++---------- lib/shape/shape.go | 13 ++++++ lib/shape/shape_callout.go | 53 ++++++++++++++++++------- lib/shape/shape_circle.go | 14 ++++++- lib/shape/shape_cloud.go | 20 ++++++++++ lib/shape/shape_cylinder.go | 57 +++++++++++++++----------- lib/shape/shape_diamond.go | 19 +++++++++ lib/shape/shape_document.go | 28 ++++++++++--- lib/shape/shape_hexagon.go | 15 +++++++ lib/shape/shape_oval.go | 17 ++++++++ lib/shape/shape_package.go | 55 +++++++++++++++++++------- lib/shape/shape_page.go | 68 +++++++++++++++++++++----------- lib/shape/shape_parallelogram.go | 20 +++++++++- lib/shape/shape_person.go | 24 +++++++++++ lib/shape/shape_queue.go | 53 ++++++++++++++----------- lib/shape/shape_step.go | 15 +++++++ lib/shape/shape_stored_data.go | 19 ++++++++- 18 files changed, 427 insertions(+), 127 deletions(-) diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 06411bc21..c90ee7607 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -18,6 +18,7 @@ import ( "oss.terrastruct.com/d2/d2target" "oss.terrastruct.com/d2/d2themes" "oss.terrastruct.com/d2/lib/geo" + "oss.terrastruct.com/d2/lib/shape" "oss.terrastruct.com/d2/lib/textmeasure" ) @@ -1117,14 +1118,14 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler continue } - shapeType := strings.ToLower(obj.Attributes.Shape.Value) + dslShape := strings.ToLower(obj.Attributes.Shape.Value) labelDims, err := obj.GetLabelSize(mtexts, ruler, fontFamily) if err != nil { return err } - switch shapeType { + switch dslShape { case d2target.ShapeText, d2target.ShapeClass, d2target.ShapeSQLTable, d2target.ShapeCode: // no labels default: @@ -1134,7 +1135,7 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler } } - if shapeType != d2target.ShapeText && obj.Attributes.Label.Value != "" { + if dslShape != d2target.ShapeText && obj.Attributes.Label.Value != "" { labelDims.Width += INNER_LABEL_PADDING labelDims.Height += INNER_LABEL_PADDING } @@ -1150,7 +1151,7 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler paddingX, paddingY := obj.GetPadding() - switch shapeType { + switch dslShape { case d2target.ShapeSquare, d2target.ShapeCircle: if desiredWidth != 0 || desiredHeight != 0 { paddingX = 0. @@ -1169,6 +1170,12 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler obj.Height += float64(paddingY) } } + contentBox := geo.NewBox(geo.NewPoint(0, 0), float64(defaultDims.Width), float64(defaultDims.Height)) + shapeType := d2target.DSL_SHAPE_TO_SHAPE_TYPE[dslShape] + s := shape.NewShape(shapeType, contentBox) + newWidth, newHeight := s.GetDimensionsToFit(contentBox.Width, contentBox.Height, paddingX/2) + obj.Width = newWidth + obj.Height = newHeight } for _, edge := range g.Edges { endpointLabels := []string{} diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index e5a3412e4..eac72d4a4 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -42,7 +42,7 @@ const ( appendixIconRadius = 16 ) -var multipleOffset = geo.NewVector(10, -10) +var multipleOffset = geo.NewVector(d2target.MULTIPLE_OFFSET, -d2target.MULTIPLE_OFFSET) //go:embed tooltip.svg var TooltipIcon string @@ -734,7 +734,7 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske var multipleTL *geo.Point if targetShape.Multiple { - multipleTL = tl.AddVector(geo.NewVector(d2target.MULTIPLE_OFFSET, -d2target.MULTIPLE_OFFSET)) + multipleTL = tl.AddVector(multipleOffset) } switch targetShape.Type { @@ -744,13 +744,13 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske if err != nil { return "", err } - fmt.Fprintf(writer, out) + fmt.Fprint(writer, out) } else { drawClass(writer, targetShape) } addAppendixItems(writer, targetShape) - fmt.Fprintf(writer, ``) - fmt.Fprintf(writer, closingTag) + fmt.Fprint(writer, ``) + fmt.Fprint(writer, closingTag) return labelMask, nil case d2target.ShapeSQLTable: if sketchRunner != nil { @@ -758,13 +758,13 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske if err != nil { return "", err } - fmt.Fprintf(writer, out) + fmt.Fprint(writer, out) } else { drawTable(writer, targetShape) } addAppendixItems(writer, targetShape) - fmt.Fprintf(writer, ``) - fmt.Fprintf(writer, closingTag) + fmt.Fprint(writer, ``) + fmt.Fprint(writer, closingTag) return labelMask, nil case d2target.ShapeOval: if targetShape.DoubleBorder { @@ -776,7 +776,7 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske if err != nil { return "", err } - fmt.Fprintf(writer, out) + fmt.Fprint(writer, out) } else { fmt.Fprint(writer, renderDoubleOval(tl, width, height, style)) } @@ -789,12 +789,17 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske if err != nil { return "", err } - fmt.Fprintf(writer, out) + fmt.Fprint(writer, out) } else { fmt.Fprint(writer, renderOval(tl, width, height, style)) } } + // debugging + for _, pathData := range s.GetSVGPathData() { + fmt.Fprintf(writer, ``, pathData, style) + } + case d2target.ShapeImage: fmt.Fprintf(writer, ``, html.EscapeString(targetShape.Icon.String()), @@ -815,7 +820,7 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske if err != nil { return "", err } - fmt.Fprintf(writer, out) + fmt.Fprint(writer, out) } else { fmt.Fprintf(writer, ``, targetShape.Pos.X, targetShape.Pos.Y, targetShape.Width, targetShape.Height, style) @@ -832,7 +837,7 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske if err != nil { return "", err } - fmt.Fprintf(writer, out) + fmt.Fprint(writer, out) } else { fmt.Fprintf(writer, ``, targetShape.Pos.X, targetShape.Pos.Y, targetShape.Width, targetShape.Height, style) @@ -855,7 +860,7 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske if err != nil { return "", err } - fmt.Fprintf(writer, out) + fmt.Fprint(writer, out) } else { for _, pathData := range s.GetSVGPathData() { fmt.Fprintf(writer, ``, pathData, style) @@ -864,7 +869,7 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske } // Closes the class=shape - fmt.Fprintf(writer, ``) + fmt.Fprint(writer, ``) if targetShape.Icon != nil && targetShape.Type != d2target.ShapeImage { iconPosition := label.Position(targetShape.IconPosition) @@ -895,7 +900,11 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske } else { box = s.GetInnerBox() } - labelTL := labelPosition.GetPointOnBox(box, label.PADDING, float64(targetShape.LabelWidth), float64(targetShape.LabelHeight)) + labelTL := labelPosition.GetPointOnBox(box, label.PADDING, + float64(targetShape.LabelWidth), + // TODO consider further + float64(targetShape.LabelHeight-d2graph.INNER_LABEL_PADDING), + ) fontClass := "text" if targetShape.Bold { @@ -932,7 +941,7 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske fmt.Fprintf(writer, ``, targetShape.Width, targetShape.Height, containerStyle) // Padding - fmt.Fprintf(writer, ``) + fmt.Fprint(writer, ``) for index, tokens := range chroma.SplitTokensIntoLines(iterator.Tokens()) { // TODO mono font looks better with 1.2 em (use px equivalent), but textmeasure needs to account for it. Not obvious how that should be done @@ -947,7 +956,7 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske } fmt.Fprint(writer, "") } - fmt.Fprintf(writer, "") + fmt.Fprint(writer, "") } else if targetShape.Type == d2target.ShapeText && targetShape.Language == "latex" { render, err := d2latex.Render(targetShape.Label) if err != nil { @@ -955,7 +964,7 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske } fmt.Fprintf(writer, ``, box.TopLeft.X, box.TopLeft.Y) fmt.Fprint(writer, render) - fmt.Fprintf(writer, "") + fmt.Fprint(writer, "") } else if targetShape.Type == d2target.ShapeText && targetShape.Language != "" { render, err := textmeasure.RenderMarkdown(targetShape.Label) if err != nil { @@ -1000,7 +1009,7 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske addAppendixItems(writer, targetShape) - fmt.Fprintf(writer, closingTag) + fmt.Fprint(writer, closingTag) return labelMask, nil } @@ -1230,7 +1239,7 @@ func Render(diagram *d2target.Diagram, opts *RenderOpts) ([]byte, error) { fmt.Fprintf(buf, ``, mdCSS) } if sketchRunner != nil { - fmt.Fprintf(buf, d2sketch.DefineFillPattern()) + fmt.Fprint(buf, d2sketch.DefineFillPattern()) } // only define shadow filter if a shape uses it diff --git a/lib/shape/shape.go b/lib/shape/shape.go index 6422c588f..1585bad7b 100644 --- a/lib/shape/shape.go +++ b/lib/shape/shape.go @@ -4,6 +4,7 @@ import ( "math" "oss.terrastruct.com/d2/lib/geo" + "oss.terrastruct.com/d2/lib/svg" ) const ( @@ -90,6 +91,8 @@ func (s baseShape) GetInnerTopLeft(_, _, padding float64) geo.Point { return *geo.NewPoint(s.Box.TopLeft.X+padding, s.Box.TopLeft.Y+padding) } +// return the minimum shape dimensions needed to fit content (width x height) +// in the shape's innerBox with padding func (s baseShape) GetDimensionsToFit(width, height, padding float64) (float64, float64) { return width + padding*2, height + padding*2 } @@ -209,3 +212,13 @@ func TraceToShapeBorder(shape Shape, rectBorderPoint, prevPoint *geo.Point) *geo return geo.NewPoint(math.Round(closestPoint.X), math.Round(closestPoint.Y)) } + +func boxPath(box *geo.Box) *svg.SvgPathContext { + pc := svg.NewSVGPathContext(box.TopLeft, 1, 1) + pc.StartAt(pc.Absolute(0, 0)) + pc.L(false, box.Width, 0) + pc.L(false, box.Width, box.Height) + pc.L(false, 0, box.Height) + pc.Z() + return pc +} diff --git a/lib/shape/shape_callout.go b/lib/shape/shape_callout.go index 73cbaac58..0942592df 100644 --- a/lib/shape/shape_callout.go +++ b/lib/shape/shape_callout.go @@ -9,6 +9,11 @@ type shapeCallout struct { *baseShape } +const ( + defaultTipWidth = 30. + defaultTipHeight = 45. +) + func NewCallout(box *geo.Box) Shape { return shapeCallout{ baseShape: &baseShape{ @@ -18,25 +23,31 @@ func NewCallout(box *geo.Box) Shape { } } -func (s shapeCallout) GetInnerBox() *geo.Box { - height := s.Box.Height - tipHeight := 45.0 - if height < tipHeight*2 { - tipHeight = height / 2.0 +func getTipWidth(box *geo.Box) float64 { + tipWidth := defaultTipWidth + if box.Width < tipWidth*2 { + tipWidth = box.Width / 2.0 } - height -= tipHeight + return tipWidth +} + +func getTipHeight(box *geo.Box) float64 { + tipHeight := defaultTipHeight + if box.Height < tipHeight*2 { + tipHeight = box.Height / 2.0 + } + return tipHeight +} + +func (s shapeCallout) GetInnerBox() *geo.Box { + tipHeight := getTipHeight(s.Box) + height := s.Box.Height - tipHeight return geo.NewBox(s.Box.TopLeft.Copy(), s.Box.Width, height) } func calloutPath(box *geo.Box) *svg.SvgPathContext { - tipWidth := 30.0 - if box.Width < tipWidth*2 { - tipWidth = box.Width / 2.0 - } - tipHeight := 45.0 - if box.Height < tipHeight*2 { - tipHeight = box.Height / 2.0 - } + tipWidth := getTipWidth(box) + tipHeight := getTipHeight(box) pc := svg.NewSVGPathContext(box.TopLeft, 1, 1) pc.StartAt(pc.Absolute(0, 0)) pc.V(true, box.Height-tipHeight) @@ -57,5 +68,19 @@ func (s shapeCallout) Perimeter() []geo.Intersectable { func (s shapeCallout) GetSVGPathData() []string { return []string{ calloutPath(s.Box).PathData(), + // debugging + boxPath(s.GetInnerBox()).PathData(), } } + +func (s shapeCallout) GetDimensionsToFit(width, height, padding float64) (float64, float64) { + // return the minimum shape dimensions needed to fit content (width x height) + // in the shape's innerBox with padding + baseHeight := height + padding*2 + if baseHeight < defaultTipHeight { + baseHeight *= 2 + } else { + baseHeight += defaultTipHeight + } + return width + padding*2, baseHeight +} diff --git a/lib/shape/shape_circle.go b/lib/shape/shape_circle.go index 50ab2cc77..54d981099 100644 --- a/lib/shape/shape_circle.go +++ b/lib/shape/shape_circle.go @@ -19,13 +19,23 @@ func NewCircle(box *geo.Box) Shape { } } +func (s shapeCircle) GetInnerBox() *geo.Box { + width := s.Box.Width + height := s.Box.Height + insideTL := s.GetInsidePlacement(width, height, 0) + tl := s.Box.TopLeft.Copy() + width -= 2 * (insideTL.X - tl.X) + height -= 2 * (insideTL.Y - tl.Y) + return geo.NewBox(&insideTL, width, height) +} + func (s shapeCircle) AspectRatio1() bool { return true } func (s shapeCircle) GetDimensionsToFit(width, height, padding float64) (float64, float64) { - radius := math.Ceil(math.Sqrt(math.Pow(width/2, 2)+math.Pow(height/2, 2))) + padding - return radius * 2, radius * 2 + diameter := math.Ceil(math.Sqrt(2 * math.Pow(math.Max(width, height)+2*padding, 2))) + return diameter, diameter } func (s shapeCircle) GetInsidePlacement(width, height, padding float64) geo.Point { diff --git a/lib/shape/shape_cloud.go b/lib/shape/shape_cloud.go index fb200feaf..ffa8e18ae 100644 --- a/lib/shape/shape_cloud.go +++ b/lib/shape/shape_cloud.go @@ -40,6 +40,24 @@ func NewCloud(box *geo.Box) Shape { } } +func (s shapeCloud) GetInnerBox() *geo.Box { + width := s.Box.Width + height := s.Box.Height + insideTL := s.GetInsidePlacement(width, height, 0) + aspectRatio := width / height + if aspectRatio > CLOUD_WIDE_ASPECT_BOUNDARY { + width *= CLOUD_WIDE_INNER_WIDTH + height *= CLOUD_WIDE_INNER_HEIGHT + } else if aspectRatio < CLOUD_TALL_ASPECT_BOUNDARY { + width *= CLOUD_TALL_INNER_WIDTH + height *= CLOUD_TALL_INNER_HEIGHT + } else { + width *= CLOUD_SQUARE_INNER_WIDTH + height *= CLOUD_SQUARE_INNER_HEIGHT + } + return geo.NewBox(&insideTL, width, height) +} + func (s shapeCloud) GetDimensionsToFit(width, height, padding float64) (float64, float64) { width += padding height += padding @@ -96,5 +114,7 @@ func (s shapeCloud) Perimeter() []geo.Intersectable { func (s shapeCloud) GetSVGPathData() []string { return []string{ cloudPath(s.Box).PathData(), + // debugging + boxPath(s.GetInnerBox()).PathData(), } } diff --git a/lib/shape/shape_cylinder.go b/lib/shape/shape_cylinder.go index dfc843841..10ebaf16c 100644 --- a/lib/shape/shape_cylinder.go +++ b/lib/shape/shape_cylinder.go @@ -9,6 +9,10 @@ type shapeCylinder struct { *baseShape } +const ( + defaultArcDepth = 24. +) + func NewCylinder(box *geo.Box) Shape { return shapeCylinder{ baseShape: &baseShape{ @@ -18,46 +22,47 @@ func NewCylinder(box *geo.Box) Shape { } } +func getArcHeight(box *geo.Box) float64 { + arcHeight := defaultArcDepth + // Note: box height should always be larger than 3*default + // this just handles after collapsing into an oval + if box.Height < arcHeight*2 { + arcHeight = box.Height / 2.0 + } + return arcHeight +} + func (s shapeCylinder) GetInnerBox() *geo.Box { height := s.Box.Height tl := s.Box.TopLeft.Copy() - arcDepth := 24.0 - if height < arcDepth*2 { - arcDepth = height / 2.0 - } - height -= 3 * arcDepth - tl.Y += 2 * arcDepth + arc := getArcHeight(s.Box) + height -= 3 * arc + tl.Y += 2 * arc return geo.NewBox(tl, s.Box.Width, height) } func cylinderOuterPath(box *geo.Box) *svg.SvgPathContext { - arcDepth := 24.0 - if box.Height < arcDepth*2 { - arcDepth = box.Height / 2 - } + arcHeight := getArcHeight(box) multiplier := 0.45 pc := svg.NewSVGPathContext(box.TopLeft, 1, 1) - pc.StartAt(pc.Absolute(0, arcDepth)) + pc.StartAt(pc.Absolute(0, arcHeight)) pc.C(false, 0, 0, box.Width*multiplier, 0, box.Width/2, 0) - pc.C(false, box.Width-box.Width*multiplier, 0, box.Width, 0, box.Width, arcDepth) - pc.V(true, box.Height-arcDepth*2) + pc.C(false, box.Width-box.Width*multiplier, 0, box.Width, 0, box.Width, arcHeight) + pc.V(true, box.Height-arcHeight*2) pc.C(false, box.Width, box.Height, box.Width-box.Width*multiplier, box.Height, box.Width/2, box.Height) - pc.C(false, box.Width*multiplier, box.Height, 0, box.Height, 0, box.Height-arcDepth) - pc.V(true, -(box.Height - arcDepth*2)) + pc.C(false, box.Width*multiplier, box.Height, 0, box.Height, 0, box.Height-arcHeight) + pc.V(true, -(box.Height - arcHeight*2)) pc.Z() return pc } func cylinderInnerPath(box *geo.Box) *svg.SvgPathContext { - arcDepth := 24.0 - if box.Height < arcDepth*2 { - arcDepth = box.Height / 2 - } + arcHeight := getArcHeight(box) multiplier := 0.45 pc := svg.NewSVGPathContext(box.TopLeft, 1, 1) - pc.StartAt(pc.Absolute(0, arcDepth)) - pc.C(false, 0, arcDepth*2, box.Width*multiplier, arcDepth*2, box.Width/2, arcDepth*2) - pc.C(false, box.Width-box.Width*multiplier, arcDepth*2, box.Width, arcDepth*2, box.Width, arcDepth) + pc.StartAt(pc.Absolute(0, arcHeight)) + pc.C(false, 0, arcHeight*2, box.Width*multiplier, arcHeight*2, box.Width/2, arcHeight*2) + pc.C(false, box.Width-box.Width*multiplier, arcHeight*2, box.Width, arcHeight*2, box.Width, arcHeight) return pc } @@ -69,5 +74,13 @@ func (s shapeCylinder) GetSVGPathData() []string { return []string{ cylinderOuterPath(s.Box).PathData(), cylinderInnerPath(s.Box).PathData(), + // debugging + boxPath(s.GetInnerBox()).PathData(), } } + +func (s shapeCylinder) GetDimensionsToFit(width, height, padding float64) (float64, float64) { + // 2 arcs top, height + padding, 1 arc bottom + totalHeight := height + padding*2 + 3*defaultArcDepth + return width + padding*2, totalHeight +} diff --git a/lib/shape/shape_diamond.go b/lib/shape/shape_diamond.go index 9fb115194..02d8a0cd2 100644 --- a/lib/shape/shape_diamond.go +++ b/lib/shape/shape_diamond.go @@ -18,6 +18,17 @@ func NewDiamond(box *geo.Box) Shape { } } +func (s shapeDiamond) GetInnerBox() *geo.Box { + width := s.Box.Width + height := s.Box.Height + tl := s.Box.TopLeft.Copy() + tl.X += width / 4. + tl.Y += height / 4. + width /= 2. + height /= 2. + return geo.NewBox(tl, width, height) +} + func diamondPath(box *geo.Box) *svg.SvgPathContext { pc := svg.NewSVGPathContext(box.TopLeft, box.Width/77, box.Height/76.9) pc.StartAt(pc.Absolute(38.5, 76.9)) @@ -41,5 +52,13 @@ func (s shapeDiamond) Perimeter() []geo.Intersectable { func (s shapeDiamond) GetSVGPathData() []string { return []string{ diamondPath(s.Box).PathData(), + // debugging + boxPath(s.GetInnerBox()).PathData(), } } + +func (s shapeDiamond) GetDimensionsToFit(width, height, padding float64) (float64, float64) { + totalWidth := 2 * (width + 2*padding) + totalHeight := 2 * (height + 2*padding) + return totalWidth, totalHeight +} diff --git a/lib/shape/shape_document.go b/lib/shape/shape_document.go index 3cdb5d100..efda39f86 100644 --- a/lib/shape/shape_document.go +++ b/lib/shape/shape_document.go @@ -9,6 +9,13 @@ type shapeDocument struct { *baseShape } +const ( + // the shape is taller than where the bottom of the path ends + docPathHeight = 18.925 + docPathInnerBottom = 14 + docPathBottom = 16.3 +) + func NewDocument(box *geo.Box) Shape { return shapeDocument{ baseShape: &baseShape{ @@ -18,15 +25,19 @@ func NewDocument(box *geo.Box) Shape { } } +func (s shapeDocument) GetInnerBox() *geo.Box { + height := s.Box.Height * docPathInnerBottom / docPathHeight + return geo.NewBox(s.Box.TopLeft.Copy(), s.Box.Width, height) +} + func documentPath(box *geo.Box) *svg.SvgPathContext { - pathHeight := 18.925 pc := svg.NewSVGPathContext(box.TopLeft, box.Width, box.Height) - pc.StartAt(pc.Absolute(0, 16.3/pathHeight)) + pc.StartAt(pc.Absolute(0, docPathBottom/docPathHeight)) pc.L(false, 0, 0) pc.L(false, 1, 0) - pc.L(false, 1, 16.3/pathHeight) - pc.C(false, 5/6.0, 12.8/pathHeight, 2/3.0, 12.8/pathHeight, 1/2.0, 16.3/pathHeight) - pc.C(false, 1/3.0, 19.8/pathHeight, 1/6.0, 19.8/pathHeight, 0, 16.3/pathHeight) + pc.L(false, 1, docPathBottom/docPathHeight) + pc.C(false, 5/6.0, 12.8/docPathHeight, 2/3.0, 12.8/docPathHeight, 1/2.0, docPathBottom/docPathHeight) + pc.C(false, 1/3.0, 19.8/docPathHeight, 1/6.0, 19.8/docPathHeight, 0, docPathBottom/docPathHeight) pc.Z() return pc } @@ -38,5 +49,12 @@ func (s shapeDocument) Perimeter() []geo.Intersectable { func (s shapeDocument) GetSVGPathData() []string { return []string{ documentPath(s.Box).PathData(), + // debugging + boxPath(s.GetInnerBox()).PathData(), } } + +func (s shapeDocument) GetDimensionsToFit(width, height, padding float64) (float64, float64) { + baseHeight := (height + padding*2) * docPathHeight / docPathInnerBottom + return width + padding*2, baseHeight +} diff --git a/lib/shape/shape_hexagon.go b/lib/shape/shape_hexagon.go index b726181a2..203904be1 100644 --- a/lib/shape/shape_hexagon.go +++ b/lib/shape/shape_hexagon.go @@ -18,6 +18,14 @@ func NewHexagon(box *geo.Box) Shape { } } +func (s shapeHexagon) GetInnerBox() *geo.Box { + width := s.Box.Width + tl := s.Box.TopLeft.Copy() + tl.X += width / 4. + width /= 2. + return geo.NewBox(tl, width, s.Box.Height) +} + func hexagonPath(box *geo.Box) *svg.SvgPathContext { halfYFactor := 43.6 / 87.3 pc := svg.NewSVGPathContext(box.TopLeft, box.Width, box.Height) @@ -38,5 +46,12 @@ func (s shapeHexagon) Perimeter() []geo.Intersectable { func (s shapeHexagon) GetSVGPathData() []string { return []string{ hexagonPath(s.Box).PathData(), + // debugging + boxPath(s.GetInnerBox()).PathData(), } } + +func (s shapeHexagon) GetDimensionsToFit(width, height, padding float64) (float64, float64) { + totalWidth := 2 * (width + 2*padding) + return totalWidth, height + 2*padding +} diff --git a/lib/shape/shape_oval.go b/lib/shape/shape_oval.go index c0f983ad6..d29a23cc4 100644 --- a/lib/shape/shape_oval.go +++ b/lib/shape/shape_oval.go @@ -19,6 +19,16 @@ func NewOval(box *geo.Box) Shape { } } +func (s shapeOval) GetInnerBox() *geo.Box { + width := s.Box.Width + height := s.Box.Height + insideTL := s.GetInsidePlacement(width, height, 0) + tl := s.Box.TopLeft.Copy() + width -= 2 * (insideTL.X - tl.X) + height -= 2 * (insideTL.Y - tl.Y) + return geo.NewBox(&insideTL, width, height) +} + func (s shapeOval) GetDimensionsToFit(width, height, padding float64) (float64, float64) { theta := math.Atan2(height, width) // add padding in direction of diagonal so there is padding distance between top left and border @@ -53,3 +63,10 @@ func (s shapeOval) GetInsidePlacement(width, height, padding float64) geo.Point func (s shapeOval) Perimeter() []geo.Intersectable { return []geo.Intersectable{geo.NewEllipse(s.Box.Center(), s.Box.Width/2, s.Box.Height/2)} } + +// debugging +func (s shapeOval) GetSVGPathData() []string { + return []string{ + boxPath(s.GetInnerBox()).PathData(), + } +} diff --git a/lib/shape/shape_package.go b/lib/shape/shape_package.go index 8cdf73501..ba6e8c76c 100644 --- a/lib/shape/shape_package.go +++ b/lib/shape/shape_package.go @@ -11,6 +11,15 @@ type shapePackage struct { *baseShape } +const ( + packageTopMinHeight = 34. + packageTopMaxHeight = 55. + packageTopMinWidth = 50. + packageTopMaxWidth = 150. + packageHorizontalScalar = 0.5 + packageVerticalScalar = 0.2 +) + func NewPackage(box *geo.Box) Shape { return shapePackage{ baseShape: &baseShape{ @@ -20,22 +29,27 @@ func NewPackage(box *geo.Box) Shape { } } -func packagePath(box *geo.Box) *svg.SvgPathContext { - const MIN_TOP_HEIGHT = 34 - const MAX_TOP_HEIGHT = 55 - const MIN_TOP_WIDTH = 50 - const MAX_TOP_WIDTH = 150 +func (s shapePackage) GetInnerBox() *geo.Box { + tl := s.Box.TopLeft.Copy() + height := s.Box.Height - const horizontalScalar = 0.5 - topWidth := box.Width * horizontalScalar - if box.Width >= 2*MIN_TOP_WIDTH { - topWidth = math.Min(MAX_TOP_WIDTH, math.Max(MIN_TOP_WIDTH, topWidth)) - } - const verticalScalar = 0.2 - topHeight := box.Height * verticalScalar - if box.Height >= 2*MIN_TOP_HEIGHT { - topHeight = math.Min(MAX_TOP_HEIGHT, math.Max(MIN_TOP_HEIGHT, topHeight)) + _, topHeight := getTopDimensions(s.Box) + tl.Y += topHeight + height -= topHeight + return geo.NewBox(tl, s.Box.Width, height) +} + +func getTopDimensions(box *geo.Box) (width, height float64) { + width = box.Width * packageHorizontalScalar + if box.Width >= 2*packageTopMinWidth { + width = math.Min(packageTopMaxWidth, math.Max(packageTopMinWidth, width)) } + height = math.Min(packageTopMaxHeight, box.Height*packageVerticalScalar) + return width, height +} + +func packagePath(box *geo.Box) *svg.SvgPathContext { + topWidth, topHeight := getTopDimensions(box) pc := svg.NewSVGPathContext(box.TopLeft, 1, 1) pc.StartAt(pc.Absolute(0, 0)) @@ -55,5 +69,18 @@ func (s shapePackage) Perimeter() []geo.Intersectable { func (s shapePackage) GetSVGPathData() []string { return []string{ packagePath(s.Box).PathData(), + // debugging + boxPath(s.GetInnerBox()).PathData(), } } + +func (s shapePackage) GetDimensionsToFit(width, height, padding float64) (float64, float64) { + innerHeight := height + padding*2 + // We want to compute what the topHeight will be to add to inner height; + // topHeight=(verticalScalar * totalHeight) and totalHeight=(topHeight + innerHeight) + // so solving for topHeight we get: topHeight=innerHeight * (verticalScalar/(1-verticalScalar)) + topHeight := innerHeight * packageVerticalScalar / (1. - packageVerticalScalar) + totalHeight := innerHeight + math.Min(topHeight, packageTopMaxHeight) + + return width + padding*2, totalHeight +} diff --git a/lib/shape/shape_page.go b/lib/shape/shape_page.go index ca55f71ac..347897601 100644 --- a/lib/shape/shape_page.go +++ b/lib/shape/shape_page.go @@ -1,6 +1,8 @@ package shape import ( + "math" + "oss.terrastruct.com/d2/lib/geo" "oss.terrastruct.com/d2/lib/svg" ) @@ -9,6 +11,12 @@ type shapePage struct { *baseShape } +const ( + // TODO: cleanup + pageCornerWidth = 20.8164 + pageCornerHeight = 20.348 +) + func NewPage(box *geo.Box) Shape { return shapePage{ baseShape: &baseShape{ @@ -18,49 +26,51 @@ func NewPage(box *geo.Box) Shape { } } -const PAGE_WIDTH = 66. -const PAGE_HEIGHT = 79. +func (s shapePage) GetInnerBox() *geo.Box { + // Note: for simplicity this assumes shape padding is greater than pageCornerSize + width := s.Box.Width + // consider right hand side occupied by corner for short pages + if s.Box.Height < 3*pageCornerHeight { + width -= pageCornerWidth + } + return geo.NewBox(s.Box.TopLeft.Copy(), width, s.Box.Height) +} func pageOuterPath(box *geo.Box) *svg.SvgPathContext { + // TODO: cleanup pc := svg.NewSVGPathContext(box.TopLeft, 1., 1.) - baseX := box.Width - PAGE_WIDTH - baseY := box.Height - PAGE_HEIGHT pc.StartAt(pc.Absolute(0.5, 0)) - pc.H(false, baseX+45.1836) // = width-(66+45.1836) - pc.C(false, baseX+46.3544, 0.0, baseX+47.479, 0.456297, baseX+48.3189, 1.27202) - pc.L(false, baseX+64.6353, 17.12) - pc.C(false, baseX+65.5077, 17.9674, baseX+66., 19.1318, baseX+66., 20.348) - // baseY is not needed above because the coordinates start at 0 - pc.V(false, baseY+78.5) - pc.C(false, baseX+66.0, baseY+78.7761, baseX+65.7761, baseY+79.0, baseX+65.5, baseY+79.0) + pc.H(false, box.Width-20.8164) + pc.C(false, box.Width-19.6456, 0.0, box.Width-18.521, 0.456297, box.Width-17.6811, 1.27202) + pc.L(false, box.Width-1.3647, 17.12) + pc.C(false, box.Width-0.4923, 17.9674, box.Width, 19.1318, box.Width, 20.348) + pc.V(false, box.Height-0.5) + pc.C(false, box.Width, box.Height-0.2239, box.Width-0.2239, box.Height, box.Width-0.5, box.Height) - pc.H(false, .499999) - pc.C(false, 0.223857, baseY+79.0, 0.0, baseY+78.7761, 0.0, baseY+78.5) + pc.H(false, 0.499999) + pc.C(false, 0.223857, box.Height, 0, box.Height-0.2239, 0, box.Height-0.5) pc.V(false, 0.499999) - pc.C(false, 0.0, 0.223857, 0.223857, 0.0, 0.5, 0.0) + pc.C(false, 0, 0.223857, 0.223857, 0, 0.5, 0) pc.Z() return pc } func pageInnerPath(box *geo.Box) *svg.SvgPathContext { - baseX := box.Width - PAGE_WIDTH - baseY := box.Height - PAGE_HEIGHT - pc := svg.NewSVGPathContext(box.TopLeft, 1., 1.) - pc.StartAt(pc.Absolute(baseX+64.91803, baseY+79.)) + pc.StartAt(pc.Absolute(box.Width-1.08197, box.Height)) pc.H(false, 1.08196) pc.C(true, -0.64918, 0, -1.08196, -0.43287, -1.08196, -1.08219) pc.V(false, 1.08219) pc.C(true, 0, -0.64931, 0.43278, -1.08219, 1.08196, -1.08219) - pc.H(true, baseX+43.27868) + pc.H(true, box.Width-22.72132) pc.C(true, 0.64918, 0, 1.08196, 0.43287, 1.08196, 1.08219) pc.V(true, 17.09863) pc.C(true, 0, 1.29863, 0.86557, 2.38082, 2.38032, 2.38082) - pc.H(false, baseX+64.91803) + pc.H(false, box.Width-1.08197) pc.C(true, .64918, 0, 1.08196, 0.43287, 1.08196, 1.08196) - pc.V(false, baseY+77.91780) - pc.C(false, baseX+64.99999, baseY+78.56712, baseX+65.56721, baseY+79, baseX+64.91803, baseY+79) + pc.V(false, box.Height-1.0822) + pc.C(false, box.Width-1.0, box.Height-0.43288, box.Width-0.43279, box.Height, box.Width-1.08197, box.Height) pc.Z() return pc } @@ -73,5 +83,19 @@ func (s shapePage) GetSVGPathData() []string { return []string{ pageOuterPath(s.Box).PathData(), pageInnerPath(s.Box).PathData(), + // debugging + boxPath(s.GetInnerBox()).PathData(), } } + +func (s shapePage) GetDimensionsToFit(width, height, padding float64) (float64, float64) { + totalWidth := width + padding*2 + totalHeight := height + padding*2 + // add space for corner with short pages + if totalHeight < 3*pageCornerHeight { + totalWidth += pageCornerWidth + } + totalWidth = math.Max(totalWidth, 2*pageCornerWidth) + totalHeight = math.Max(totalHeight, pageCornerHeight) + return totalWidth, totalHeight +} diff --git a/lib/shape/shape_parallelogram.go b/lib/shape/shape_parallelogram.go index 3557579cb..d9b99df69 100644 --- a/lib/shape/shape_parallelogram.go +++ b/lib/shape/shape_parallelogram.go @@ -9,6 +9,8 @@ type shapeParallelogram struct { *baseShape } +const parallelWedgeWidth = 26. + func NewParallelogram(box *geo.Box) Shape { return shapeParallelogram{ baseShape: &baseShape{ @@ -18,8 +20,17 @@ func NewParallelogram(box *geo.Box) Shape { } } +func (s shapeParallelogram) GetInnerBox() *geo.Box { + tl := s.Box.TopLeft.Copy() + width := s.Box.Width - 2*parallelWedgeWidth + tl.X += parallelWedgeWidth + return geo.NewBox(tl, width, s.Box.Height) +} + func parallelogramPath(box *geo.Box) *svg.SvgPathContext { - wedgeWidth := 26.0 + wedgeWidth := parallelWedgeWidth + // Note: box width should always be larger than parallelWedgeWidth + // this just handles after collapsing into a line if box.Width <= wedgeWidth { wedgeWidth = box.Width / 2.0 } @@ -40,5 +51,12 @@ func (s shapeParallelogram) Perimeter() []geo.Intersectable { func (s shapeParallelogram) GetSVGPathData() []string { return []string{ parallelogramPath(s.Box).PathData(), + // debugging + boxPath(s.GetInnerBox()).PathData(), } } + +func (s shapeParallelogram) GetDimensionsToFit(width, height, padding float64) (float64, float64) { + totalWidth := width + padding*2 + parallelWedgeWidth*2 + return totalWidth, height + padding*2 +} diff --git a/lib/shape/shape_person.go b/lib/shape/shape_person.go index f75c6c49d..9cb4e19c9 100644 --- a/lib/shape/shape_person.go +++ b/lib/shape/shape_person.go @@ -18,6 +18,19 @@ func NewPerson(box *geo.Box) Shape { } } +const ( + personShoulderWidthFactor = 20.2 / 68.3 +) + +func (s shapePerson) GetInnerBox() *geo.Box { + width := s.Box.Width + tl := s.Box.TopLeft.Copy() + shoulderWidth := personShoulderWidthFactor * width + tl.X += shoulderWidth + width -= shoulderWidth * 2 + return geo.NewBox(tl, width, s.Box.Height) +} + func personPath(box *geo.Box) *svg.SvgPathContext { pc := svg.NewSVGPathContext(box.TopLeft, box.Width/68.3, box.Height/77.4) @@ -50,5 +63,16 @@ func (s shapePerson) Perimeter() []geo.Intersectable { func (s shapePerson) GetSVGPathData() []string { return []string{ personPath(s.Box).PathData(), + // debugging + boxPath(s.GetInnerBox()).PathData(), } } + +func (s shapePerson) GetDimensionsToFit(width, height, padding float64) (float64, float64) { + totalWidth := width + padding*2 + // see shapePackage + shoulderWidth := totalWidth * personShoulderWidthFactor / (1 - 2*personShoulderWidthFactor) + totalWidth += 2 * shoulderWidth + totalHeight := height + padding*2 + return totalWidth, totalHeight +} diff --git a/lib/shape/shape_queue.go b/lib/shape/shape_queue.go index 5f40893d5..8981adc31 100644 --- a/lib/shape/shape_queue.go +++ b/lib/shape/shape_queue.go @@ -18,46 +18,47 @@ func NewQueue(box *geo.Box) Shape { } } +func getArcWidth(box *geo.Box) float64 { + arcWidth := defaultArcDepth + // Note: box width should always be larger than 3*default + // this just handles after collaping into an oval + if box.Width < arcWidth*2 { + arcWidth = box.Width / 2.0 + } + return arcWidth +} + func (s shapeQueue) GetInnerBox() *geo.Box { width := s.Box.Width tl := s.Box.TopLeft.Copy() - arcDepth := 24.0 - if width < arcDepth*2 { - arcDepth = width / 2.0 - } - width -= 3 * arcDepth - tl.X += arcDepth + arcWidth := getArcWidth(s.Box) + width -= 3 * arcWidth + tl.X += arcWidth return geo.NewBox(tl, width, s.Box.Height) } func queueOuterPath(box *geo.Box) *svg.SvgPathContext { - arcDepth := 24.0 + arcWidth := getArcWidth(box) multiplier := 0.45 - if box.Width < arcDepth*2 { - arcDepth = box.Width / 2.0 - } pc := svg.NewSVGPathContext(box.TopLeft, 1, 1) - pc.StartAt(pc.Absolute(arcDepth, 0)) - pc.H(true, box.Width-2*arcDepth) + pc.StartAt(pc.Absolute(arcWidth, 0)) + pc.H(true, box.Width-2*arcWidth) pc.C(false, box.Width, 0, box.Width, box.Height*multiplier, box.Width, box.Height/2.0) - pc.C(false, box.Width, box.Height-box.Height*multiplier, box.Width, box.Height, box.Width-arcDepth, box.Height) - pc.H(true, -1*(box.Width-2*arcDepth)) + pc.C(false, box.Width, box.Height-box.Height*multiplier, box.Width, box.Height, box.Width-arcWidth, box.Height) + pc.H(true, -1*(box.Width-2*arcWidth)) pc.C(false, 0, box.Height, 0, box.Height-box.Height*multiplier, 0, box.Height/2.0) - pc.C(false, 0, box.Height*multiplier, 0, 0, arcDepth, 0) + pc.C(false, 0, box.Height*multiplier, 0, 0, arcWidth, 0) pc.Z() return pc } func queueInnerPath(box *geo.Box) *svg.SvgPathContext { - arcDepth := 24.0 + arcWidth := getArcWidth(box) multiplier := 0.45 - if box.Width < arcDepth*2 { - arcDepth = box.Width / 2.0 - } pc := svg.NewSVGPathContext(box.TopLeft, 1, 1) - pc.StartAt(pc.Absolute(box.Width-arcDepth, 0)) - pc.C(false, box.Width-2*arcDepth, 0, box.Width-2*arcDepth, box.Height*multiplier, box.Width-2*arcDepth, box.Height/2.0) - pc.C(false, box.Width-2*arcDepth, box.Height-box.Height*multiplier, box.Width-2*arcDepth, box.Height, box.Width-arcDepth, box.Height) + pc.StartAt(pc.Absolute(box.Width-arcWidth, 0)) + pc.C(false, box.Width-2*arcWidth, 0, box.Width-2*arcWidth, box.Height*multiplier, box.Width-2*arcWidth, box.Height/2.0) + pc.C(false, box.Width-2*arcWidth, box.Height-box.Height*multiplier, box.Width-2*arcWidth, box.Height, box.Width-arcWidth, box.Height) return pc } @@ -69,5 +70,13 @@ func (s shapeQueue) GetSVGPathData() []string { return []string{ queueOuterPath(s.Box).PathData(), queueInnerPath(s.Box).PathData(), + // debugging + boxPath(s.GetInnerBox()).PathData(), } } + +func (s shapeQueue) GetDimensionsToFit(width, height, padding float64) (float64, float64) { + // 1 arc left, width+ padding, 2 arcs right + totalWidth := 3*defaultArcDepth + width + padding*2 + return totalWidth, height + padding*2 +} diff --git a/lib/shape/shape_step.go b/lib/shape/shape_step.go index bd63fb01a..5732b2ad4 100644 --- a/lib/shape/shape_step.go +++ b/lib/shape/shape_step.go @@ -20,6 +20,14 @@ func NewStep(box *geo.Box) Shape { const STEP_WEDGE_WIDTH = 35.0 +func (s shapeStep) GetInnerBox() *geo.Box { + width := s.Box.Width + tl := s.Box.TopLeft.Copy() + width -= 2 * STEP_WEDGE_WIDTH + tl.X += STEP_WEDGE_WIDTH + return geo.NewBox(tl, width, s.Box.Height) +} + func stepPath(box *geo.Box) *svg.SvgPathContext { wedgeWidth := STEP_WEDGE_WIDTH if box.Width <= wedgeWidth { @@ -43,5 +51,12 @@ func (s shapeStep) Perimeter() []geo.Intersectable { func (s shapeStep) GetSVGPathData() []string { return []string{ stepPath(s.Box).PathData(), + // debugging + boxPath(s.GetInnerBox()).PathData(), } } + +func (s shapeStep) GetDimensionsToFit(width, height, padding float64) (float64, float64) { + totalWidth := width + padding*2 + 2*STEP_WEDGE_WIDTH + return totalWidth, height + padding*2 +} diff --git a/lib/shape/shape_stored_data.go b/lib/shape/shape_stored_data.go index 734037a75..6d015a854 100644 --- a/lib/shape/shape_stored_data.go +++ b/lib/shape/shape_stored_data.go @@ -9,6 +9,8 @@ type shapeStoredData struct { *baseShape } +const storedDataWedgeWidth = 15. + func NewStoredData(box *geo.Box) Shape { return shapeStoredData{ baseShape: &baseShape{ @@ -18,8 +20,16 @@ func NewStoredData(box *geo.Box) Shape { } } +func (s shapeStoredData) GetInnerBox() *geo.Box { + width := s.Box.Width + tl := s.Box.TopLeft.Copy() + width -= 2 * storedDataWedgeWidth + tl.X += storedDataWedgeWidth + return geo.NewBox(tl, width, s.Box.Height) +} + func storedDataPath(box *geo.Box) *svg.SvgPathContext { - wedgeWidth := 15.0 + wedgeWidth := storedDataWedgeWidth multiplier := 0.27 if box.Width < wedgeWidth*2 { wedgeWidth = box.Width / 2.0 @@ -43,5 +53,12 @@ func (s shapeStoredData) Perimeter() []geo.Intersectable { func (s shapeStoredData) GetSVGPathData() []string { return []string{ storedDataPath(s.Box).PathData(), + // debugging + boxPath(s.GetInnerBox()).PathData(), } } + +func (s shapeStoredData) GetDimensionsToFit(width, height, padding float64) (float64, float64) { + totalWidth := width + padding*2 + 2*storedDataWedgeWidth + return totalWidth, height + padding*2 +} From b76d43536d8810b7e4d0056d5f0695f8716073bc Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Fri, 20 Jan 2023 20:12:16 -0800 Subject: [PATCH 02/35] remove debugging code --- d2renderers/d2svg/d2svg.go | 5 ----- lib/shape/shape_callout.go | 2 -- lib/shape/shape_cloud.go | 2 -- lib/shape/shape_cylinder.go | 2 -- lib/shape/shape_diamond.go | 2 -- lib/shape/shape_document.go | 2 -- lib/shape/shape_hexagon.go | 2 -- lib/shape/shape_oval.go | 7 ------- lib/shape/shape_package.go | 2 -- lib/shape/shape_page.go | 2 -- lib/shape/shape_parallelogram.go | 2 -- lib/shape/shape_person.go | 2 -- lib/shape/shape_queue.go | 2 -- lib/shape/shape_step.go | 2 -- lib/shape/shape_stored_data.go | 2 -- 15 files changed, 38 deletions(-) diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index eac72d4a4..92ac64f73 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -795,11 +795,6 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske } } - // debugging - for _, pathData := range s.GetSVGPathData() { - fmt.Fprintf(writer, ``, pathData, style) - } - case d2target.ShapeImage: fmt.Fprintf(writer, ``, html.EscapeString(targetShape.Icon.String()), diff --git a/lib/shape/shape_callout.go b/lib/shape/shape_callout.go index 0942592df..fccd8d5bc 100644 --- a/lib/shape/shape_callout.go +++ b/lib/shape/shape_callout.go @@ -68,8 +68,6 @@ func (s shapeCallout) Perimeter() []geo.Intersectable { func (s shapeCallout) GetSVGPathData() []string { return []string{ calloutPath(s.Box).PathData(), - // debugging - boxPath(s.GetInnerBox()).PathData(), } } diff --git a/lib/shape/shape_cloud.go b/lib/shape/shape_cloud.go index ffa8e18ae..634098cdb 100644 --- a/lib/shape/shape_cloud.go +++ b/lib/shape/shape_cloud.go @@ -114,7 +114,5 @@ func (s shapeCloud) Perimeter() []geo.Intersectable { func (s shapeCloud) GetSVGPathData() []string { return []string{ cloudPath(s.Box).PathData(), - // debugging - boxPath(s.GetInnerBox()).PathData(), } } diff --git a/lib/shape/shape_cylinder.go b/lib/shape/shape_cylinder.go index 10ebaf16c..0e97bbd89 100644 --- a/lib/shape/shape_cylinder.go +++ b/lib/shape/shape_cylinder.go @@ -74,8 +74,6 @@ func (s shapeCylinder) GetSVGPathData() []string { return []string{ cylinderOuterPath(s.Box).PathData(), cylinderInnerPath(s.Box).PathData(), - // debugging - boxPath(s.GetInnerBox()).PathData(), } } diff --git a/lib/shape/shape_diamond.go b/lib/shape/shape_diamond.go index 02d8a0cd2..6c7951955 100644 --- a/lib/shape/shape_diamond.go +++ b/lib/shape/shape_diamond.go @@ -52,8 +52,6 @@ func (s shapeDiamond) Perimeter() []geo.Intersectable { func (s shapeDiamond) GetSVGPathData() []string { return []string{ diamondPath(s.Box).PathData(), - // debugging - boxPath(s.GetInnerBox()).PathData(), } } diff --git a/lib/shape/shape_document.go b/lib/shape/shape_document.go index efda39f86..36ffeafcf 100644 --- a/lib/shape/shape_document.go +++ b/lib/shape/shape_document.go @@ -49,8 +49,6 @@ func (s shapeDocument) Perimeter() []geo.Intersectable { func (s shapeDocument) GetSVGPathData() []string { return []string{ documentPath(s.Box).PathData(), - // debugging - boxPath(s.GetInnerBox()).PathData(), } } diff --git a/lib/shape/shape_hexagon.go b/lib/shape/shape_hexagon.go index 203904be1..60aeb26df 100644 --- a/lib/shape/shape_hexagon.go +++ b/lib/shape/shape_hexagon.go @@ -46,8 +46,6 @@ func (s shapeHexagon) Perimeter() []geo.Intersectable { func (s shapeHexagon) GetSVGPathData() []string { return []string{ hexagonPath(s.Box).PathData(), - // debugging - boxPath(s.GetInnerBox()).PathData(), } } diff --git a/lib/shape/shape_oval.go b/lib/shape/shape_oval.go index d29a23cc4..608fd4a38 100644 --- a/lib/shape/shape_oval.go +++ b/lib/shape/shape_oval.go @@ -63,10 +63,3 @@ func (s shapeOval) GetInsidePlacement(width, height, padding float64) geo.Point func (s shapeOval) Perimeter() []geo.Intersectable { return []geo.Intersectable{geo.NewEllipse(s.Box.Center(), s.Box.Width/2, s.Box.Height/2)} } - -// debugging -func (s shapeOval) GetSVGPathData() []string { - return []string{ - boxPath(s.GetInnerBox()).PathData(), - } -} diff --git a/lib/shape/shape_package.go b/lib/shape/shape_package.go index ba6e8c76c..3181dcc7e 100644 --- a/lib/shape/shape_package.go +++ b/lib/shape/shape_package.go @@ -69,8 +69,6 @@ func (s shapePackage) Perimeter() []geo.Intersectable { func (s shapePackage) GetSVGPathData() []string { return []string{ packagePath(s.Box).PathData(), - // debugging - boxPath(s.GetInnerBox()).PathData(), } } diff --git a/lib/shape/shape_page.go b/lib/shape/shape_page.go index 347897601..a355f02ed 100644 --- a/lib/shape/shape_page.go +++ b/lib/shape/shape_page.go @@ -83,8 +83,6 @@ func (s shapePage) GetSVGPathData() []string { return []string{ pageOuterPath(s.Box).PathData(), pageInnerPath(s.Box).PathData(), - // debugging - boxPath(s.GetInnerBox()).PathData(), } } diff --git a/lib/shape/shape_parallelogram.go b/lib/shape/shape_parallelogram.go index d9b99df69..916a943a9 100644 --- a/lib/shape/shape_parallelogram.go +++ b/lib/shape/shape_parallelogram.go @@ -51,8 +51,6 @@ func (s shapeParallelogram) Perimeter() []geo.Intersectable { func (s shapeParallelogram) GetSVGPathData() []string { return []string{ parallelogramPath(s.Box).PathData(), - // debugging - boxPath(s.GetInnerBox()).PathData(), } } diff --git a/lib/shape/shape_person.go b/lib/shape/shape_person.go index 9cb4e19c9..1be86ebaa 100644 --- a/lib/shape/shape_person.go +++ b/lib/shape/shape_person.go @@ -63,8 +63,6 @@ func (s shapePerson) Perimeter() []geo.Intersectable { func (s shapePerson) GetSVGPathData() []string { return []string{ personPath(s.Box).PathData(), - // debugging - boxPath(s.GetInnerBox()).PathData(), } } diff --git a/lib/shape/shape_queue.go b/lib/shape/shape_queue.go index 8981adc31..0ddaa683d 100644 --- a/lib/shape/shape_queue.go +++ b/lib/shape/shape_queue.go @@ -70,8 +70,6 @@ func (s shapeQueue) GetSVGPathData() []string { return []string{ queueOuterPath(s.Box).PathData(), queueInnerPath(s.Box).PathData(), - // debugging - boxPath(s.GetInnerBox()).PathData(), } } diff --git a/lib/shape/shape_step.go b/lib/shape/shape_step.go index 5732b2ad4..6eb892869 100644 --- a/lib/shape/shape_step.go +++ b/lib/shape/shape_step.go @@ -51,8 +51,6 @@ func (s shapeStep) Perimeter() []geo.Intersectable { func (s shapeStep) GetSVGPathData() []string { return []string{ stepPath(s.Box).PathData(), - // debugging - boxPath(s.GetInnerBox()).PathData(), } } diff --git a/lib/shape/shape_stored_data.go b/lib/shape/shape_stored_data.go index 6d015a854..e30c7896f 100644 --- a/lib/shape/shape_stored_data.go +++ b/lib/shape/shape_stored_data.go @@ -53,8 +53,6 @@ func (s shapeStoredData) Perimeter() []geo.Intersectable { func (s shapeStoredData) GetSVGPathData() []string { return []string{ storedDataPath(s.Box).PathData(), - // debugging - boxPath(s.GetInnerBox()).PathData(), } } From 0311a3f7d7da9262f162914f98ae5927f7f92222 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Mon, 23 Jan 2023 10:32:12 -0800 Subject: [PATCH 03/35] use paddingX and paddingY in GetDimensionsToFit --- d2graph/d2graph.go | 45 ++++++++++++-------------------- lib/shape/shape.go | 13 ++++++--- lib/shape/shape_callout.go | 6 ++--- lib/shape/shape_circle.go | 4 +-- lib/shape/shape_class.go | 5 ++++ lib/shape/shape_cloud.go | 11 +++++--- lib/shape/shape_code.go | 4 +++ lib/shape/shape_cylinder.go | 6 ++--- lib/shape/shape_diamond.go | 6 ++--- lib/shape/shape_document.go | 6 ++--- lib/shape/shape_hexagon.go | 6 ++--- lib/shape/shape_image.go | 4 +++ lib/shape/shape_oval.go | 6 ++--- lib/shape/shape_package.go | 6 ++--- lib/shape/shape_page.go | 6 ++--- lib/shape/shape_parallelogram.go | 6 ++--- lib/shape/shape_person.go | 6 ++--- lib/shape/shape_queue.go | 6 ++--- lib/shape/shape_real_square.go | 4 +-- lib/shape/shape_step.go | 6 ++--- lib/shape/shape_stored_data.go | 6 ++--- lib/shape/shape_table.go | 4 +++ lib/shape/shape_text.go | 4 +++ 23 files changed, 98 insertions(+), 78 deletions(-) diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index c90ee7607..65f60cdb9 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -23,7 +23,7 @@ import ( ) const INNER_LABEL_PADDING int = 5 -const DEFAULT_SHAPE_PADDING = 100. +const DEFAULT_SHAPE_SIZE = 100. // TODO: Refactor with a light abstract layer on top of AST implementing scenarios, // variables, imports, substitutions and then a final set of structures representing @@ -827,21 +827,6 @@ func (obj *Object) GetDefaultSize(mtexts []*d2target.MText, ruler *textmeasure.R return &dims, nil } -func (obj *Object) GetPadding() (x, y float64) { - switch strings.ToLower(obj.Attributes.Shape.Value) { - case d2target.ShapeImage, - d2target.ShapeSQLTable, - d2target.ShapeText, - d2target.ShapeCode: - return 0., 0. - case d2target.ShapeClass: - // TODO fix class row width measurements (see SQL table) - return 100., 0. - default: - return DEFAULT_SHAPE_PADDING, DEFAULT_SHAPE_PADDING - } -} - type Edge struct { Index int `json:"index"` @@ -1107,8 +1092,8 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler obj.Attributes.Shape.Value != d2target.ShapeImage && obj.Attributes.Shape.Value != d2target.ShapeSQLTable && obj.Attributes.Shape.Value != d2target.ShapeClass { - obj.Width = DEFAULT_SHAPE_PADDING - obj.Height = DEFAULT_SHAPE_PADDING + obj.Width = DEFAULT_SHAPE_SIZE + obj.Height = DEFAULT_SHAPE_SIZE if desiredWidth != 0 { obj.Width = float64(desiredWidth) } @@ -1149,10 +1134,13 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler obj.Width = float64(go2.Max(defaultDims.Width, desiredWidth)) obj.Height = float64(go2.Max(defaultDims.Height, desiredHeight)) - paddingX, paddingY := obj.GetPadding() + shapeType := d2target.DSL_SHAPE_TO_SHAPE_TYPE[dslShape] + contentBox := geo.NewBox(geo.NewPoint(0, 0), float64(defaultDims.Width), float64(defaultDims.Height)) + s := shape.NewShape(shapeType, contentBox) - switch dslShape { - case d2target.ShapeSquare, d2target.ShapeCircle: + paddingX, paddingY := s.GetDefaultPadding() + + if s.AspectRatio1() { if desiredWidth != 0 || desiredHeight != 0 { paddingX = 0. paddingY = 0. @@ -1161,8 +1149,7 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler sideLength := math.Max(obj.Width+paddingX, obj.Height+paddingY) obj.Width = sideLength obj.Height = sideLength - - default: + } else { if desiredWidth == 0 { obj.Width += float64(paddingX) } @@ -1170,12 +1157,12 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler obj.Height += float64(paddingY) } } - contentBox := geo.NewBox(geo.NewPoint(0, 0), float64(defaultDims.Width), float64(defaultDims.Height)) - shapeType := d2target.DSL_SHAPE_TO_SHAPE_TYPE[dslShape] - s := shape.NewShape(shapeType, contentBox) - newWidth, newHeight := s.GetDimensionsToFit(contentBox.Width, contentBox.Height, paddingX/2) - obj.Width = newWidth - obj.Height = newHeight + + if desiredWidth == 0 && desiredHeight == 0 { + newWidth, newHeight := s.GetDimensionsToFit(contentBox.Width, contentBox.Height, paddingX, paddingY) + obj.Width = newWidth + obj.Height = newHeight + } } for _, edge := range g.Edges { endpointLabels := []string{} diff --git a/lib/shape/shape.go b/lib/shape/shape.go index 1585bad7b..705d209e3 100644 --- a/lib/shape/shape.go +++ b/lib/shape/shape.go @@ -46,7 +46,10 @@ type Shape interface { // placing a rectangle of the given size and padding inside the shape, return the position relative to the shape's TopLeft GetInsidePlacement(width, height, padding float64) geo.Point - GetDimensionsToFit(width, height, padding float64) (float64, float64) + // TODO note change to interface + GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) + + GetDefaultPadding() (paddingX, paddingY float64) // Perimeter returns a slice of geo.Intersectables that together constitute the shape border Perimeter() []geo.Intersectable @@ -93,8 +96,12 @@ func (s baseShape) GetInnerTopLeft(_, _, padding float64) geo.Point { // return the minimum shape dimensions needed to fit content (width x height) // in the shape's innerBox with padding -func (s baseShape) GetDimensionsToFit(width, height, padding float64) (float64, float64) { - return width + padding*2, height + padding*2 +func (s baseShape) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { + return width + paddingX, height + paddingY +} + +func (s baseShape) GetDefaultPadding() (paddingX, paddingY float64) { + return 100., 100. } func (s baseShape) Perimeter() []geo.Intersectable { diff --git a/lib/shape/shape_callout.go b/lib/shape/shape_callout.go index fccd8d5bc..fec727fd1 100644 --- a/lib/shape/shape_callout.go +++ b/lib/shape/shape_callout.go @@ -71,14 +71,14 @@ func (s shapeCallout) GetSVGPathData() []string { } } -func (s shapeCallout) GetDimensionsToFit(width, height, padding float64) (float64, float64) { +func (s shapeCallout) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { // return the minimum shape dimensions needed to fit content (width x height) // in the shape's innerBox with padding - baseHeight := height + padding*2 + baseHeight := height + paddingY if baseHeight < defaultTipHeight { baseHeight *= 2 } else { baseHeight += defaultTipHeight } - return width + padding*2, baseHeight + return width + paddingX, baseHeight } diff --git a/lib/shape/shape_circle.go b/lib/shape/shape_circle.go index 54d981099..ef759f196 100644 --- a/lib/shape/shape_circle.go +++ b/lib/shape/shape_circle.go @@ -33,8 +33,8 @@ func (s shapeCircle) AspectRatio1() bool { return true } -func (s shapeCircle) GetDimensionsToFit(width, height, padding float64) (float64, float64) { - diameter := math.Ceil(math.Sqrt(2 * math.Pow(math.Max(width, height)+2*padding, 2))) +func (s shapeCircle) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { + diameter := math.Ceil(math.Sqrt(2 * math.Pow(math.Max(width+paddingX, height+paddingY), 2))) return diameter, diameter } diff --git a/lib/shape/shape_class.go b/lib/shape/shape_class.go index ac481eadb..4b9bafc19 100644 --- a/lib/shape/shape_class.go +++ b/lib/shape/shape_class.go @@ -19,3 +19,8 @@ func NewClass(box *geo.Box) Shape { }, } } + +func (s shapeClass) GetDefaultPadding() (paddingX, paddingY float64) { + // TODO fix class row width measurements (see SQL table) + return 100, 0 +} diff --git a/lib/shape/shape_cloud.go b/lib/shape/shape_cloud.go index 634098cdb..548d65310 100644 --- a/lib/shape/shape_cloud.go +++ b/lib/shape/shape_cloud.go @@ -58,9 +58,10 @@ func (s shapeCloud) GetInnerBox() *geo.Box { return geo.NewBox(&insideTL, width, height) } -func (s shapeCloud) GetDimensionsToFit(width, height, padding float64) (float64, float64) { - width += padding - height += padding +func (s shapeCloud) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { + // TODO /2? + width += paddingX + height += paddingY aspectRatio := width / height // use the inner box with the closest aspect ratio (wide, tall, or square box) if aspectRatio > CLOUD_WIDE_ASPECT_BOUNDARY { @@ -116,3 +117,7 @@ func (s shapeCloud) GetSVGPathData() []string { cloudPath(s.Box).PathData(), } } + +func (s shapeCloud) GetDefaultPadding() (paddingX, paddingY float64) { + return 50, 50 +} diff --git a/lib/shape/shape_code.go b/lib/shape/shape_code.go index 83fe728e9..2c0f4b1e1 100644 --- a/lib/shape/shape_code.go +++ b/lib/shape/shape_code.go @@ -18,3 +18,7 @@ func NewCode(box *geo.Box) Shape { }, } } + +func (s shapeCode) GetDefaultPadding() (paddingX, paddingY float64) { + return 0, 0 +} diff --git a/lib/shape/shape_cylinder.go b/lib/shape/shape_cylinder.go index 0e97bbd89..4273b49dd 100644 --- a/lib/shape/shape_cylinder.go +++ b/lib/shape/shape_cylinder.go @@ -77,8 +77,8 @@ func (s shapeCylinder) GetSVGPathData() []string { } } -func (s shapeCylinder) GetDimensionsToFit(width, height, padding float64) (float64, float64) { +func (s shapeCylinder) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { // 2 arcs top, height + padding, 1 arc bottom - totalHeight := height + padding*2 + 3*defaultArcDepth - return width + padding*2, totalHeight + totalHeight := height + paddingY + 3*defaultArcDepth + return width + paddingX, totalHeight } diff --git a/lib/shape/shape_diamond.go b/lib/shape/shape_diamond.go index 6c7951955..ef1853679 100644 --- a/lib/shape/shape_diamond.go +++ b/lib/shape/shape_diamond.go @@ -55,8 +55,8 @@ func (s shapeDiamond) GetSVGPathData() []string { } } -func (s shapeDiamond) GetDimensionsToFit(width, height, padding float64) (float64, float64) { - totalWidth := 2 * (width + 2*padding) - totalHeight := 2 * (height + 2*padding) +func (s shapeDiamond) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { + totalWidth := 2 * (width + paddingX) + totalHeight := 2 * (height + paddingY) return totalWidth, totalHeight } diff --git a/lib/shape/shape_document.go b/lib/shape/shape_document.go index 36ffeafcf..81e65f9aa 100644 --- a/lib/shape/shape_document.go +++ b/lib/shape/shape_document.go @@ -52,7 +52,7 @@ func (s shapeDocument) GetSVGPathData() []string { } } -func (s shapeDocument) GetDimensionsToFit(width, height, padding float64) (float64, float64) { - baseHeight := (height + padding*2) * docPathHeight / docPathInnerBottom - return width + padding*2, baseHeight +func (s shapeDocument) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { + baseHeight := (height + paddingX) * docPathHeight / docPathInnerBottom + return width + paddingY, baseHeight } diff --git a/lib/shape/shape_hexagon.go b/lib/shape/shape_hexagon.go index 60aeb26df..0009426c7 100644 --- a/lib/shape/shape_hexagon.go +++ b/lib/shape/shape_hexagon.go @@ -49,7 +49,7 @@ func (s shapeHexagon) GetSVGPathData() []string { } } -func (s shapeHexagon) GetDimensionsToFit(width, height, padding float64) (float64, float64) { - totalWidth := 2 * (width + 2*padding) - return totalWidth, height + 2*padding +func (s shapeHexagon) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { + totalWidth := 2 * (width + paddingX) + return totalWidth, height + paddingY } diff --git a/lib/shape/shape_image.go b/lib/shape/shape_image.go index 7ba782ae5..ae3923298 100644 --- a/lib/shape/shape_image.go +++ b/lib/shape/shape_image.go @@ -20,3 +20,7 @@ func NewImage(box *geo.Box) Shape { func (s shapeImage) IsRectangular() bool { return true } + +func (s shapeImage) GetDefaultPadding() (paddingX, paddingY float64) { + return 0, 0 +} diff --git a/lib/shape/shape_oval.go b/lib/shape/shape_oval.go index 608fd4a38..77ee82fc7 100644 --- a/lib/shape/shape_oval.go +++ b/lib/shape/shape_oval.go @@ -29,11 +29,11 @@ func (s shapeOval) GetInnerBox() *geo.Box { return geo.NewBox(&insideTL, width, height) } -func (s shapeOval) GetDimensionsToFit(width, height, padding float64) (float64, float64) { +func (s shapeOval) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { theta := math.Atan2(height, width) // add padding in direction of diagonal so there is padding distance between top left and border - paddedWidth := width + 2*padding*math.Cos(theta) - paddedHeight := height + 2*padding*math.Sin(theta) + 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) } diff --git a/lib/shape/shape_package.go b/lib/shape/shape_package.go index 3181dcc7e..e0201c260 100644 --- a/lib/shape/shape_package.go +++ b/lib/shape/shape_package.go @@ -72,13 +72,13 @@ func (s shapePackage) GetSVGPathData() []string { } } -func (s shapePackage) GetDimensionsToFit(width, height, padding float64) (float64, float64) { - innerHeight := height + padding*2 +func (s shapePackage) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { + innerHeight := height + paddingY // We want to compute what the topHeight will be to add to inner height; // topHeight=(verticalScalar * totalHeight) and totalHeight=(topHeight + innerHeight) // so solving for topHeight we get: topHeight=innerHeight * (verticalScalar/(1-verticalScalar)) topHeight := innerHeight * packageVerticalScalar / (1. - packageVerticalScalar) totalHeight := innerHeight + math.Min(topHeight, packageTopMaxHeight) - return width + padding*2, totalHeight + return width + paddingX, totalHeight } diff --git a/lib/shape/shape_page.go b/lib/shape/shape_page.go index a355f02ed..4e7609d2f 100644 --- a/lib/shape/shape_page.go +++ b/lib/shape/shape_page.go @@ -86,9 +86,9 @@ func (s shapePage) GetSVGPathData() []string { } } -func (s shapePage) GetDimensionsToFit(width, height, padding float64) (float64, float64) { - totalWidth := width + padding*2 - totalHeight := height + padding*2 +func (s shapePage) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { + totalWidth := width + paddingX + totalHeight := height + paddingY // add space for corner with short pages if totalHeight < 3*pageCornerHeight { totalWidth += pageCornerWidth diff --git a/lib/shape/shape_parallelogram.go b/lib/shape/shape_parallelogram.go index 916a943a9..4666853f6 100644 --- a/lib/shape/shape_parallelogram.go +++ b/lib/shape/shape_parallelogram.go @@ -54,7 +54,7 @@ func (s shapeParallelogram) GetSVGPathData() []string { } } -func (s shapeParallelogram) GetDimensionsToFit(width, height, padding float64) (float64, float64) { - totalWidth := width + padding*2 + parallelWedgeWidth*2 - return totalWidth, height + padding*2 +func (s shapeParallelogram) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { + totalWidth := width + paddingX + parallelWedgeWidth*2 + return totalWidth, height + paddingY } diff --git a/lib/shape/shape_person.go b/lib/shape/shape_person.go index 1be86ebaa..68cf06ab8 100644 --- a/lib/shape/shape_person.go +++ b/lib/shape/shape_person.go @@ -66,11 +66,11 @@ func (s shapePerson) GetSVGPathData() []string { } } -func (s shapePerson) GetDimensionsToFit(width, height, padding float64) (float64, float64) { - totalWidth := width + padding*2 +func (s shapePerson) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { + totalWidth := width + paddingX // see shapePackage shoulderWidth := totalWidth * personShoulderWidthFactor / (1 - 2*personShoulderWidthFactor) totalWidth += 2 * shoulderWidth - totalHeight := height + padding*2 + totalHeight := height + paddingY return totalWidth, totalHeight } diff --git a/lib/shape/shape_queue.go b/lib/shape/shape_queue.go index 0ddaa683d..d5685fbb2 100644 --- a/lib/shape/shape_queue.go +++ b/lib/shape/shape_queue.go @@ -73,8 +73,8 @@ func (s shapeQueue) GetSVGPathData() []string { } } -func (s shapeQueue) GetDimensionsToFit(width, height, padding float64) (float64, float64) { +func (s shapeQueue) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { // 1 arc left, width+ padding, 2 arcs right - totalWidth := 3*defaultArcDepth + width + padding*2 - return totalWidth, height + padding*2 + totalWidth := 3*defaultArcDepth + width + paddingX + return totalWidth, height + paddingY } diff --git a/lib/shape/shape_real_square.go b/lib/shape/shape_real_square.go index 3f2ea71cb..76f3ccbde 100644 --- a/lib/shape/shape_real_square.go +++ b/lib/shape/shape_real_square.go @@ -27,7 +27,7 @@ func (s shapeRealSquare) IsRectangular() bool { return true } -func (s shapeRealSquare) GetDimensionsToFit(width, height, padding float64) (float64, float64) { - sideLength := math.Max(width+padding*2, height+padding*2) +func (s shapeRealSquare) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { + sideLength := math.Max(width+paddingX, height+paddingY) return sideLength, sideLength } diff --git a/lib/shape/shape_step.go b/lib/shape/shape_step.go index 6eb892869..481de7ed8 100644 --- a/lib/shape/shape_step.go +++ b/lib/shape/shape_step.go @@ -54,7 +54,7 @@ func (s shapeStep) GetSVGPathData() []string { } } -func (s shapeStep) GetDimensionsToFit(width, height, padding float64) (float64, float64) { - totalWidth := width + padding*2 + 2*STEP_WEDGE_WIDTH - return totalWidth, height + padding*2 +func (s shapeStep) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { + totalWidth := width + paddingX + 2*STEP_WEDGE_WIDTH + return totalWidth, height + paddingY } diff --git a/lib/shape/shape_stored_data.go b/lib/shape/shape_stored_data.go index e30c7896f..f5961c590 100644 --- a/lib/shape/shape_stored_data.go +++ b/lib/shape/shape_stored_data.go @@ -56,7 +56,7 @@ func (s shapeStoredData) GetSVGPathData() []string { } } -func (s shapeStoredData) GetDimensionsToFit(width, height, padding float64) (float64, float64) { - totalWidth := width + padding*2 + 2*storedDataWedgeWidth - return totalWidth, height + padding*2 +func (s shapeStoredData) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { + totalWidth := width + paddingX + 2*storedDataWedgeWidth + return totalWidth, height + paddingY } diff --git a/lib/shape/shape_table.go b/lib/shape/shape_table.go index 6a9ad8044..6d66b9a43 100644 --- a/lib/shape/shape_table.go +++ b/lib/shape/shape_table.go @@ -19,3 +19,7 @@ func NewTable(box *geo.Box) Shape { }, } } + +func (s shapeTable) GetDefaultPadding() (paddingX, paddingY float64) { + return 0, 0 +} diff --git a/lib/shape/shape_text.go b/lib/shape/shape_text.go index 18343205f..078609e0b 100644 --- a/lib/shape/shape_text.go +++ b/lib/shape/shape_text.go @@ -19,3 +19,7 @@ func NewText(box *geo.Box) Shape { }, } } + +func (s shapeText) GetDefaultPadding() (paddingX, paddingY float64) { + return 0, 0 +} From 6f26167beb865a32ffb5f8b3b4701b0ae16f34b9 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Mon, 23 Jan 2023 17:19:38 -0800 Subject: [PATCH 04/35] fix class dimensions --- d2graph/d2graph.go | 9 ++++----- d2target/class.go | 3 +++ lib/shape/shape_class.go | 3 +-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 65f60cdb9..d92f90233 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -750,7 +750,7 @@ func (obj *Object) GetDefaultSize(mtexts []*d2target.MText, ruler *textmeasure.R return nil, fmt.Errorf("dimensions for class field %#v not found", f.Text()) } lineWidth := fdims.Width - if maxWidth < lineWidth { + if lineWidth > maxWidth { maxWidth = lineWidth } } @@ -760,11 +760,11 @@ func (obj *Object) GetDefaultSize(mtexts []*d2target.MText, ruler *textmeasure.R return nil, fmt.Errorf("dimensions for class method %#v not found", m.Text()) } lineWidth := mdims.Width - if maxWidth < lineWidth { + if lineWidth > maxWidth { maxWidth = lineWidth } } - dims.Width = maxWidth + dims.Width = d2target.PrefixPadding + d2target.PrefixWidth + maxWidth + d2target.CenterPadding + d2target.TypePadding // All rows should be the same height var anyRowText *d2target.MText @@ -774,8 +774,7 @@ func (obj *Object) GetDefaultSize(mtexts []*d2target.MText, ruler *textmeasure.R anyRowText = obj.Class.Methods[0].Text() } if anyRowText != nil { - // 10px of padding top and bottom so text doesn't look squished - rowHeight := GetTextDimensions(mtexts, ruler, anyRowText, go2.Pointer(d2fonts.SourceCodePro)).Height + 20 + rowHeight := GetTextDimensions(mtexts, ruler, anyRowText, go2.Pointer(d2fonts.SourceCodePro)).Height + d2target.VerticalPadding dims.Height = rowHeight * (len(obj.Class.Fields) + len(obj.Class.Methods) + 2) } else { dims.Height = go2.Max(12, labelDims.Height) diff --git a/d2target/class.go b/d2target/class.go index f62a3ea43..3cc39921e 100644 --- a/d2target/class.go +++ b/d2target/class.go @@ -9,6 +9,9 @@ import ( const ( PrefixPadding = 10 PrefixWidth = 20 + CenterPadding = 50 + // 10px of padding top and bottom so text doesn't look squished + VerticalPadding = 20 ) type Class struct { diff --git a/lib/shape/shape_class.go b/lib/shape/shape_class.go index 4b9bafc19..3f7f67a12 100644 --- a/lib/shape/shape_class.go +++ b/lib/shape/shape_class.go @@ -21,6 +21,5 @@ func NewClass(box *geo.Box) Shape { } func (s shapeClass) GetDefaultPadding() (paddingX, paddingY float64) { - // TODO fix class row width measurements (see SQL table) - return 100, 0 + return 0, 0 } From b1beddc9e2d41a1e68683ce1b06faa62870f56c8 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Mon, 23 Jan 2023 19:10:31 -0800 Subject: [PATCH 05/35] Adjust padding per shape --- d2graph/d2graph.go | 12 ++++++++++++ lib/shape/shape.go | 4 +++- lib/shape/shape_callout.go | 4 ++++ lib/shape/shape_circle.go | 4 ++++ lib/shape/shape_cloud.go | 2 +- lib/shape/shape_cylinder.go | 4 ++++ lib/shape/shape_diamond.go | 4 ++++ lib/shape/shape_document.go | 8 ++++++-- lib/shape/shape_hexagon.go | 4 ++++ lib/shape/shape_package.go | 4 ++++ lib/shape/shape_page.go | 4 ++++ lib/shape/shape_person.go | 4 ++++ lib/shape/shape_queue.go | 4 ++++ lib/shape/shape_step.go | 4 ++++ lib/shape/shape_stored_data.go | 4 ++++ 15 files changed, 66 insertions(+), 4 deletions(-) diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index d92f90233..dc5bd13c8 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -1157,6 +1157,18 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler } } + // give shapes with icons extra padding + if obj.Attributes.Icon != nil { + paddingX += 20 + paddingY += 20 + } + if obj.Attributes.Link != "" { + paddingX += 32 + } + if obj.Attributes.Tooltip != "" { + paddingX += 32 + } + if desiredWidth == 0 && desiredHeight == 0 { newWidth, newHeight := s.GetDimensionsToFit(contentBox.Width, contentBox.Height, paddingX, paddingY) obj.Width = newWidth diff --git a/lib/shape/shape.go b/lib/shape/shape.go index 705d209e3..84468ad7b 100644 --- a/lib/shape/shape.go +++ b/lib/shape/shape.go @@ -31,6 +31,8 @@ const ( TEXT_TYPE = "Text" CODE_TYPE = "Code" IMAGE_TYPE = "Image" + + defaultPadding = 40. ) type Shape interface { @@ -101,7 +103,7 @@ func (s baseShape) GetDimensionsToFit(width, height, paddingX, paddingY float64) } func (s baseShape) GetDefaultPadding() (paddingX, paddingY float64) { - return 100., 100. + return defaultPadding, defaultPadding } func (s baseShape) Perimeter() []geo.Intersectable { diff --git a/lib/shape/shape_callout.go b/lib/shape/shape_callout.go index fec727fd1..6c91d2e2c 100644 --- a/lib/shape/shape_callout.go +++ b/lib/shape/shape_callout.go @@ -82,3 +82,7 @@ func (s shapeCallout) GetDimensionsToFit(width, height, paddingX, paddingY float } return width + paddingX, baseHeight } + +func (s shapeCallout) GetDefaultPadding() (paddingX, paddingY float64) { + return defaultPadding, defaultPadding / 2 +} diff --git a/lib/shape/shape_circle.go b/lib/shape/shape_circle.go index ef759f196..7261f37aa 100644 --- a/lib/shape/shape_circle.go +++ b/lib/shape/shape_circle.go @@ -45,3 +45,7 @@ func (s shapeCircle) GetInsidePlacement(width, height, padding float64) geo.Poin func (s shapeCircle) Perimeter() []geo.Intersectable { return []geo.Intersectable{geo.NewEllipse(s.Box.Center(), s.Box.Width/2, s.Box.Height/2)} } + +func (s shapeCircle) GetDefaultPadding() (paddingX, paddingY float64) { + return defaultPadding / 2, defaultPadding / 2 +} diff --git a/lib/shape/shape_cloud.go b/lib/shape/shape_cloud.go index 548d65310..710d7b4c8 100644 --- a/lib/shape/shape_cloud.go +++ b/lib/shape/shape_cloud.go @@ -119,5 +119,5 @@ func (s shapeCloud) GetSVGPathData() []string { } func (s shapeCloud) GetDefaultPadding() (paddingX, paddingY float64) { - return 50, 50 + return defaultPadding, defaultPadding / 2 } diff --git a/lib/shape/shape_cylinder.go b/lib/shape/shape_cylinder.go index 4273b49dd..79cc06e72 100644 --- a/lib/shape/shape_cylinder.go +++ b/lib/shape/shape_cylinder.go @@ -82,3 +82,7 @@ func (s shapeCylinder) GetDimensionsToFit(width, height, paddingX, paddingY floa totalHeight := height + paddingY + 3*defaultArcDepth return width + paddingX, totalHeight } + +func (s shapeCylinder) GetDefaultPadding() (paddingX, paddingY float64) { + return defaultPadding, defaultPadding / 2 +} diff --git a/lib/shape/shape_diamond.go b/lib/shape/shape_diamond.go index ef1853679..b6f95f7a8 100644 --- a/lib/shape/shape_diamond.go +++ b/lib/shape/shape_diamond.go @@ -60,3 +60,7 @@ func (s shapeDiamond) GetDimensionsToFit(width, height, paddingX, paddingY float totalHeight := 2 * (height + paddingY) return totalWidth, totalHeight } + +func (s shapeDiamond) GetDefaultPadding() (paddingX, paddingY float64) { + return defaultPadding / 4, defaultPadding / 2 +} diff --git a/lib/shape/shape_document.go b/lib/shape/shape_document.go index 81e65f9aa..3ee710a28 100644 --- a/lib/shape/shape_document.go +++ b/lib/shape/shape_document.go @@ -53,6 +53,10 @@ func (s shapeDocument) GetSVGPathData() []string { } func (s shapeDocument) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { - baseHeight := (height + paddingX) * docPathHeight / docPathInnerBottom - return width + paddingY, baseHeight + baseHeight := (height + paddingY) * docPathHeight / docPathInnerBottom + return width + paddingX, baseHeight +} + +func (s shapeDocument) GetDefaultPadding() (paddingX, paddingY float64) { + return defaultPadding, defaultPadding * docPathInnerBottom / docPathHeight } diff --git a/lib/shape/shape_hexagon.go b/lib/shape/shape_hexagon.go index 0009426c7..ed6bbcb83 100644 --- a/lib/shape/shape_hexagon.go +++ b/lib/shape/shape_hexagon.go @@ -53,3 +53,7 @@ func (s shapeHexagon) GetDimensionsToFit(width, height, paddingX, paddingY float totalWidth := 2 * (width + paddingX) return totalWidth, height + paddingY } + +func (s shapeHexagon) GetDefaultPadding() (paddingX, paddingY float64) { + return defaultPadding / 4, defaultPadding +} diff --git a/lib/shape/shape_package.go b/lib/shape/shape_package.go index e0201c260..80219fa79 100644 --- a/lib/shape/shape_package.go +++ b/lib/shape/shape_package.go @@ -82,3 +82,7 @@ func (s shapePackage) GetDimensionsToFit(width, height, paddingX, paddingY float return width + paddingX, totalHeight } + +func (s shapePackage) GetDefaultPadding() (paddingX, paddingY float64) { + return defaultPadding, .8 * defaultPadding +} diff --git a/lib/shape/shape_page.go b/lib/shape/shape_page.go index 4e7609d2f..75717c8f2 100644 --- a/lib/shape/shape_page.go +++ b/lib/shape/shape_page.go @@ -97,3 +97,7 @@ func (s shapePage) GetDimensionsToFit(width, height, paddingX, paddingY float64) totalHeight = math.Max(totalHeight, pageCornerHeight) return totalWidth, totalHeight } + +func (s shapePage) GetDefaultPadding() (paddingX, paddingY float64) { + return defaultPadding, pageCornerHeight + defaultPadding +} diff --git a/lib/shape/shape_person.go b/lib/shape/shape_person.go index 68cf06ab8..e92ddab53 100644 --- a/lib/shape/shape_person.go +++ b/lib/shape/shape_person.go @@ -74,3 +74,7 @@ func (s shapePerson) GetDimensionsToFit(width, height, paddingX, paddingY float6 totalHeight := height + paddingY return totalWidth, totalHeight } + +func (s shapePerson) GetDefaultPadding() (paddingX, paddingY float64) { + return 10, defaultPadding +} diff --git a/lib/shape/shape_queue.go b/lib/shape/shape_queue.go index d5685fbb2..5a0a9d32f 100644 --- a/lib/shape/shape_queue.go +++ b/lib/shape/shape_queue.go @@ -78,3 +78,7 @@ func (s shapeQueue) GetDimensionsToFit(width, height, paddingX, paddingY float64 totalWidth := 3*defaultArcDepth + width + paddingX return totalWidth, height + paddingY } + +func (s shapeQueue) GetDefaultPadding() (paddingX, paddingY float64) { + return defaultPadding / 2, defaultPadding +} diff --git a/lib/shape/shape_step.go b/lib/shape/shape_step.go index 481de7ed8..8951e866a 100644 --- a/lib/shape/shape_step.go +++ b/lib/shape/shape_step.go @@ -58,3 +58,7 @@ func (s shapeStep) GetDimensionsToFit(width, height, paddingX, paddingY float64) totalWidth := width + paddingX + 2*STEP_WEDGE_WIDTH return totalWidth, height + paddingY } + +func (s shapeStep) GetDefaultPadding() (paddingX, paddingY float64) { + return defaultPadding / 4, defaultPadding + STEP_WEDGE_WIDTH +} diff --git a/lib/shape/shape_stored_data.go b/lib/shape/shape_stored_data.go index f5961c590..f952c3fd0 100644 --- a/lib/shape/shape_stored_data.go +++ b/lib/shape/shape_stored_data.go @@ -60,3 +60,7 @@ func (s shapeStoredData) GetDimensionsToFit(width, height, paddingX, paddingY fl totalWidth := width + paddingX + 2*storedDataWedgeWidth return totalWidth, height + paddingY } + +func (s shapeStoredData) GetDefaultPadding() (paddingX, paddingY float64) { + return defaultPadding - 10, defaultPadding +} From d5f2ed00d58d804f0abfe7e16c2d89d75e227be6 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Mon, 23 Jan 2023 20:20:42 -0800 Subject: [PATCH 06/35] handle person shape aspect ratio --- lib/shape/shape_person.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/shape/shape_person.go b/lib/shape/shape_person.go index e92ddab53..e177135c8 100644 --- a/lib/shape/shape_person.go +++ b/lib/shape/shape_person.go @@ -72,6 +72,13 @@ func (s shapePerson) GetDimensionsToFit(width, height, paddingX, paddingY float6 shoulderWidth := totalWidth * personShoulderWidthFactor / (1 - 2*personShoulderWidthFactor) totalWidth += 2 * shoulderWidth totalHeight := height + paddingY + + // prevent the shape's aspect ratio from becoming too extreme + if totalWidth > 1.5*totalHeight { + totalHeight = totalWidth / 1.5 + } else if totalHeight > 1.5*totalWidth { + totalWidth = totalHeight / 1.5 + } return totalWidth, totalHeight } From 162227e196f9e0e592f78f695bdfd3fd82971137 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Mon, 23 Jan 2023 20:33:41 -0800 Subject: [PATCH 07/35] only add extra x padding for non-special shapes --- d2graph/d2graph.go | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index dc5bd13c8..e675a9670 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -1162,11 +1162,15 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler paddingX += 20 paddingY += 20 } - if obj.Attributes.Link != "" { - paddingX += 32 - } - if obj.Attributes.Tooltip != "" { - paddingX += 32 + switch shapeType { + case shape.TABLE_TYPE, shape.CLASS_TYPE, shape.CODE_TYPE, shape.IMAGE_TYPE: + default: + if obj.Attributes.Link != "" { + paddingX += 32 + } + if obj.Attributes.Tooltip != "" { + paddingX += 32 + } } if desiredWidth == 0 && desiredHeight == 0 { From b2036e8bdff376d3c3ff2595846a7783e0f91b72 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Mon, 23 Jan 2023 20:39:57 -0800 Subject: [PATCH 08/35] fix sequence diagram actor shape scaling --- d2layouts/d2sequence/sequence_diagram.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/d2layouts/d2sequence/sequence_diagram.go b/d2layouts/d2sequence/sequence_diagram.go index 053694d1a..ddd8d55bc 100644 --- a/d2layouts/d2sequence/sequence_diagram.go +++ b/d2layouts/d2sequence/sequence_diagram.go @@ -105,6 +105,12 @@ func newSequenceDiagram(objects []*d2graph.Object, messages []*d2graph.Edge) *se sd.objectRank[actor] = rank if actor.Width < MIN_ACTOR_WIDTH { + dslShape := strings.ToLower(actor.Attributes.Shape.Value) + switch dslShape { + case d2target.ShapePerson, d2target.ShapeSquare, d2target.ShapeCircle: + // scale shape up to min width uniformly + actor.Height *= MIN_ACTOR_WIDTH / actor.Width + } actor.Width = MIN_ACTOR_WIDTH } sd.maxActorHeight = math.Max(sd.maxActorHeight, actor.Height) From cc8c7756abb98990ec7d084174bdf0c1b8e8b801 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Tue, 24 Jan 2023 12:08:30 -0800 Subject: [PATCH 09/35] cleanup --- lib/shape/shape.go | 6 ------ lib/shape/shape_cloud.go | 2 -- 2 files changed, 8 deletions(-) diff --git a/lib/shape/shape.go b/lib/shape/shape.go index 84468ad7b..484719d99 100644 --- a/lib/shape/shape.go +++ b/lib/shape/shape.go @@ -48,9 +48,7 @@ type Shape interface { // placing a rectangle of the given size and padding inside the shape, return the position relative to the shape's TopLeft GetInsidePlacement(width, height, padding float64) geo.Point - // TODO note change to interface GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) - GetDefaultPadding() (paddingX, paddingY float64) // Perimeter returns a slice of geo.Intersectables that together constitute the shape border @@ -92,10 +90,6 @@ func (s baseShape) GetInsidePlacement(_, _, padding float64) geo.Point { return *geo.NewPoint(s.Box.TopLeft.X+padding, s.Box.TopLeft.Y+padding) } -func (s baseShape) GetInnerTopLeft(_, _, padding float64) geo.Point { - return *geo.NewPoint(s.Box.TopLeft.X+padding, s.Box.TopLeft.Y+padding) -} - // return the minimum shape dimensions needed to fit content (width x height) // in the shape's innerBox with padding func (s baseShape) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { diff --git a/lib/shape/shape_cloud.go b/lib/shape/shape_cloud.go index 710d7b4c8..5e3b19cb7 100644 --- a/lib/shape/shape_cloud.go +++ b/lib/shape/shape_cloud.go @@ -59,7 +59,6 @@ func (s shapeCloud) GetInnerBox() *geo.Box { } func (s shapeCloud) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { - // TODO /2? width += paddingX height += paddingY aspectRatio := width / height @@ -75,7 +74,6 @@ func (s shapeCloud) GetDimensionsToFit(width, height, paddingX, paddingY float64 func (s shapeCloud) GetInsidePlacement(width, height, padding float64) geo.Point { r := s.Box - // only using padding/2 since there's already quite a bit of padding away from the corners width += padding height += padding aspectRatio := width / height From c12e71af15c0fc4d8474356726e3e9d01b238cdc Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Tue, 24 Jan 2023 13:43:06 -0800 Subject: [PATCH 10/35] update circle fitting --- lib/shape/shape_circle.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/shape/shape_circle.go b/lib/shape/shape_circle.go index 7261f37aa..57cb8937f 100644 --- a/lib/shape/shape_circle.go +++ b/lib/shape/shape_circle.go @@ -34,7 +34,7 @@ func (s shapeCircle) AspectRatio1() bool { } func (s shapeCircle) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { - diameter := math.Ceil(math.Sqrt(2 * math.Pow(math.Max(width+paddingX, height+paddingY), 2))) + diameter := math.Ceil(math.Sqrt(math.Pow(width+paddingX, 2) + math.Pow(height+paddingY, 2))) return diameter, diameter } @@ -47,5 +47,5 @@ func (s shapeCircle) Perimeter() []geo.Intersectable { } func (s shapeCircle) GetDefaultPadding() (paddingX, paddingY float64) { - return defaultPadding / 2, defaultPadding / 2 + return defaultPadding / math.Sqrt2, defaultPadding / math.Sqrt2 } From f30fe2c2c4f4c8e3e227c347e532445ae1c2b8a7 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Tue, 24 Jan 2023 15:43:47 -0800 Subject: [PATCH 11/35] round from float32 precision --- lib/label/label.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/label/label.go b/lib/label/label.go index 731b381b8..19da6b7e9 100644 --- a/lib/label/label.go +++ b/lib/label/label.go @@ -317,5 +317,6 @@ func (labelPosition Position) GetPointOnRoute(route geo.Route, strokeWidth, labe // TODO probably use math.Big func chopPrecision(f float64) float64 { - return math.Round(f*10000) / 10000 + // bring down to float32 precision before rounding for consistency across architectures + return math.Round(float64(float32(f*10000)) / 10000) } From e367a007e50e8e835bc461b38f339077b44fcdd6 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Tue, 24 Jan 2023 16:45:08 -0800 Subject: [PATCH 12/35] chopPrecision once at end --- lib/label/label.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/label/label.go b/lib/label/label.go index 19da6b7e9..fff93e1a0 100644 --- a/lib/label/label.go +++ b/lib/label/label.go @@ -266,7 +266,7 @@ func (labelPosition Position) GetPointOnRoute(route geo.Route, strokeWidth, labe offsetX := strokeWidth/2 + float64(PADDING) + width/2 offsetY := strokeWidth/2 + float64(PADDING) + height/2 - return geo.NewPoint(chopPrecision(basePoint.X+normalX*offsetX), chopPrecision(basePoint.Y+normalY*offsetY)) + return geo.NewPoint(basePoint.X+normalX*offsetX, basePoint.Y+normalY*offsetY) } var labelCenter *geo.Point @@ -310,8 +310,8 @@ func (labelPosition Position) GetPointOnRoute(route geo.Route, strokeWidth, labe return nil } // convert from center to top left - labelCenter.X -= chopPrecision(width / 2) - labelCenter.Y -= chopPrecision(height / 2) + labelCenter.X = chopPrecision(labelCenter.X - width/2) + labelCenter.Y = chopPrecision(labelCenter.Y - height/2) return labelCenter } From fed4bd2b9fe35d11ea49480768da3d2b933b3a79 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Tue, 24 Jan 2023 17:32:42 -0800 Subject: [PATCH 13/35] ceil dimensions to fit --- lib/shape/shape.go | 2 +- lib/shape/shape_callout.go | 4 +++- lib/shape/shape_cylinder.go | 4 +++- lib/shape/shape_diamond.go | 4 +++- lib/shape/shape_document.go | 4 +++- lib/shape/shape_hexagon.go | 4 +++- lib/shape/shape_package.go | 2 +- lib/shape/shape_page.go | 2 +- lib/shape/shape_parallelogram.go | 4 +++- lib/shape/shape_person.go | 4 +++- lib/shape/shape_queue.go | 4 +++- lib/shape/shape_real_square.go | 2 +- lib/shape/shape_step.go | 4 +++- lib/shape/shape_stored_data.go | 4 +++- 14 files changed, 34 insertions(+), 14 deletions(-) diff --git a/lib/shape/shape.go b/lib/shape/shape.go index 484719d99..ae4a30f73 100644 --- a/lib/shape/shape.go +++ b/lib/shape/shape.go @@ -93,7 +93,7 @@ func (s baseShape) GetInsidePlacement(_, _, padding float64) geo.Point { // return the minimum shape dimensions needed to fit content (width x height) // in the shape's innerBox with padding func (s baseShape) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { - return width + paddingX, height + paddingY + return math.Ceil(width + paddingX), math.Ceil(height + paddingY) } func (s baseShape) GetDefaultPadding() (paddingX, paddingY float64) { diff --git a/lib/shape/shape_callout.go b/lib/shape/shape_callout.go index 6c91d2e2c..36cd23779 100644 --- a/lib/shape/shape_callout.go +++ b/lib/shape/shape_callout.go @@ -1,6 +1,8 @@ package shape import ( + "math" + "oss.terrastruct.com/d2/lib/geo" "oss.terrastruct.com/d2/lib/svg" ) @@ -80,7 +82,7 @@ func (s shapeCallout) GetDimensionsToFit(width, height, paddingX, paddingY float } else { baseHeight += defaultTipHeight } - return width + paddingX, baseHeight + return math.Ceil(width + paddingX), math.Ceil(baseHeight) } func (s shapeCallout) GetDefaultPadding() (paddingX, paddingY float64) { diff --git a/lib/shape/shape_cylinder.go b/lib/shape/shape_cylinder.go index 79cc06e72..c0dcc6b9a 100644 --- a/lib/shape/shape_cylinder.go +++ b/lib/shape/shape_cylinder.go @@ -1,6 +1,8 @@ package shape import ( + "math" + "oss.terrastruct.com/d2/lib/geo" "oss.terrastruct.com/d2/lib/svg" ) @@ -80,7 +82,7 @@ func (s shapeCylinder) GetSVGPathData() []string { func (s shapeCylinder) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { // 2 arcs top, height + padding, 1 arc bottom totalHeight := height + paddingY + 3*defaultArcDepth - return width + paddingX, totalHeight + return math.Ceil(width + paddingX), math.Ceil(totalHeight) } func (s shapeCylinder) GetDefaultPadding() (paddingX, paddingY float64) { diff --git a/lib/shape/shape_diamond.go b/lib/shape/shape_diamond.go index b6f95f7a8..a0a456cb6 100644 --- a/lib/shape/shape_diamond.go +++ b/lib/shape/shape_diamond.go @@ -1,6 +1,8 @@ package shape import ( + "math" + "oss.terrastruct.com/d2/lib/geo" "oss.terrastruct.com/d2/lib/svg" ) @@ -58,7 +60,7 @@ func (s shapeDiamond) GetSVGPathData() []string { func (s shapeDiamond) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { totalWidth := 2 * (width + paddingX) totalHeight := 2 * (height + paddingY) - return totalWidth, totalHeight + return math.Ceil(totalWidth), math.Ceil(totalHeight) } func (s shapeDiamond) GetDefaultPadding() (paddingX, paddingY float64) { diff --git a/lib/shape/shape_document.go b/lib/shape/shape_document.go index 3ee710a28..e3238ea3c 100644 --- a/lib/shape/shape_document.go +++ b/lib/shape/shape_document.go @@ -1,6 +1,8 @@ package shape import ( + "math" + "oss.terrastruct.com/d2/lib/geo" "oss.terrastruct.com/d2/lib/svg" ) @@ -54,7 +56,7 @@ func (s shapeDocument) GetSVGPathData() []string { func (s shapeDocument) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { baseHeight := (height + paddingY) * docPathHeight / docPathInnerBottom - return width + paddingX, baseHeight + return math.Ceil(width + paddingX), math.Ceil(baseHeight) } func (s shapeDocument) GetDefaultPadding() (paddingX, paddingY float64) { diff --git a/lib/shape/shape_hexagon.go b/lib/shape/shape_hexagon.go index ed6bbcb83..8fef2ffc7 100644 --- a/lib/shape/shape_hexagon.go +++ b/lib/shape/shape_hexagon.go @@ -1,6 +1,8 @@ package shape import ( + "math" + "oss.terrastruct.com/d2/lib/geo" "oss.terrastruct.com/d2/lib/svg" ) @@ -51,7 +53,7 @@ func (s shapeHexagon) GetSVGPathData() []string { func (s shapeHexagon) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { totalWidth := 2 * (width + paddingX) - return totalWidth, height + paddingY + return math.Ceil(totalWidth), math.Ceil(height + paddingY) } func (s shapeHexagon) GetDefaultPadding() (paddingX, paddingY float64) { diff --git a/lib/shape/shape_package.go b/lib/shape/shape_package.go index 80219fa79..39da973c8 100644 --- a/lib/shape/shape_package.go +++ b/lib/shape/shape_package.go @@ -80,7 +80,7 @@ func (s shapePackage) GetDimensionsToFit(width, height, paddingX, paddingY float topHeight := innerHeight * packageVerticalScalar / (1. - packageVerticalScalar) totalHeight := innerHeight + math.Min(topHeight, packageTopMaxHeight) - return width + paddingX, totalHeight + return math.Ceil(width + paddingX), math.Ceil(totalHeight) } func (s shapePackage) GetDefaultPadding() (paddingX, paddingY float64) { diff --git a/lib/shape/shape_page.go b/lib/shape/shape_page.go index 75717c8f2..5a836c4ab 100644 --- a/lib/shape/shape_page.go +++ b/lib/shape/shape_page.go @@ -95,7 +95,7 @@ func (s shapePage) GetDimensionsToFit(width, height, paddingX, paddingY float64) } totalWidth = math.Max(totalWidth, 2*pageCornerWidth) totalHeight = math.Max(totalHeight, pageCornerHeight) - return totalWidth, totalHeight + return math.Ceil(totalWidth), math.Ceil(totalHeight) } func (s shapePage) GetDefaultPadding() (paddingX, paddingY float64) { diff --git a/lib/shape/shape_parallelogram.go b/lib/shape/shape_parallelogram.go index 4666853f6..90c1dc41f 100644 --- a/lib/shape/shape_parallelogram.go +++ b/lib/shape/shape_parallelogram.go @@ -1,6 +1,8 @@ package shape import ( + "math" + "oss.terrastruct.com/d2/lib/geo" "oss.terrastruct.com/d2/lib/svg" ) @@ -56,5 +58,5 @@ func (s shapeParallelogram) GetSVGPathData() []string { func (s shapeParallelogram) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { totalWidth := width + paddingX + parallelWedgeWidth*2 - return totalWidth, height + paddingY + return math.Ceil(totalWidth), math.Ceil(height + paddingY) } diff --git a/lib/shape/shape_person.go b/lib/shape/shape_person.go index e177135c8..415e0e2af 100644 --- a/lib/shape/shape_person.go +++ b/lib/shape/shape_person.go @@ -1,6 +1,8 @@ package shape import ( + "math" + "oss.terrastruct.com/d2/lib/geo" "oss.terrastruct.com/d2/lib/svg" ) @@ -79,7 +81,7 @@ func (s shapePerson) GetDimensionsToFit(width, height, paddingX, paddingY float6 } else if totalHeight > 1.5*totalWidth { totalWidth = totalHeight / 1.5 } - return totalWidth, totalHeight + return math.Ceil(totalWidth), math.Ceil(totalHeight) } func (s shapePerson) GetDefaultPadding() (paddingX, paddingY float64) { diff --git a/lib/shape/shape_queue.go b/lib/shape/shape_queue.go index 5a0a9d32f..10a21ff0d 100644 --- a/lib/shape/shape_queue.go +++ b/lib/shape/shape_queue.go @@ -1,6 +1,8 @@ package shape import ( + "math" + "oss.terrastruct.com/d2/lib/geo" "oss.terrastruct.com/d2/lib/svg" ) @@ -76,7 +78,7 @@ func (s shapeQueue) GetSVGPathData() []string { func (s shapeQueue) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { // 1 arc left, width+ padding, 2 arcs right totalWidth := 3*defaultArcDepth + width + paddingX - return totalWidth, height + paddingY + return math.Ceil(totalWidth), math.Ceil(height + paddingY) } func (s shapeQueue) GetDefaultPadding() (paddingX, paddingY float64) { diff --git a/lib/shape/shape_real_square.go b/lib/shape/shape_real_square.go index 76f3ccbde..3948d7d7a 100644 --- a/lib/shape/shape_real_square.go +++ b/lib/shape/shape_real_square.go @@ -28,6 +28,6 @@ func (s shapeRealSquare) IsRectangular() bool { } func (s shapeRealSquare) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { - sideLength := math.Max(width+paddingX, height+paddingY) + sideLength := math.Ceil(math.Max(width+paddingX, height+paddingY)) return sideLength, sideLength } diff --git a/lib/shape/shape_step.go b/lib/shape/shape_step.go index 8951e866a..c7b9dc0e0 100644 --- a/lib/shape/shape_step.go +++ b/lib/shape/shape_step.go @@ -1,6 +1,8 @@ package shape import ( + "math" + "oss.terrastruct.com/d2/lib/geo" "oss.terrastruct.com/d2/lib/svg" ) @@ -56,7 +58,7 @@ func (s shapeStep) GetSVGPathData() []string { func (s shapeStep) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { totalWidth := width + paddingX + 2*STEP_WEDGE_WIDTH - return totalWidth, height + paddingY + return math.Ceil(totalWidth), math.Ceil(height + paddingY) } func (s shapeStep) GetDefaultPadding() (paddingX, paddingY float64) { diff --git a/lib/shape/shape_stored_data.go b/lib/shape/shape_stored_data.go index f952c3fd0..69e127e7e 100644 --- a/lib/shape/shape_stored_data.go +++ b/lib/shape/shape_stored_data.go @@ -1,6 +1,8 @@ package shape import ( + "math" + "oss.terrastruct.com/d2/lib/geo" "oss.terrastruct.com/d2/lib/svg" ) @@ -58,7 +60,7 @@ func (s shapeStoredData) GetSVGPathData() []string { func (s shapeStoredData) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { totalWidth := width + paddingX + 2*storedDataWedgeWidth - return totalWidth, height + paddingY + return math.Ceil(totalWidth), math.Ceil(height + paddingY) } func (s shapeStoredData) GetDefaultPadding() (paddingX, paddingY float64) { From 597bc319bfc7efe5396142acac3c77616bd462bf Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Tue, 24 Jan 2023 18:10:57 -0800 Subject: [PATCH 14/35] update other chopPrecision --- lib/svg/path.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/svg/path.go b/lib/svg/path.go index fa448d419..cc3ac8ef2 100644 --- a/lib/svg/path.go +++ b/lib/svg/path.go @@ -20,7 +20,8 @@ type SvgPathContext struct { // TODO probably use math.Big func chopPrecision(f float64) float64 { - return math.Round(f*10000) / 10000 + // bring down to float32 precision before rounding for consistency across architectures + return math.Round(float64(float32(f*10000)) / 10000) } func NewSVGPathContext(tl *geo.Point, sx, sy float64) *SvgPathContext { From bd23d0758bb1e2630eb2b1c3d36df483b9bc6c06 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 25 Jan 2023 12:24:56 -0800 Subject: [PATCH 15/35] update hexagon inner box --- lib/shape/shape_hexagon.go | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/shape/shape_hexagon.go b/lib/shape/shape_hexagon.go index 8fef2ffc7..3d4492053 100644 --- a/lib/shape/shape_hexagon.go +++ b/lib/shape/shape_hexagon.go @@ -22,10 +22,13 @@ func NewHexagon(box *geo.Box) Shape { func (s shapeHexagon) GetInnerBox() *geo.Box { width := s.Box.Width + height := s.Box.Height tl := s.Box.TopLeft.Copy() - tl.X += width / 4. - width /= 2. - return geo.NewBox(tl, width, s.Box.Height) + tl.X += width / 6. + width /= 1.5 + tl.Y += height / 6. + height /= 1.5 + return geo.NewBox(tl, width, height) } func hexagonPath(box *geo.Box) *svg.SvgPathContext { @@ -52,10 +55,11 @@ func (s shapeHexagon) GetSVGPathData() []string { } func (s shapeHexagon) GetDimensionsToFit(width, height, paddingX, paddingY float64) (float64, float64) { - totalWidth := 2 * (width + paddingX) - return math.Ceil(totalWidth), math.Ceil(height + paddingY) + totalWidth := 1.5 * (width + paddingX) + totalHeight := 1.5 * (height + paddingY) + return math.Ceil(totalWidth), math.Ceil(totalHeight) } func (s shapeHexagon) GetDefaultPadding() (paddingX, paddingY float64) { - return defaultPadding / 4, defaultPadding + return defaultPadding / 2, defaultPadding / 2 } From ce0d81650d602e0216a03a5758f465c65903f0ae Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 25 Jan 2023 12:32:36 -0800 Subject: [PATCH 16/35] update tests --- .../testdata/all_shapes/sketch.exp.svg | 6 +- .../d2sketch/testdata/animated/sketch.exp.svg | 6 +- .../testdata/arrowheads/sketch.exp.svg | 24 +- .../d2sketch/testdata/basic/sketch.exp.svg | 6 +- .../testdata/child_to_child/sketch.exp.svg | 6 +- .../testdata/connection_label/sketch.exp.svg | 8 +- .../d2sketch/testdata/opacity/sketch.exp.svg | 14 +- .../d2sketch/testdata/twitter/sketch.exp.svg | 22 +- .../diagram_wider_than_tooltip/sketch.exp.svg | 38 +- .../appendix/testdata/links/sketch.exp.svg | 14 +- .../tooltip_wider_than_diagram/sketch.exp.svg | 12 +- .../dagre/board.exp.json | 76 +- .../dagre/sketch.exp.svg | 8 +- .../dagre_broken_arrowhead/elk/board.exp.json | 82 +- .../dagre_broken_arrowhead/elk/sketch.exp.svg | 8 +- .../dagre/board.exp.json | 96 +- .../dagre/sketch.exp.svg | 14 +- .../elk/board.exp.json | 64 +- .../elk/sketch.exp.svg | 14 +- .../dagre_special_ids/dagre/board.exp.json | 90 +- .../dagre_special_ids/dagre/sketch.exp.svg | 6 +- .../dagre_special_ids/elk/board.exp.json | 82 +- .../dagre_special_ids/elk/sketch.exp.svg | 6 +- .../elk_alignment/dagre/board.exp.json | 214 +- .../elk_alignment/dagre/sketch.exp.svg | 22 +- .../elk_alignment/elk/board.exp.json | 158 +- .../elk_alignment/elk/sketch.exp.svg | 22 +- .../dagre/board.exp.json | 8 +- .../dagre/sketch.exp.svg | 6 +- .../elk/board.exp.json | 8 +- .../elk/sketch.exp.svg | 6 +- .../elk_loop_panic/dagre/board.exp.json | 60 +- .../elk_loop_panic/dagre/sketch.exp.svg | 6 +- .../elk_loop_panic/elk/board.exp.json | 22 +- .../elk_loop_panic/elk/sketch.exp.svg | 6 +- .../regression/elk_order/dagre/board.exp.json | 84 +- .../regression/elk_order/dagre/sketch.exp.svg | 14 +- .../regression/elk_order/elk/board.exp.json | 76 +- .../regression/elk_order/elk/sketch.exp.svg | 14 +- .../empty_sequence/dagre/board.exp.json | 30 +- .../empty_sequence/dagre/sketch.exp.svg | 6 +- .../empty_sequence/elk/board.exp.json | 18 +- .../empty_sequence/elk/sketch.exp.svg | 6 +- .../md_h1_li_li/dagre/board.exp.json | 58 +- .../md_h1_li_li/dagre/sketch.exp.svg | 8 +- .../regression/md_h1_li_li/elk/board.exp.json | 34 +- .../regression/md_h1_li_li/elk/sketch.exp.svg | 8 +- .../opacity-on-label/dagre/board.exp.json | 26 +- .../opacity-on-label/dagre/sketch.exp.svg | 10 +- .../opacity-on-label/elk/board.exp.json | 22 +- .../opacity-on-label/elk/sketch.exp.svg | 10 +- .../dagre/board.exp.json | 124 +- .../dagre/sketch.exp.svg | 14 +- .../overlapping-edge-label/elk/board.exp.json | 118 +- .../overlapping-edge-label/elk/sketch.exp.svg | 14 +- .../query_param_escape/dagre/board.exp.json | 4 +- .../query_param_escape/dagre/sketch.exp.svg | 6 +- .../query_param_escape/elk/board.exp.json | 4 +- .../query_param_escape/elk/sketch.exp.svg | 6 +- .../dagre/board.exp.json | 58 +- .../dagre/sketch.exp.svg | 6 +- .../elk/board.exp.json | 46 +- .../elk/sketch.exp.svg | 6 +- .../dagre/board.exp.json | 12 +- .../dagre/sketch.exp.svg | 6 +- .../elk/board.exp.json | 12 +- .../elk/sketch.exp.svg | 6 +- .../dagre/board.exp.json | 24 +- .../dagre/sketch.exp.svg | 6 +- .../elk/board.exp.json | 24 +- .../elk/sketch.exp.svg | 6 +- .../sanity/1_to_2/dagre/board.exp.json | 60 +- .../sanity/1_to_2/dagre/sketch.exp.svg | 6 +- .../testdata/sanity/1_to_2/elk/board.exp.json | 44 +- .../testdata/sanity/1_to_2/elk/sketch.exp.svg | 6 +- .../sanity/basic/dagre/board.exp.json | 30 +- .../sanity/basic/dagre/sketch.exp.svg | 6 +- .../testdata/sanity/basic/elk/board.exp.json | 18 +- .../testdata/sanity/basic/elk/sketch.exp.svg | 6 +- .../child_to_child/dagre/board.exp.json | 60 +- .../child_to_child/dagre/sketch.exp.svg | 6 +- .../sanity/child_to_child/elk/board.exp.json | 28 +- .../sanity/child_to_child/elk/sketch.exp.svg | 6 +- .../connection_label/dagre/board.exp.json | 26 +- .../connection_label/dagre/sketch.exp.svg | 8 +- .../connection_label/elk/board.exp.json | 18 +- .../connection_label/elk/sketch.exp.svg | 8 +- .../stable/all_shapes/dagre/board.exp.json | 304 +- .../stable/all_shapes/dagre/sketch.exp.svg | 6 +- .../stable/all_shapes/elk/board.exp.json | 216 +- .../stable/all_shapes/elk/sketch.exp.svg | 6 +- .../all_shapes_multiple/dagre/board.exp.json | 304 +- .../all_shapes_multiple/dagre/sketch.exp.svg | 6 +- .../all_shapes_multiple/elk/board.exp.json | 216 +- .../all_shapes_multiple/elk/sketch.exp.svg | 6 +- .../all_shapes_shadow/dagre/board.exp.json | 304 +- .../all_shapes_shadow/dagre/sketch.exp.svg | 6 +- .../all_shapes_shadow/elk/board.exp.json | 216 +- .../all_shapes_shadow/elk/sketch.exp.svg | 6 +- .../stable/animated/dagre/board.exp.json | 220 +- .../stable/animated/dagre/sketch.exp.svg | 8 +- .../stable/animated/elk/board.exp.json | 180 +- .../stable/animated/elk/sketch.exp.svg | 8 +- .../arrowhead_adjustment/dagre/board.exp.json | 128 +- .../arrowhead_adjustment/dagre/sketch.exp.svg | 6 +- .../arrowhead_adjustment/elk/board.exp.json | 102 +- .../arrowhead_adjustment/elk/sketch.exp.svg | 6 +- .../arrowhead_labels/dagre/board.exp.json | 22 +- .../arrowhead_labels/dagre/sketch.exp.svg | 8 +- .../arrowhead_labels/elk/board.exp.json | 18 +- .../arrowhead_labels/elk/sketch.exp.svg | 8 +- .../stable/binary_tree/dagre/board.exp.json | 340 +- .../stable/binary_tree/dagre/sketch.exp.svg | 6 +- .../stable/binary_tree/elk/board.exp.json | 284 +- .../stable/binary_tree/elk/sketch.exp.svg | 6 +- .../stable/border-radius/dagre/board.exp.json | 10 +- .../stable/border-radius/dagre/sketch.exp.svg | 6 +- .../stable/border-radius/elk/board.exp.json | 10 +- .../stable/border-radius/elk/sketch.exp.svg | 6 +- .../stable/chaos1/dagre/board.exp.json | 60 +- .../stable/chaos1/dagre/sketch.exp.svg | 10 +- .../testdata/stable/chaos1/elk/board.exp.json | 48 +- .../testdata/stable/chaos1/elk/sketch.exp.svg | 10 +- .../stable/chaos2/dagre/board.exp.json | 314 +- .../stable/chaos2/dagre/sketch.exp.svg | 22 +- .../testdata/stable/chaos2/elk/board.exp.json | 296 +- .../testdata/stable/chaos2/elk/sketch.exp.svg | 22 +- .../child_parent_edges/dagre/board.exp.json | 116 +- .../child_parent_edges/dagre/sketch.exp.svg | 6 +- .../child_parent_edges/elk/board.exp.json | 30 +- .../child_parent_edges/elk/sketch.exp.svg | 6 +- .../circle_arrowhead/dagre/board.exp.json | 56 +- .../circle_arrowhead/dagre/sketch.exp.svg | 10 +- .../circle_arrowhead/elk/board.exp.json | 40 +- .../circle_arrowhead/elk/sketch.exp.svg | 10 +- .../circular_dependency/dagre/board.exp.json | 88 +- .../circular_dependency/dagre/sketch.exp.svg | 6 +- .../circular_dependency/elk/board.exp.json | 48 +- .../circular_dependency/elk/sketch.exp.svg | 6 +- .../stable/code_snippet/dagre/board.exp.json | 48 +- .../stable/code_snippet/dagre/sketch.exp.svg | 8 +- .../stable/code_snippet/elk/board.exp.json | 24 +- .../stable/code_snippet/elk/sketch.exp.svg | 8 +- .../connected_container/dagre/board.exp.json | 134 +- .../connected_container/dagre/sketch.exp.svg | 6 +- .../connected_container/elk/board.exp.json | 54 +- .../connected_container/elk/sketch.exp.svg | 6 +- .../constant_near_stress/dagre/board.exp.json | 62 +- .../constant_near_stress/dagre/sketch.exp.svg | 8 +- .../constant_near_stress/elk/board.exp.json | 50 +- .../constant_near_stress/elk/sketch.exp.svg | 8 +- .../constant_near_title/dagre/board.exp.json | 134 +- .../constant_near_title/dagre/sketch.exp.svg | 8 +- .../constant_near_title/elk/board.exp.json | 92 +- .../constant_near_title/elk/sketch.exp.svg | 8 +- .../container_edges/dagre/board.exp.json | 158 +- .../container_edges/dagre/sketch.exp.svg | 6 +- .../stable/container_edges/elk/board.exp.json | 126 +- .../stable/container_edges/elk/sketch.exp.svg | 6 +- .../crow_foot_arrowhead/dagre/board.exp.json | 146 +- .../crow_foot_arrowhead/dagre/sketch.exp.svg | 6 +- .../crow_foot_arrowhead/elk/board.exp.json | 102 +- .../crow_foot_arrowhead/elk/sketch.exp.svg | 6 +- .../stable/dense/dagre/board.exp.json | 648 ++-- .../stable/dense/dagre/sketch.exp.svg | 6 +- .../testdata/stable/dense/elk/board.exp.json | 472 +-- .../testdata/stable/dense/elk/sketch.exp.svg | 6 +- .../different_subgraphs/dagre/board.exp.json | 454 +-- .../different_subgraphs/dagre/sketch.exp.svg | 6 +- .../different_subgraphs/elk/board.exp.json | 362 +- .../different_subgraphs/elk/sketch.exp.svg | 6 +- .../stable/direction/dagre/board.exp.json | 284 +- .../stable/direction/dagre/sketch.exp.svg | 6 +- .../stable/direction/elk/board.exp.json | 184 +- .../stable/direction/elk/sketch.exp.svg | 6 +- .../stable/font_colors/dagre/board.exp.json | 26 +- .../stable/font_colors/dagre/sketch.exp.svg | 8 +- .../stable/font_colors/elk/board.exp.json | 18 +- .../stable/font_colors/elk/sketch.exp.svg | 8 +- .../stable/font_sizes/dagre/board.exp.json | 122 +- .../stable/font_sizes/dagre/sketch.exp.svg | 12 +- .../stable/font_sizes/elk/board.exp.json | 98 +- .../stable/font_sizes/elk/sketch.exp.svg | 12 +- .../giant_markdown_test/dagre/board.exp.json | 48 +- .../giant_markdown_test/dagre/sketch.exp.svg | 8 +- .../giant_markdown_test/elk/board.exp.json | 24 +- .../giant_markdown_test/elk/sketch.exp.svg | 8 +- .../testdata/stable/hr/dagre/board.exp.json | 48 +- .../testdata/stable/hr/dagre/sketch.exp.svg | 8 +- .../testdata/stable/hr/elk/board.exp.json | 24 +- .../testdata/stable/hr/elk/sketch.exp.svg | 8 +- .../stable/icon-label/dagre/board.exp.json | 4 +- .../stable/icon-label/dagre/sketch.exp.svg | 6 +- .../stable/icon-label/elk/board.exp.json | 4 +- .../stable/icon-label/elk/sketch.exp.svg | 6 +- .../stable/images/dagre/board.exp.json | 28 +- .../stable/images/dagre/sketch.exp.svg | 6 +- .../testdata/stable/images/elk/board.exp.json | 18 +- .../testdata/stable/images/elk/sketch.exp.svg | 6 +- .../stable/investigate/dagre/board.exp.json | 1386 +++---- .../stable/investigate/dagre/sketch.exp.svg | 18 +- .../stable/investigate/elk/board.exp.json | 554 +-- .../stable/investigate/elk/sketch.exp.svg | 18 +- .../stable/large_arch/dagre/board.exp.json | 1034 +++--- .../stable/large_arch/dagre/sketch.exp.svg | 6 +- .../stable/large_arch/elk/board.exp.json | 512 +-- .../stable/large_arch/elk/sketch.exp.svg | 6 +- .../stable/latex/dagre/board.exp.json | 78 +- .../stable/latex/dagre/sketch.exp.svg | 8 +- .../testdata/stable/latex/elk/board.exp.json | 66 +- .../testdata/stable/latex/elk/sketch.exp.svg | 8 +- .../testdata/stable/li1/dagre/board.exp.json | 48 +- .../testdata/stable/li1/dagre/sketch.exp.svg | 8 +- .../testdata/stable/li1/elk/board.exp.json | 24 +- .../testdata/stable/li1/elk/sketch.exp.svg | 8 +- .../testdata/stable/li2/dagre/board.exp.json | 48 +- .../testdata/stable/li2/dagre/sketch.exp.svg | 8 +- .../testdata/stable/li2/elk/board.exp.json | 24 +- .../testdata/stable/li2/elk/sketch.exp.svg | 8 +- .../testdata/stable/li3/dagre/board.exp.json | 48 +- .../testdata/stable/li3/dagre/sketch.exp.svg | 8 +- .../testdata/stable/li3/elk/board.exp.json | 24 +- .../testdata/stable/li3/elk/sketch.exp.svg | 8 +- .../testdata/stable/li4/dagre/board.exp.json | 48 +- .../testdata/stable/li4/dagre/sketch.exp.svg | 8 +- .../testdata/stable/li4/elk/board.exp.json | 24 +- .../testdata/stable/li4/elk/sketch.exp.svg | 8 +- .../stable/links/dagre/board.exp.json | 32 +- .../stable/links/dagre/sketch.exp.svg | 12 +- .../testdata/stable/links/elk/board.exp.json | 20 +- .../testdata/stable/links/elk/sketch.exp.svg | 12 +- .../stable/lone_h1/dagre/board.exp.json | 48 +- .../stable/lone_h1/dagre/sketch.exp.svg | 8 +- .../stable/lone_h1/elk/board.exp.json | 24 +- .../stable/lone_h1/elk/sketch.exp.svg | 8 +- .../stable/markdown/dagre/board.exp.json | 48 +- .../stable/markdown/dagre/sketch.exp.svg | 8 +- .../stable/markdown/elk/board.exp.json | 24 +- .../stable/markdown/elk/sketch.exp.svg | 8 +- .../md_code_block_fenced/dagre/board.exp.json | 48 +- .../md_code_block_fenced/dagre/sketch.exp.svg | 8 +- .../md_code_block_fenced/elk/board.exp.json | 24 +- .../md_code_block_fenced/elk/sketch.exp.svg | 8 +- .../dagre/board.exp.json | 48 +- .../dagre/sketch.exp.svg | 8 +- .../md_code_block_indented/elk/board.exp.json | 24 +- .../md_code_block_indented/elk/sketch.exp.svg | 8 +- .../md_code_inline/dagre/board.exp.json | 54 +- .../md_code_inline/dagre/sketch.exp.svg | 8 +- .../stable/md_code_inline/elk/board.exp.json | 30 +- .../stable/md_code_inline/elk/sketch.exp.svg | 8 +- .../multiline_text/dagre/board.exp.json | 4 +- .../multiline_text/dagre/sketch.exp.svg | 6 +- .../stable/multiline_text/elk/board.exp.json | 4 +- .../stable/multiline_text/elk/sketch.exp.svg | 6 +- .../multiple_trees/dagre/board.exp.json | 538 +-- .../multiple_trees/dagre/sketch.exp.svg | 6 +- .../stable/multiple_trees/elk/board.exp.json | 450 +-- .../stable/multiple_trees/elk/sketch.exp.svg | 6 +- .../stable/n22_e32/dagre/board.exp.json | 1008 +++--- .../stable/n22_e32/dagre/sketch.exp.svg | 6 +- .../stable/n22_e32/elk/board.exp.json | 678 ++-- .../stable/n22_e32/elk/sketch.exp.svg | 6 +- .../stable/near-alone/dagre/board.exp.json | 22 +- .../stable/near-alone/dagre/sketch.exp.svg | 6 +- .../stable/near-alone/elk/board.exp.json | 22 +- .../stable/near-alone/elk/sketch.exp.svg | 6 +- .../number_connections/dagre/board.exp.json | 64 +- .../number_connections/dagre/sketch.exp.svg | 6 +- .../number_connections/elk/board.exp.json | 40 +- .../number_connections/elk/sketch.exp.svg | 6 +- .../one_container_loop/dagre/board.exp.json | 282 +- .../one_container_loop/dagre/sketch.exp.svg | 6 +- .../one_container_loop/elk/board.exp.json | 150 +- .../one_container_loop/elk/sketch.exp.svg | 6 +- .../dagre/board.exp.json | 144 +- .../dagre/sketch.exp.svg | 6 +- .../elk/board.exp.json | 148 +- .../elk/sketch.exp.svg | 6 +- .../dagre/board.exp.json | 210 +- .../dagre/sketch.exp.svg | 18 +- .../elk/board.exp.json | 190 +- .../elk/sketch.exp.svg | 18 +- .../testdata/stable/p/dagre/board.exp.json | 48 +- .../testdata/stable/p/dagre/sketch.exp.svg | 8 +- e2etests/testdata/stable/p/elk/board.exp.json | 24 +- e2etests/testdata/stable/p/elk/sketch.exp.svg | 8 +- .../testdata/stable/pre/dagre/board.exp.json | 48 +- .../testdata/stable/pre/dagre/sketch.exp.svg | 8 +- .../testdata/stable/pre/elk/board.exp.json | 24 +- .../testdata/stable/pre/elk/sketch.exp.svg | 8 +- .../self-referencing/dagre/board.exp.json | 188 +- .../self-referencing/dagre/sketch.exp.svg | 8 +- .../self-referencing/elk/board.exp.json | 74 +- .../self-referencing/elk/sketch.exp.svg | 8 +- .../dagre/board.exp.json | 32 +- .../dagre/sketch.exp.svg | 12 +- .../elk/board.exp.json | 32 +- .../elk/sketch.exp.svg | 12 +- .../dagre/board.exp.json | 128 +- .../dagre/sketch.exp.svg | 16 +- .../elk/board.exp.json | 128 +- .../elk/sketch.exp.svg | 16 +- .../dagre/board.exp.json | 252 +- .../dagre/sketch.exp.svg | 18 +- .../elk/board.exp.json | 252 +- .../elk/sketch.exp.svg | 18 +- .../dagre/board.exp.json | 20 +- .../dagre/sketch.exp.svg | 10 +- .../elk/board.exp.json | 20 +- .../elk/sketch.exp.svg | 10 +- .../dagre/board.exp.json | 106 +- .../dagre/sketch.exp.svg | 24 +- .../elk/board.exp.json | 106 +- .../elk/sketch.exp.svg | 24 +- .../dagre/board.exp.json | 38 +- .../dagre/sketch.exp.svg | 6 +- .../elk/board.exp.json | 38 +- .../elk/sketch.exp.svg | 6 +- .../dagre/board.exp.json | 182 +- .../dagre/sketch.exp.svg | 26 +- .../elk/board.exp.json | 182 +- .../elk/sketch.exp.svg | 26 +- .../dagre/board.exp.json | 130 +- .../dagre/sketch.exp.svg | 6 +- .../elk/board.exp.json | 130 +- .../elk/sketch.exp.svg | 6 +- .../dagre/board.exp.json | 68 +- .../dagre/sketch.exp.svg | 8 +- .../sequence_diagram_note/elk/board.exp.json | 68 +- .../sequence_diagram_note/elk/sketch.exp.svg | 8 +- .../dagre/board.exp.json | 194 +- .../dagre/sketch.exp.svg | 34 +- .../sequence_diagram_real/elk/board.exp.json | 194 +- .../sequence_diagram_real/elk/sketch.exp.svg | 34 +- .../dagre/board.exp.json | 66 +- .../dagre/sketch.exp.svg | 18 +- .../elk/board.exp.json | 66 +- .../elk/sketch.exp.svg | 18 +- .../dagre/board.exp.json | 148 +- .../dagre/sketch.exp.svg | 22 +- .../elk/board.exp.json | 148 +- .../elk/sketch.exp.svg | 22 +- .../dagre/board.exp.json | 136 +- .../dagre/sketch.exp.svg | 30 +- .../sequence_diagram_span/elk/board.exp.json | 136 +- .../sequence_diagram_span/elk/sketch.exp.svg | 30 +- .../sequence_diagrams/dagre/board.exp.json | 802 ++-- .../sequence_diagrams/dagre/sketch.exp.svg | 54 +- .../sequence_diagrams/elk/board.exp.json | 726 ++-- .../sequence_diagrams/elk/sketch.exp.svg | 54 +- .../stable/square_3d/dagre/board.exp.json | 30 +- .../stable/square_3d/dagre/sketch.exp.svg | 14 +- .../stable/square_3d/elk/board.exp.json | 18 +- .../stable/square_3d/elk/sketch.exp.svg | 14 +- .../dagre/board.exp.json | 562 +-- .../dagre/sketch.exp.svg | 6 +- .../elk/board.exp.json | 330 +- .../elk/sketch.exp.svg | 6 +- .../stable/stylish/dagre/board.exp.json | 26 +- .../stable/stylish/dagre/sketch.exp.svg | 12 +- .../stable/stylish/elk/board.exp.json | 18 +- .../stable/stylish/elk/sketch.exp.svg | 12 +- .../stable/tooltips/dagre/board.exp.json | 30 +- .../stable/tooltips/dagre/sketch.exp.svg | 10 +- .../stable/tooltips/elk/board.exp.json | 18 +- .../stable/tooltips/elk/sketch.exp.svg | 10 +- .../transparent_3d/dagre/board.exp.json | 4 +- .../transparent_3d/dagre/sketch.exp.svg | 10 +- .../stable/transparent_3d/elk/board.exp.json | 4 +- .../stable/transparent_3d/elk/sketch.exp.svg | 10 +- .../unnamed_only_width/dagre/board.exp.json | 4 +- .../unnamed_only_width/dagre/sketch.exp.svg | 2 +- .../unnamed_only_width/elk/board.exp.json | 2 +- .../unnamed_only_width/elk/sketch.exp.svg | 2 +- .../stable/us_map/dagre/board.exp.json | 3212 ++++++++--------- .../stable/us_map/dagre/sketch.exp.svg | 6 +- .../testdata/stable/us_map/elk/board.exp.json | 1950 +++++----- .../testdata/stable/us_map/elk/sketch.exp.svg | 6 +- .../container_child_edge/dagre/board.exp.json | 50 +- .../container_child_edge/dagre/sketch.exp.svg | 10 +- .../container_child_edge/elk/board.exp.json | 34 +- .../container_child_edge/elk/sketch.exp.svg | 10 +- .../dagre/board.exp.json | 20 +- .../dagre/sketch.exp.svg | 6 +- .../elk/board.exp.json | 20 +- .../elk/sketch.exp.svg | 6 +- .../font_sizes_large/dagre/board.exp.json | 92 +- .../font_sizes_large/dagre/sketch.exp.svg | 14 +- .../todo/font_sizes_large/elk/board.exp.json | 60 +- .../todo/font_sizes_large/elk/sketch.exp.svg | 14 +- .../dagre/board.exp.json | 52 +- .../dagre/sketch.exp.svg | 16 +- .../elk/board.exp.json | 52 +- .../elk/sketch.exp.svg | 16 +- .../dagre/board.exp.json | 16 +- .../dagre/sketch.exp.svg | 6 +- .../shape_set_width_height/elk/board.exp.json | 10 +- .../shape_set_width_height/elk/sketch.exp.svg | 6 +- .../todo/tall_edge_label/dagre/board.exp.json | 26 +- .../todo/tall_edge_label/dagre/sketch.exp.svg | 8 +- .../todo/tall_edge_label/elk/board.exp.json | 18 +- .../todo/tall_edge_label/elk/sketch.exp.svg | 8 +- 403 files changed, 16020 insertions(+), 15972 deletions(-) diff --git a/d2renderers/d2sketch/testdata/all_shapes/sketch.exp.svg b/d2renderers/d2sketch/testdata/all_shapes/sketch.exp.svg index f0a8aabf2..05eaa9547 100644 --- a/d2renderers/d2sketch/testdata/all_shapes/sketch.exp.svg +++ b/d2renderers/d2sketch/testdata/all_shapes/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="1597" height="835" viewBox="-102 -102 1597 835">1Like starbucks or something -2I'm not sure what this is +}]]>1Like starbucks or something +2I'm not sure what this is 1https://d2lang.com -2Gee, I feel kind of LIGHT in the head now,knowing I can't make my satellite dish PAYMENTS! -3https://terrastruct.com +}]]>1https://d2lang.com +2Gee, I feel kind of LIGHT in the head now,knowing I can't make my satellite dish PAYMENTS! +3https://terrastruct.com 1Total abstinence is easier than perfect moderation -2Gee, I feel kind of LIGHT in the head now,knowing I can't make my satellite dish PAYMENTS! +}]]>1Total abstinence is easier than perfect moderation +2Gee, I feel kind of LIGHT in the head now,knowing I can't make my satellite dish PAYMENTS! \ No newline at end of file diff --git a/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json index bdd6a327a..9bb8b113d 100644 --- a/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json +++ b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json @@ -9,8 +9,8 @@ "x": 12, "y": 12 }, - "width": 128, - "height": 128, + "width": 148, + "height": 148, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -57,8 +57,8 @@ "id": "ico", "type": "", "pos": { - "x": 160, - "y": 26 + "x": 180, + "y": 36 }, "width": 100, "height": 100, diff --git a/e2etests/testdata/regression/elk_img_empty_label_panic/elk/sketch.exp.svg b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/sketch.exp.svg index b7128f39d..17fab0d6c 100644 --- a/e2etests/testdata/regression/elk_img_empty_label_panic/elk/sketch.exp.svg +++ b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/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="452" height="332" viewBox="-90 -90 452 332"> \ No newline at end of file diff --git a/e2etests/testdata/regression/elk_loop_panic/dagre/board.exp.json b/e2etests/testdata/regression/elk_loop_panic/dagre/board.exp.json index 33dc2e5da..2ce46a8b7 100644 --- a/e2etests/testdata/regression/elk_loop_panic/dagre/board.exp.json +++ b/e2etests/testdata/regression/elk_loop_panic/dagre/board.exp.json @@ -9,8 +9,8 @@ "x": 0, "y": 0 }, - "width": 426, - "height": 226, + "width": 306, + "height": 166, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -50,8 +50,8 @@ "x": 50, "y": 50 }, - "width": 113, - "height": 126, + "width": 53, + "height": 66, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -88,11 +88,11 @@ "id": "x.b", "type": "", "pos": { - "x": 263, + "x": 203, "y": 50 }, - "width": 113, - "height": 126, + "width": 53, + "height": 66, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -153,56 +153,56 @@ "labelPercentage": 0, "route": [ { - "x": 163, - "y": 73.37662337662337 + "x": 103, + "y": 68.38440111420613 }, { - "x": 189.66666666666669, - "y": 54.675324675324674 + "x": 129.66666666666669, + "y": 53.67688022284123 }, { - "x": 198, + "x": 138, "y": 50 }, { - "x": 200.5, + "x": 140.5, "y": 50 }, { - "x": 203, + "x": 143, "y": 50 }, { - "x": 206.33333333333331, - "y": 62.6 + "x": 146.33333333333331, + "y": 56.6 }, { - "x": 208.83333333333331, - "y": 81.5 + "x": 148.83333333333331, + "y": 66.5 }, { - "x": 211.33333333333334, - "y": 100.4 + "x": 151.33333333333334, + "y": 76.4 }, { - "x": 211.33333333333334, - "y": 125.6 + "x": 151.33333333333334, + "y": 89.6 }, { - "x": 208.83333333333331, - "y": 144.5 + "x": 148.83333333333331, + "y": 99.5 }, { - "x": 206.33333333333331, - "y": 163.4 + "x": 146.33333333333331, + "y": 109.4 }, { - "x": 189.66666666666669, - "y": 171.32467532467533 + "x": 129.66666666666669, + "y": 112.32311977715878 }, { - "x": 163, - "y": 152.62337662337663 + "x": 103, + "y": 97.61559888579387 } ], "isCurve": true, diff --git a/e2etests/testdata/regression/elk_loop_panic/dagre/sketch.exp.svg b/e2etests/testdata/regression/elk_loop_panic/dagre/sketch.exp.svg index c66e878a7..e86b4bb83 100644 --- a/e2etests/testdata/regression/elk_loop_panic/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/elk_loop_panic/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="630" height="430" viewBox="-102 -102 630 430">

Oldest message

-

Offset

-

Last message

-

Next message will be
+

Oldest message

+

Offset

+

Last message

+

Next message will be
inserted here

-
M0M1M2M3M4M5M6 - +
M0M1M2M3M4M5M6 +

Oldest message

-

Offset

-

Last message

-

Next message will be
+

Oldest message

+

Offset

+

Last message

+

Next message will be
inserted here

-
M0M1M2M3M4M5M6 - +
M0M1M2M3M4M5M6 +

hey

+

hey

  • they
      @@ -804,8 +804,8 @@ width="317" height="771" viewBox="-102 -102 317 771">

      hey

      +

      hey

      • they
          @@ -804,8 +804,8 @@ width="317" height="771" viewBox="-90 -90 317 771">x

          linux: because a PC is a terrible thing to waste

          -
          a You don't have to know how the computer works,just how to work the computer. - - +x

          linux: because a PC is a terrible thing to waste

          +
          a You don't have to know how the computer works,just how to work the computer. + + x

          linux: because a PC is a terrible thing to waste

          -
          a You don't have to know how the computer works,just how to work the computer. - - +x

          linux: because a PC is a terrible thing to waste

          +
          a You don't have to know how the computer works,just how to work the computer. + + aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 - - - - - - - - - +aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 + + + + + + + + + aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 - - - - - - - - - +aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 + + + + + + + + + xyThe top of the mountain

          Cats, no less liquid than their shadows, offer no angles to the wind.

          +xyThe top of the mountain

          Cats, no less liquid than their shadows, offer no angles to the wind.

          If we can't fix it, it ain't broke.

          Dieters live life in the fasting lane.

          -
          JoeDonaldi am top lefti am top righti am bottom lefti am bottom right - +
          JoeDonaldi am top lefti am top righti am bottom lefti am bottom right + xyThe top of the mountain

          Cats, no less liquid than their shadows, offer no angles to the wind.

          +xyThe top of the mountain

          Cats, no less liquid than their shadows, offer no angles to the wind.

          If we can't fix it, it ain't broke.

          Dieters live life in the fasting lane.

          -
          JoeDonaldi am top lefti am top righti am bottom lefti am bottom right - +
          JoeDonaldi am top lefti am top righti am bottom lefti am bottom right + poll the peopleresultsunfavorablefavorablewill of the people

          A winning strategy

          -
          - +poll the peopleresultsunfavorablefavorablewill of the people

          A winning strategy

          +
          + poll the peopleresultsunfavorablefavorablewill of the people

          A winning strategy

          -
          - +poll the peopleresultsunfavorablefavorablewill of the people

          A winning strategy

          +
          +

          Markdown: Syntax

          +

          Markdown: Syntax

          • Overview
              @@ -1053,8 +1053,8 @@ title for the link, surrounded in quotes. For example:

              Code

              Unlike a pre-formatted code block, a code span indicates code within a normal paragraph. For example:

              -
          ab - +
          ab +

          Markdown: Syntax

          +

          Markdown: Syntax

          • Overview
              @@ -1053,8 +1053,8 @@ title for the link, surrounded in quotes. For example:

              Code

              Unlike a pre-formatted code block, a code span indicates code within a normal paragraph. For example:

              -
          ab - +
          ab +

          Note: This document is itself written using Markdown; you +

          Note: This document is itself written using Markdown; you can see the source for it by adding '.text' to the URL.


          Overview

          -
          ab - +
          ab +

          Note: This document is itself written using Markdown; you +

          Note: This document is itself written using Markdown; you can see the source for it by adding '.text' to the URL.


          Overview

          -
          ab - +
          ab + mixed togethersugarsolution we get - - +mixed togethersugarsolution we get + + mixed togethersugarsolution we get - - +mixed togethersugarsolution we get + +
            +
            • Overview
              • Philosophy
              • @@ -808,8 +808,8 @@ width="583" height="756" viewBox="-102 -102 583 756">
                  +
                  • Overview
                    • Philosophy
                    • @@ -808,8 +808,8 @@ width="583" height="756" viewBox="-90 -90 583 756">
                        +
                        • Overview ok this is all measured
                          • Philosophy
                          • @@ -804,8 +804,8 @@ width="449" height="732" viewBox="-102 -102 449 732">
                              +
                              • Overview ok this is all measured
                                • Philosophy
                                • @@ -804,8 +804,8 @@ width="449" height="732" viewBox="-90 -90 449 732">
                                    +
                                    • Overview
                                      • Philosophy
                                      • @@ -829,8 +829,8 @@ width="551" height="1168" viewBox="-102 -102 551 1168">
                                          +
                                          • Overview
                                            • Philosophy
                                            • @@ -829,8 +829,8 @@ width="551" height="1168" viewBox="-90 -90 551 1168">

                                              List items may consist of multiple paragraphs. Each subsequent +

                                              List items may consist of multiple paragraphs. Each subsequent paragraph in a list item must be indented by either 4 spaces or one tab:

                                                @@ -827,8 +827,8 @@ sit amet, consectetuer adipiscing elit.

                                                Another item in the same list.

                                            -
                                          ab - +
                                        ab +

                                        List items may consist of multiple paragraphs. Each subsequent +

                                        List items may consist of multiple paragraphs. Each subsequent paragraph in a list item must be indented by either 4 spaces or one tab:

                                          @@ -827,8 +827,8 @@ sit amet, consectetuer adipiscing elit.

                                          Another item in the same list.

                                      -
                                    ab - +
                                  ab +

                                  Markdown: Syntax

                                  -
                                  ab - +

                                  Markdown: Syntax

                                  +
                                  ab +

                                  Markdown: Syntax

                                  -
                                  ab - +

                                  Markdown: Syntax

                                  +
                                  ab +

                                  Every frustum longs to be a cone

                                  +

                                  Every frustum longs to be a cone

                                  • A continuing flow of paper is sufficient to continue the flow of paper
                                  • Please remain calm, it's no use both of us being hysterical at the same time
                                  • Visits always give pleasure: if not on arrival, then on the departure

                                  Festivity Level 1: Your guests are chatting amiably with each other.

                                  -
                                  xy - +
                                  xy +

                                  Every frustum longs to be a cone

                                  +

                                  Every frustum longs to be a cone

                                  • A continuing flow of paper is sufficient to continue the flow of paper
                                  • Please remain calm, it's no use both of us being hysterical at the same time
                                  • Visits always give pleasure: if not on arrival, then on the departure

                                  Festivity Level 1: Your guests are chatting amiably with each other.

                                  -
                                  xy - +
                                  xy +
                                  {
                                  +
                                  {
                                   	fenced: "block",
                                   	of: "json",
                                   }
                                   
                                  -
                                  ab - +
                                  ab +
                                  {
                                  +
                                  {
                                   	fenced: "block",
                                   	of: "json",
                                   }
                                   
                                  -
                                  ab - +
                                  ab +

                                  a line of text and an

                                  +

                                  a line of text and an

                                  {
                                   	indented: "block",
                                   	of: "json",
                                   }
                                   
                                  -
                                  ab - +
                                  ab +

                                  a line of text and an

                                  +

                                  a line of text and an

                                  {
                                   	indented: "block",
                                   	of: "json",
                                   }
                                   
                                  -
                                  ab - +
                                  ab +

                                  code

                                  -
                                  ab - +

                                  code

                                  +
                                  ab +

                                  code

                                  -
                                  ab - +

                                  code

                                  +
                                  ab +

                                  A paragraph is simply one or more consecutive lines of text, separated +

                                  A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line -- a line containing nothing but spaces or tabs is considered blank.) Normal paragraphs should not be indented with spaces or tabs.

                                  -
                                  ab - +
                                  ab +

                                  A paragraph is simply one or more consecutive lines of text, separated +

                                  A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line -- a line containing nothing but spaces or tabs is considered blank.) Normal paragraphs should not be indented with spaces or tabs.

                                  -
                                  ab - +
                                  ab +

                                  Here is an example of AppleScript:

                                  +

                                  Here is an example of AppleScript:

                                  tell application "Foo"
                                       beep
                                   end tell
                                   

                                  A code block continues until it reaches a line that is not indented (or the end of the article).

                                  -
                                  ab - +
                                  ab +

                                  Here is an example of AppleScript:

                                  +

                                  Here is an example of AppleScript:

                                  tell application "Foo"
                                       beep
                                   end tell
                                   

                                  A code block continues until it reaches a line that is not indented (or the end of the article).

                                  -
                                  ab - +
                                  ab + 1Like starbucks or something -2I'm not sure what this is +}]]>1Like starbucks or something +2I'm not sure what this is \ No newline at end of file diff --git a/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json index 9bb8b113d..bdd6a327a 100644 --- a/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json +++ b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json @@ -9,8 +9,8 @@ "x": 12, "y": 12 }, - "width": 148, - "height": 148, + "width": 128, + "height": 128, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -57,8 +57,8 @@ "id": "ico", "type": "", "pos": { - "x": 180, - "y": 36 + "x": 160, + "y": 26 }, "width": 100, "height": 100, diff --git a/e2etests/testdata/regression/elk_img_empty_label_panic/elk/sketch.exp.svg b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/sketch.exp.svg index 17fab0d6c..b7128f39d 100644 --- a/e2etests/testdata/regression/elk_img_empty_label_panic/elk/sketch.exp.svg +++ b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/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="472" height="352" viewBox="-90 -90 472 352"> \ No newline at end of file diff --git a/e2etests/testdata/regression/query_param_escape/dagre/board.exp.json b/e2etests/testdata/regression/query_param_escape/dagre/board.exp.json index b334e2853..cd72d3fc5 100644 --- a/e2etests/testdata/regression/query_param_escape/dagre/board.exp.json +++ b/e2etests/testdata/regression/query_param_escape/dagre/board.exp.json @@ -9,8 +9,8 @@ "x": 0, "y": 0 }, - "width": 150, - "height": 112, + "width": 156, + "height": 118, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, diff --git a/e2etests/testdata/regression/query_param_escape/dagre/sketch.exp.svg b/e2etests/testdata/regression/query_param_escape/dagre/sketch.exp.svg index c25defe44..50a961538 100644 --- a/e2etests/testdata/regression/query_param_escape/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/query_param_escape/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="354" height="316" viewBox="-102 -102 354 316">------------------------------------------------------------------------------------------------------------------------------- + + + \ No newline at end of file diff --git a/e2etests/testdata/stable/people/elk/board.exp.json b/e2etests/testdata/stable/people/elk/board.exp.json new file mode 100644 index 000000000..9bd63d14c --- /dev/null +++ b/e2etests/testdata/stable/people/elk/board.exp.json @@ -0,0 +1,294 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "a", + "type": "person", + "pos": { + "x": 12, + "y": 12 + }, + "width": 110, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "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": 10, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "b", + "type": "person", + "pos": { + "x": 142, + "y": 12 + }, + "width": 116, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "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": 16, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "c", + "type": "person", + "pos": { + "x": 278, + "y": 12 + }, + "width": 126, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "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": 26, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "d", + "type": "person", + "pos": { + "x": 424, + "y": 12 + }, + "width": 148, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "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": 48, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "e", + "type": "person", + "pos": { + "x": 592, + "y": 12 + }, + "width": 190, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "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": 90, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "f", + "type": "person", + "pos": { + "x": 802, + "y": 12 + }, + "width": 275, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "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": 175, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "g", + "type": "person", + "pos": { + "x": 1097, + "y": 12 + }, + "width": 445, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "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": 345, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [] +} diff --git a/e2etests/testdata/stable/people/elk/sketch.exp.svg b/e2etests/testdata/stable/people/elk/sketch.exp.svg new file mode 100644 index 000000000..006d3f179 --- /dev/null +++ b/e2etests/testdata/stable/people/elk/sketch.exp.svg @@ -0,0 +1,52 @@ + +------------------------------------------------------------------------------------------------------------------------------- + + + \ No newline at end of file From 92629a6c3b781e4787d58d51f5cc8a3838e98598 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Mon, 30 Jan 2023 18:33:22 -0800 Subject: [PATCH 25/35] update test --- .../stable/people/dagre/board.exp.json | 52 +++++++++---------- .../stable/people/dagre/sketch.exp.svg | 6 +-- .../testdata/stable/people/elk/board.exp.json | 52 +++++++++---------- .../testdata/stable/people/elk/sketch.exp.svg | 6 +-- 4 files changed, 58 insertions(+), 58 deletions(-) diff --git a/e2etests/testdata/stable/people/dagre/board.exp.json b/e2etests/testdata/stable/people/dagre/board.exp.json index 277ecb748..dd9f25d4c 100644 --- a/e2etests/testdata/stable/people/dagre/board.exp.json +++ b/e2etests/testdata/stable/people/dagre/board.exp.json @@ -7,10 +7,10 @@ "type": "person", "pos": { "x": 0, - "y": 0 + "y": 257 }, - "width": 110, - "height": 126, + "width": 49, + "height": 66, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -47,11 +47,11 @@ "id": "b", "type": "person", "pos": { - "x": 170, - "y": 0 + "x": 109, + "y": 257 }, - "width": 116, - "height": 126, + "width": 64, + "height": 66, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -88,11 +88,11 @@ "id": "c", "type": "person", "pos": { - "x": 346, - "y": 0 + "x": 233, + "y": 257 }, - "width": 126, - "height": 126, + "width": 89, + "height": 66, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -129,11 +129,11 @@ "id": "d", "type": "person", "pos": { - "x": 532, - "y": 0 + "x": 382, + "y": 243 }, - "width": 148, - "height": 126, + "width": 142, + "height": 95, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -170,11 +170,11 @@ "id": "e", "type": "person", "pos": { - "x": 740, - "y": 0 + "x": 584, + "y": 208 }, - "width": 190, - "height": 126, + "width": 245, + "height": 164, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -211,11 +211,11 @@ "id": "f", "type": "person", "pos": { - "x": 990, - "y": 0 + "x": 889, + "y": 139 }, - "width": 275, - "height": 126, + "width": 453, + "height": 302, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -252,11 +252,11 @@ "id": "g", "type": "person", "pos": { - "x": 1325, + "x": 1402, "y": 0 }, - "width": 445, - "height": 126, + "width": 870, + "height": 580, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, diff --git a/e2etests/testdata/stable/people/dagre/sketch.exp.svg b/e2etests/testdata/stable/people/dagre/sketch.exp.svg index b32c962d4..ae5c71990 100644 --- a/e2etests/testdata/stable/people/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/people/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="1974" height="330" viewBox="-102 -102 1974 330">Office chatterAliceBobbyawkward small talk uhm, hioh, hellowhat did you have for lunch?that's personalok - - - - - - \ No newline at end of file diff --git a/e2etests/testdata/regression/sequence_diagram_ambiguous_edge_group/elk/board.exp.json b/e2etests/testdata/regression/sequence_diagram_ambiguous_edge_group/elk/board.exp.json deleted file mode 100644 index 151e6b38a..000000000 --- a/e2etests/testdata/regression/sequence_diagram_ambiguous_edge_group/elk/board.exp.json +++ /dev/null @@ -1,606 +0,0 @@ -{ - "name": "", - "fontFamily": "SourceSansPro", - "shapes": [ - { - "id": "Office chatter", - "type": "sequence_diagram", - "pos": { - "x": 12, - "y": 12 - }, - "width": 711, - "height": 1046, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 0, - "borderRadius": 0, - "fill": "#FFFFFF", - "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": "Office chatter", - "fontSize": 28, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 164, - "labelHeight": 41, - "labelPosition": "INSIDE_TOP_CENTER", - "zIndex": 0, - "level": 1 - }, - { - "id": "Office chatter.alice", - "type": "rectangle", - "pos": { - "x": 36, - "y": 122 - }, - "width": 150, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "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": "Alice", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 38, - "labelHeight": 26, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - }, - { - "id": "Office chatter.bob", - "type": "rectangle", - "pos": { - "x": 286, - "y": 122 - }, - "width": 150, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "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": "Bobby", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 48, - "labelHeight": 26, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - }, - { - "id": "Office chatter.awkward small talk", - "type": "rectangle", - "pos": { - "x": 524, - "y": 122 - }, - "width": 175, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#EDF0FD", - "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": "awkward small talk", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 135, - "labelHeight": 26, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 0, - "level": 2 - }, - { - "id": "Office chatter.awkward small talk.awkward small talk", - "type": "rectangle", - "pos": { - "x": 605, - "y": 302 - }, - "width": 12, - "height": 98, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#E3E9FD", - "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": false, - "underline": false, - "labelWidth": 135, - "labelHeight": 26, - "zIndex": 2, - "level": 3 - }, - { - "id": "Office chatter.awkward small talk.awkward small talk.ok", - "type": "page", - "pos": { - "x": 580, - "y": 318 - }, - "width": 62, - "height": 66, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "borderRadius": 0, - "fill": "#FFFFFF", - "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": "ok", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 22, - "labelHeight": 26, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "zIndex": 5, - "level": 4 - }, - { - "id": "Office chatter.awkward small talk.icebreaker attempt", - "type": "rectangle", - "pos": { - "x": 605, - "y": 9223372036854775807 - }, - "width": 12, - "height": 80, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 0, - "borderRadius": 0, - "fill": "#DEE1EB", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": true, - "fields": null, - "methods": null, - "columns": null, - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 134, - "labelHeight": 26, - "zIndex": 2, - "level": 3 - }, - { - "id": "Office chatter.awkward small talk.unfortunate outcome", - "type": "rectangle", - "pos": { - "x": 605, - "y": 9223372036854775807 - }, - "width": 12, - "height": 80, - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 0, - "borderRadius": 0, - "fill": "#DEE1EB", - "stroke": "#0D32B2", - "shadow": false, - "3d": false, - "multiple": false, - "double-border": false, - "tooltip": "", - "link": "", - "icon": null, - "iconPosition": "", - "blend": true, - "fields": null, - "methods": null, - "columns": null, - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#0A0F25", - "italic": false, - "bold": false, - "underline": false, - "labelWidth": 148, - "labelHeight": 26, - "zIndex": 2, - "level": 3 - } - ], - "connections": [ - { - "id": "Office chatter.(alice -> bob)[1]", - "src": "Office chatter.alice", - "srcArrow": "none", - "srcLabel": "", - "dst": "Office chatter.bob", - "dstArrow": "triangle", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "uhm, hi", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 50, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "labelPercentage": 0, - "route": [ - { - "x": 111, - "y": 514 - }, - { - "x": 361, - "y": 514 - } - ], - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 4 - }, - { - "id": "Office chatter.(bob -> alice)[1]", - "src": "Office chatter.bob", - "srcArrow": "none", - "srcLabel": "", - "dst": "Office chatter.alice", - "dstArrow": "triangle", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "oh, hello", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 56, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "labelPercentage": 0, - "route": [ - { - "x": 361, - "y": 644 - }, - { - "x": 111, - "y": 644 - } - ], - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 4 - }, - { - "id": "Office chatter.(alice -> bob)[0]", - "src": "Office chatter.alice", - "srcArrow": "none", - "srcLabel": "", - "dst": "Office chatter.bob", - "dstArrow": "triangle", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "what did you have for lunch?", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 187, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "labelPercentage": 0, - "route": [ - { - "x": 111, - "y": 774 - }, - { - "x": 361, - "y": 774 - } - ], - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 4 - }, - { - "id": "Office chatter.(bob -> alice)[0]", - "src": "Office chatter.bob", - "srcArrow": "none", - "srcLabel": "", - "dst": "Office chatter.alice", - "dstArrow": "triangle", - "dstLabel": "", - "opacity": 1, - "strokeDash": 0, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "that's personal", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 99, - "labelHeight": 21, - "labelPosition": "INSIDE_MIDDLE_CENTER", - "labelPercentage": 0, - "route": [ - { - "x": 361, - "y": 904 - }, - { - "x": 111, - "y": 904 - } - ], - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 4 - }, - { - "id": "(Office chatter.alice -- )[0]", - "src": "Office chatter.alice", - "srcArrow": "none", - "srcLabel": "", - "dst": "alice-lifeline-end-3851299086", - "dstArrow": "none", - "dstLabel": "", - "opacity": 1, - "strokeDash": 6, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 111, - "y": 188 - }, - { - "x": 111, - "y": 1034 - } - ], - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 1 - }, - { - "id": "(Office chatter.bob -- )[0]", - "src": "Office chatter.bob", - "srcArrow": "none", - "srcLabel": "", - "dst": "bob-lifeline-end-3036726343", - "dstArrow": "none", - "dstLabel": "", - "opacity": 1, - "strokeDash": 6, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 361, - "y": 188 - }, - { - "x": 361, - "y": 1034 - } - ], - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 1 - }, - { - "id": "(Office chatter.awkward small talk -- )[0]", - "src": "Office chatter.awkward small talk", - "srcArrow": "none", - "srcLabel": "", - "dst": "awkward small talk-lifeline-end-861194358", - "dstArrow": "none", - "dstLabel": "", - "opacity": 1, - "strokeDash": 6, - "strokeWidth": 2, - "stroke": "#0D32B2", - "label": "", - "fontSize": 16, - "fontFamily": "DEFAULT", - "language": "", - "color": "#676C7E", - "italic": true, - "bold": false, - "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", - "labelPercentage": 0, - "route": [ - { - "x": 611.5, - "y": 188 - }, - { - "x": 611.5, - "y": 1034 - } - ], - "animated": false, - "tooltip": "", - "icon": null, - "zIndex": 1 - } - ] -} diff --git a/e2etests/testdata/regression/sequence_diagram_ambiguous_edge_group/elk/sketch.exp.svg b/e2etests/testdata/regression/sequence_diagram_ambiguous_edge_group/elk/sketch.exp.svg deleted file mode 100644 index 19f1468a1..000000000 --- a/e2etests/testdata/regression/sequence_diagram_ambiguous_edge_group/elk/sketch.exp.svg +++ /dev/null @@ -1,62 +0,0 @@ - -Office chatterAliceBobbyawkward small talk uhm, hioh, hellowhat did you have for lunch?that's personalok - - - - - - \ No newline at end of file diff --git a/e2etests/todo_test.go b/e2etests/todo_test.go index 3fbf45e67..a1a413206 100644 --- a/e2etests/todo_test.go +++ b/e2etests/todo_test.go @@ -219,6 +219,29 @@ Office chatter: { } } } +`, + }, + { + // issue https://github.com/terrastruct/d2/issues/748 + skip: true, + name: "sequence_diagram_ambiguous_edge_group", + script: ` +Office chatter: { + shape: sequence_diagram + alice: Alice + bob: Bobby + awkward small talk: { + awkward small talk.ok + alice -> bob: uhm, hi + bob -> alice: oh, hello + icebreaker attempt: { + alice -> bob: what did you have for lunch? + } + unfortunate outcome: { + bob -> alice: that's personal + } + } +} `, }, } From 1567de64e1dfd50bd7794ea506f0a329e59c3324 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Fri, 3 Feb 2023 13:13:10 -0800 Subject: [PATCH 29/35] don't set obj.LabelDimensions with padding --- d2exporter/export.go | 1 + d2graph/d2graph.go | 4 ++-- d2renderers/d2svg/d2svg.go | 3 +-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/d2exporter/export.go b/d2exporter/export.go index 06628af70..5a57f0881 100644 --- a/d2exporter/export.go +++ b/d2exporter/export.go @@ -143,6 +143,7 @@ func toShape(obj *d2graph.Object, theme *d2themes.Theme) d2target.Shape { } shape.Label = text.Text shape.LabelWidth = text.Dimensions.Width + shape.LabelHeight = text.Dimensions.Height if obj.LabelPosition != nil { shape.LabelPosition = *obj.LabelPosition diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 1c67aebbb..c92f80a54 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -1208,11 +1208,11 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler } } + obj.LabelDimensions = *labelDims if dslShape != d2target.ShapeText && obj.Attributes.Label.Value != "" { labelDims.Width += INNER_LABEL_PADDING labelDims.Height += INNER_LABEL_PADDING } - obj.LabelDimensions = *labelDims defaultDims, err := obj.GetDefaultSize(mtexts, ruler, fontFamily, *labelDims) if err != nil { @@ -1226,7 +1226,7 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler paddingX, paddingY := s.GetDefaultPadding() // give shapes with icons extra padding to fit their label if obj.Attributes.Icon != nil { - labelHeight := float64(obj.LabelDimensions.Height) + labelHeight := float64(labelDims.Height) // Evenly pad enough to fit label above icon paddingX += labelHeight paddingY += labelHeight diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index 5a2eeb348..546ec2740 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -897,8 +897,7 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske } labelTL := labelPosition.GetPointOnBox(box, label.PADDING, float64(targetShape.LabelWidth), - // TODO consider further - float64(targetShape.LabelHeight-d2graph.INNER_LABEL_PADDING), + float64(targetShape.LabelHeight), ) fontClass := "text" From b387e2c6e0a38e7f570158290c970c8c0046361f Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Fri, 3 Feb 2023 13:59:12 -0800 Subject: [PATCH 30/35] update tests --- .../testdata/all_shapes/sketch.exp.svg | 2 +- .../d2sketch/testdata/animated/sketch.exp.svg | 2 +- .../testdata/arrowheads/sketch.exp.svg | 2 +- .../d2sketch/testdata/basic/sketch.exp.svg | 2 +- .../testdata/child_to_child/sketch.exp.svg | 2 +- .../d2sketch/testdata/class/sketch.exp.svg | 4 +- .../testdata/connection_label/sketch.exp.svg | 2 +- .../d2sketch/testdata/opacity/sketch.exp.svg | 4 +- .../testdata/sql_tables/sketch.exp.svg | 10 +- .../d2sketch/testdata/twitter/sketch.exp.svg | 10 +- .../diagram_wider_than_tooltip/sketch.exp.svg | 8 +- .../appendix/testdata/links/sketch.exp.svg | 2 +- .../tooltip_wider_than_diagram/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 12 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 12 +- .../elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 24 +- .../dagre/sketch.exp.svg | 2 +- .../dagre_broken_arrowhead/elk/board.exp.json | 24 +- .../dagre_broken_arrowhead/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 24 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 24 +- .../elk/sketch.exp.svg | 2 +- .../dagre_special_ids/dagre/board.exp.json | 28 +- .../dagre_special_ids/dagre/sketch.exp.svg | 2 +- .../dagre_special_ids/elk/board.exp.json | 28 +- .../dagre_special_ids/elk/sketch.exp.svg | 2 +- .../elk_alignment/dagre/board.exp.json | 56 ++-- .../elk_alignment/dagre/sketch.exp.svg | 2 +- .../elk_alignment/elk/board.exp.json | 56 ++-- .../elk_alignment/elk/sketch.exp.svg | 2 +- .../elk_loop_panic/dagre/board.exp.json | 12 +- .../elk_loop_panic/dagre/sketch.exp.svg | 2 +- .../elk_loop_panic/elk/board.exp.json | 12 +- .../elk_loop_panic/elk/sketch.exp.svg | 2 +- .../regression/elk_order/dagre/board.exp.json | 28 +- .../regression/elk_order/dagre/sketch.exp.svg | 2 +- .../regression/elk_order/elk/board.exp.json | 28 +- .../regression/elk_order/elk/sketch.exp.svg | 2 +- .../empty_sequence/dagre/board.exp.json | 8 +- .../empty_sequence/dagre/sketch.exp.svg | 2 +- .../empty_sequence/elk/board.exp.json | 8 +- .../empty_sequence/elk/sketch.exp.svg | 2 +- .../md_h1_li_li/dagre/board.exp.json | 8 +- .../md_h1_li_li/dagre/sketch.exp.svg | 2 +- .../regression/md_h1_li_li/elk/board.exp.json | 8 +- .../regression/md_h1_li_li/elk/sketch.exp.svg | 2 +- .../regression/no-lexer/dagre/board.exp.json | 4 +- .../regression/no-lexer/dagre/sketch.exp.svg | 2 +- .../regression/no-lexer/elk/board.exp.json | 4 +- .../regression/no-lexer/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 12 +- .../dagre/sketch.exp.svg | 4 +- .../elk/board.exp.json | 12 +- .../elk/sketch.exp.svg | 4 +- .../opacity-on-label/dagre/board.exp.json | 8 +- .../opacity-on-label/dagre/sketch.exp.svg | 2 +- .../opacity-on-label/elk/board.exp.json | 8 +- .../opacity-on-label/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 40 +-- .../dagre/sketch.exp.svg | 2 +- .../overlapping-edge-label/elk/board.exp.json | 40 +-- .../overlapping-edge-label/elk/sketch.exp.svg | 2 +- .../query_param_escape/dagre/board.exp.json | 4 +- .../query_param_escape/dagre/sketch.exp.svg | 2 +- .../query_param_escape/elk/board.exp.json | 4 +- .../query_param_escape/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 24 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 24 +- .../elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 8 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 8 +- .../elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 60 ++-- .../dagre/sketch.exp.svg | 24 +- .../elk/board.exp.json | 60 ++-- .../elk/sketch.exp.svg | 24 +- .../dagre/board.exp.json | 8 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 8 +- .../elk/sketch.exp.svg | 2 +- .../sql_table_overflow/dagre/board.exp.json | 8 +- .../sql_table_overflow/dagre/sketch.exp.svg | 6 +- .../sql_table_overflow/elk/board.exp.json | 8 +- .../sql_table_overflow/elk/sketch.exp.svg | 6 +- .../dagre/board.exp.json | 4 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 4 +- .../elk/sketch.exp.svg | 2 +- .../sanity/1_to_2/dagre/board.exp.json | 12 +- .../sanity/1_to_2/dagre/sketch.exp.svg | 2 +- .../testdata/sanity/1_to_2/elk/board.exp.json | 12 +- .../testdata/sanity/1_to_2/elk/sketch.exp.svg | 2 +- .../sanity/basic/dagre/board.exp.json | 8 +- .../sanity/basic/dagre/sketch.exp.svg | 2 +- .../testdata/sanity/basic/elk/board.exp.json | 8 +- .../testdata/sanity/basic/elk/sketch.exp.svg | 2 +- .../child_to_child/dagre/board.exp.json | 16 +- .../child_to_child/dagre/sketch.exp.svg | 2 +- .../sanity/child_to_child/elk/board.exp.json | 16 +- .../sanity/child_to_child/elk/sketch.exp.svg | 2 +- .../connection_label/dagre/board.exp.json | 8 +- .../connection_label/dagre/sketch.exp.svg | 2 +- .../connection_label/elk/board.exp.json | 8 +- .../connection_label/elk/sketch.exp.svg | 2 +- .../stable/all_shapes/dagre/board.exp.json | 68 ++--- .../stable/all_shapes/dagre/sketch.exp.svg | 2 +- .../stable/all_shapes/elk/board.exp.json | 68 ++--- .../stable/all_shapes/elk/sketch.exp.svg | 2 +- .../all_shapes_multiple/dagre/board.exp.json | 68 ++--- .../all_shapes_multiple/dagre/sketch.exp.svg | 2 +- .../all_shapes_multiple/elk/board.exp.json | 68 ++--- .../all_shapes_multiple/elk/sketch.exp.svg | 2 +- .../all_shapes_shadow/dagre/board.exp.json | 68 ++--- .../all_shapes_shadow/dagre/sketch.exp.svg | 2 +- .../all_shapes_shadow/elk/board.exp.json | 68 ++--- .../all_shapes_shadow/elk/sketch.exp.svg | 2 +- .../stable/animated/dagre/board.exp.json | 52 ++-- .../stable/animated/dagre/sketch.exp.svg | 2 +- .../stable/animated/elk/board.exp.json | 52 ++-- .../stable/animated/elk/sketch.exp.svg | 2 +- .../arrowhead_adjustment/dagre/board.exp.json | 12 +- .../arrowhead_adjustment/dagre/sketch.exp.svg | 2 +- .../arrowhead_adjustment/elk/board.exp.json | 12 +- .../arrowhead_adjustment/elk/sketch.exp.svg | 2 +- .../arrowhead_labels/dagre/board.exp.json | 8 +- .../arrowhead_labels/dagre/sketch.exp.svg | 2 +- .../arrowhead_labels/elk/board.exp.json | 8 +- .../arrowhead_labels/elk/sketch.exp.svg | 2 +- .../stable/binary_tree/dagre/board.exp.json | 60 ++-- .../stable/binary_tree/dagre/sketch.exp.svg | 2 +- .../stable/binary_tree/elk/board.exp.json | 60 ++-- .../stable/binary_tree/elk/sketch.exp.svg | 2 +- .../stable/border-radius/dagre/board.exp.json | 8 +- .../stable/border-radius/dagre/sketch.exp.svg | 2 +- .../stable/border-radius/elk/board.exp.json | 8 +- .../stable/border-radius/elk/sketch.exp.svg | 2 +- .../stable/chaos1/dagre/board.exp.json | 20 +- .../stable/chaos1/dagre/sketch.exp.svg | 2 +- .../testdata/stable/chaos1/elk/board.exp.json | 20 +- .../testdata/stable/chaos1/elk/sketch.exp.svg | 2 +- .../stable/chaos2/dagre/board.exp.json | 48 ++-- .../stable/chaos2/dagre/sketch.exp.svg | 2 +- .../testdata/stable/chaos2/elk/board.exp.json | 48 ++-- .../testdata/stable/chaos2/elk/sketch.exp.svg | 2 +- .../child_parent_edges/dagre/board.exp.json | 16 +- .../child_parent_edges/dagre/sketch.exp.svg | 2 +- .../child_parent_edges/elk/board.exp.json | 16 +- .../child_parent_edges/elk/sketch.exp.svg | 2 +- .../circle_arrowhead/dagre/board.exp.json | 16 +- .../circle_arrowhead/dagre/sketch.exp.svg | 2 +- .../circle_arrowhead/elk/board.exp.json | 16 +- .../circle_arrowhead/elk/sketch.exp.svg | 2 +- .../circular_dependency/dagre/board.exp.json | 12 +- .../circular_dependency/dagre/sketch.exp.svg | 2 +- .../circular_dependency/elk/board.exp.json | 12 +- .../circular_dependency/elk/sketch.exp.svg | 2 +- .../stable/class/dagre/board.exp.json | 4 +- .../stable/class/dagre/sketch.exp.svg | 4 +- .../testdata/stable/class/elk/board.exp.json | 4 +- .../testdata/stable/class/elk/sketch.exp.svg | 4 +- .../stable/code_snippet/dagre/board.exp.json | 12 +- .../stable/code_snippet/dagre/sketch.exp.svg | 2 +- .../stable/code_snippet/elk/board.exp.json | 12 +- .../stable/code_snippet/elk/sketch.exp.svg | 2 +- .../complex-layers/dagre/board.exp.json | 100 +++---- .../complex-layers/dagre/sketch.exp.svg | 2 +- .../stable/complex-layers/elk/board.exp.json | 100 +++---- .../stable/complex-layers/elk/sketch.exp.svg | 2 +- .../connected_container/dagre/board.exp.json | 28 +- .../connected_container/dagre/sketch.exp.svg | 2 +- .../connected_container/elk/board.exp.json | 28 +- .../connected_container/elk/sketch.exp.svg | 2 +- .../constant_near_stress/dagre/board.exp.json | 16 +- .../constant_near_stress/dagre/sketch.exp.svg | 4 +- .../constant_near_stress/elk/board.exp.json | 16 +- .../constant_near_stress/elk/sketch.exp.svg | 4 +- .../constant_near_title/dagre/board.exp.json | 20 +- .../constant_near_title/dagre/sketch.exp.svg | 2 +- .../constant_near_title/elk/board.exp.json | 20 +- .../constant_near_title/elk/sketch.exp.svg | 2 +- .../container_edges/dagre/board.exp.json | 32 +-- .../container_edges/dagre/sketch.exp.svg | 2 +- .../stable/container_edges/elk/board.exp.json | 32 +-- .../stable/container_edges/elk/sketch.exp.svg | 2 +- .../crow_foot_arrowhead/dagre/board.exp.json | 32 +-- .../crow_foot_arrowhead/dagre/sketch.exp.svg | 2 +- .../crow_foot_arrowhead/elk/board.exp.json | 32 +-- .../crow_foot_arrowhead/elk/sketch.exp.svg | 2 +- .../stable/dense/dagre/board.exp.json | 68 ++--- .../stable/dense/dagre/sketch.exp.svg | 2 +- .../testdata/stable/dense/elk/board.exp.json | 68 ++--- .../testdata/stable/dense/elk/sketch.exp.svg | 2 +- .../different_subgraphs/dagre/board.exp.json | 88 +++--- .../different_subgraphs/dagre/sketch.exp.svg | 2 +- .../different_subgraphs/elk/board.exp.json | 88 +++--- .../different_subgraphs/elk/sketch.exp.svg | 2 +- .../stable/direction/dagre/board.exp.json | 60 ++-- .../stable/direction/dagre/sketch.exp.svg | 2 +- .../stable/direction/elk/board.exp.json | 60 ++-- .../stable/direction/elk/sketch.exp.svg | 2 +- .../stable/font_colors/dagre/board.exp.json | 8 +- .../stable/font_colors/dagre/sketch.exp.svg | 2 +- .../stable/font_colors/elk/board.exp.json | 8 +- .../stable/font_colors/elk/sketch.exp.svg | 2 +- .../stable/font_sizes/dagre/board.exp.json | 48 ++-- .../stable/font_sizes/dagre/sketch.exp.svg | 2 +- .../stable/font_sizes/elk/board.exp.json | 48 ++-- .../stable/font_sizes/elk/sketch.exp.svg | 2 +- .../giant_markdown_test/dagre/board.exp.json | 8 +- .../giant_markdown_test/dagre/sketch.exp.svg | 2 +- .../giant_markdown_test/elk/board.exp.json | 8 +- .../giant_markdown_test/elk/sketch.exp.svg | 2 +- .../testdata/stable/hr/dagre/board.exp.json | 8 +- .../testdata/stable/hr/dagre/sketch.exp.svg | 2 +- .../testdata/stable/hr/elk/board.exp.json | 8 +- .../testdata/stable/hr/elk/sketch.exp.svg | 2 +- .../stable/icon-label/dagre/board.exp.json | 4 +- .../stable/icon-label/dagre/sketch.exp.svg | 2 +- .../stable/icon-label/elk/board.exp.json | 4 +- .../stable/icon-label/elk/sketch.exp.svg | 2 +- .../stable/images/dagre/board.exp.json | 8 +- .../stable/images/dagre/sketch.exp.svg | 6 +- .../testdata/stable/images/elk/board.exp.json | 8 +- .../testdata/stable/images/elk/sketch.exp.svg | 6 +- .../stable/investigate/dagre/board.exp.json | 124 ++++----- .../stable/investigate/dagre/sketch.exp.svg | 2 +- .../stable/investigate/elk/board.exp.json | 124 ++++----- .../stable/investigate/elk/sketch.exp.svg | 2 +- .../stable/large_arch/dagre/board.exp.json | 132 ++++----- .../stable/large_arch/dagre/sketch.exp.svg | 2 +- .../stable/large_arch/elk/board.exp.json | 132 ++++----- .../stable/large_arch/elk/sketch.exp.svg | 2 +- .../stable/latex/dagre/board.exp.json | 12 +- .../stable/latex/dagre/sketch.exp.svg | 2 +- .../testdata/stable/latex/elk/board.exp.json | 12 +- .../testdata/stable/latex/elk/sketch.exp.svg | 2 +- .../testdata/stable/li1/dagre/board.exp.json | 8 +- .../testdata/stable/li1/dagre/sketch.exp.svg | 2 +- .../testdata/stable/li1/elk/board.exp.json | 8 +- .../testdata/stable/li1/elk/sketch.exp.svg | 2 +- .../testdata/stable/li2/dagre/board.exp.json | 8 +- .../testdata/stable/li2/dagre/sketch.exp.svg | 2 +- .../testdata/stable/li2/elk/board.exp.json | 8 +- .../testdata/stable/li2/elk/sketch.exp.svg | 2 +- .../testdata/stable/li3/dagre/board.exp.json | 8 +- .../testdata/stable/li3/dagre/sketch.exp.svg | 2 +- .../testdata/stable/li3/elk/board.exp.json | 8 +- .../testdata/stable/li3/elk/sketch.exp.svg | 2 +- .../testdata/stable/li4/dagre/board.exp.json | 8 +- .../testdata/stable/li4/dagre/sketch.exp.svg | 2 +- .../testdata/stable/li4/elk/board.exp.json | 8 +- .../testdata/stable/li4/elk/sketch.exp.svg | 2 +- .../stable/links/dagre/board.exp.json | 8 +- .../stable/links/dagre/sketch.exp.svg | 2 +- .../testdata/stable/links/elk/board.exp.json | 8 +- .../testdata/stable/links/elk/sketch.exp.svg | 2 +- .../stable/lone_h1/dagre/board.exp.json | 8 +- .../stable/lone_h1/dagre/sketch.exp.svg | 2 +- .../stable/lone_h1/elk/board.exp.json | 8 +- .../stable/lone_h1/elk/sketch.exp.svg | 2 +- .../stable/markdown/dagre/board.exp.json | 8 +- .../stable/markdown/dagre/sketch.exp.svg | 2 +- .../stable/markdown/elk/board.exp.json | 8 +- .../stable/markdown/elk/sketch.exp.svg | 2 +- .../markdown_stroke_fill/dagre/board.exp.json | 4 +- .../markdown_stroke_fill/dagre/sketch.exp.svg | 2 +- .../markdown_stroke_fill/elk/board.exp.json | 4 +- .../markdown_stroke_fill/elk/sketch.exp.svg | 2 +- .../md_2space_newline/dagre/board.exp.json | 4 +- .../md_2space_newline/dagre/sketch.exp.svg | 2 +- .../md_2space_newline/elk/board.exp.json | 4 +- .../md_2space_newline/elk/sketch.exp.svg | 2 +- .../md_backslash_newline/dagre/board.exp.json | 4 +- .../md_backslash_newline/dagre/sketch.exp.svg | 2 +- .../md_backslash_newline/elk/board.exp.json | 4 +- .../md_backslash_newline/elk/sketch.exp.svg | 2 +- .../md_code_block_fenced/dagre/board.exp.json | 8 +- .../md_code_block_fenced/dagre/sketch.exp.svg | 2 +- .../md_code_block_fenced/elk/board.exp.json | 8 +- .../md_code_block_fenced/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 8 +- .../dagre/sketch.exp.svg | 2 +- .../md_code_block_indented/elk/board.exp.json | 8 +- .../md_code_block_indented/elk/sketch.exp.svg | 2 +- .../md_code_inline/dagre/board.exp.json | 8 +- .../md_code_inline/dagre/sketch.exp.svg | 2 +- .../stable/md_code_inline/elk/board.exp.json | 8 +- .../stable/md_code_inline/elk/sketch.exp.svg | 2 +- .../multiline_text/dagre/board.exp.json | 4 +- .../multiline_text/dagre/sketch.exp.svg | 2 +- .../stable/multiline_text/elk/board.exp.json | 4 +- .../stable/multiline_text/elk/sketch.exp.svg | 2 +- .../multiple_trees/dagre/board.exp.json | 92 +++---- .../multiple_trees/dagre/sketch.exp.svg | 2 +- .../stable/multiple_trees/elk/board.exp.json | 92 +++---- .../stable/multiple_trees/elk/sketch.exp.svg | 2 +- .../stable/n22_e32/dagre/board.exp.json | 84 +++--- .../stable/n22_e32/dagre/sketch.exp.svg | 2 +- .../stable/n22_e32/elk/board.exp.json | 84 +++--- .../stable/n22_e32/elk/sketch.exp.svg | 2 +- .../stable/near-alone/dagre/board.exp.json | 12 +- .../stable/near-alone/dagre/sketch.exp.svg | 2 +- .../stable/near-alone/elk/board.exp.json | 12 +- .../stable/near-alone/elk/sketch.exp.svg | 2 +- .../number_connections/dagre/board.exp.json | 16 +- .../number_connections/dagre/sketch.exp.svg | 2 +- .../number_connections/elk/board.exp.json | 16 +- .../number_connections/elk/sketch.exp.svg | 2 +- .../one_container_loop/dagre/board.exp.json | 32 +-- .../one_container_loop/dagre/sketch.exp.svg | 2 +- .../one_container_loop/elk/board.exp.json | 32 +-- .../one_container_loop/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 28 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 28 +- .../elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 52 ++-- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 52 ++-- .../elk/sketch.exp.svg | 2 +- .../testdata/stable/p/dagre/board.exp.json | 8 +- .../testdata/stable/p/dagre/sketch.exp.svg | 2 +- e2etests/testdata/stable/p/elk/board.exp.json | 8 +- e2etests/testdata/stable/p/elk/sketch.exp.svg | 2 +- .../stable/people/dagre/board.exp.json | 48 ++-- .../stable/people/dagre/sketch.exp.svg | 2 +- .../testdata/stable/people/elk/board.exp.json | 48 ++-- .../testdata/stable/people/elk/sketch.exp.svg | 2 +- .../testdata/stable/pre/dagre/board.exp.json | 8 +- .../testdata/stable/pre/dagre/sketch.exp.svg | 2 +- .../testdata/stable/pre/elk/board.exp.json | 8 +- .../testdata/stable/pre/elk/sketch.exp.svg | 2 +- .../self-referencing/dagre/board.exp.json | 12 +- .../self-referencing/dagre/sketch.exp.svg | 2 +- .../self-referencing/elk/board.exp.json | 12 +- .../self-referencing/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 16 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 16 +- .../elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 24 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 24 +- .../elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 80 +++--- .../dagre/sketch.exp.svg | 6 +- .../elk/board.exp.json | 80 +++--- .../elk/sketch.exp.svg | 6 +- .../dagre/board.exp.json | 8 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 8 +- .../elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 56 ++-- .../dagre/sketch.exp.svg | 12 +- .../elk/board.exp.json | 56 ++-- .../elk/sketch.exp.svg | 12 +- .../dagre/board.exp.json | 16 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 16 +- .../elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 64 ++--- .../dagre/sketch.exp.svg | 22 +- .../elk/board.exp.json | 64 ++--- .../elk/sketch.exp.svg | 22 +- .../dagre/board.exp.json | 92 +++---- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 92 +++---- .../elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 32 +-- .../dagre/sketch.exp.svg | 2 +- .../sequence_diagram_note/elk/board.exp.json | 32 +-- .../sequence_diagram_note/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 56 ++-- .../dagre/sketch.exp.svg | 4 +- .../sequence_diagram_real/elk/board.exp.json | 56 ++-- .../sequence_diagram_real/elk/sketch.exp.svg | 4 +- .../dagre/board.exp.json | 28 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 28 +- .../elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 20 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 20 +- .../elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 68 ++--- .../dagre/sketch.exp.svg | 2 +- .../sequence_diagram_span/elk/board.exp.json | 68 ++--- .../sequence_diagram_span/elk/sketch.exp.svg | 2 +- .../sequence_diagrams/dagre/board.exp.json | 256 +++++++++--------- .../sequence_diagrams/dagre/sketch.exp.svg | 2 +- .../sequence_diagrams/elk/board.exp.json | 256 +++++++++--------- .../sequence_diagrams/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 8 +- .../dagre/sketch.exp.svg | 6 +- .../elk/board.exp.json | 8 +- .../elk/sketch.exp.svg | 6 +- .../stable/sql_tables/dagre/board.exp.json | 16 +- .../stable/sql_tables/dagre/sketch.exp.svg | 10 +- .../stable/sql_tables/elk/board.exp.json | 16 +- .../stable/sql_tables/elk/sketch.exp.svg | 10 +- .../stable/square_3d/dagre/board.exp.json | 8 +- .../stable/square_3d/dagre/sketch.exp.svg | 2 +- .../stable/square_3d/elk/board.exp.json | 8 +- .../stable/square_3d/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 100 +++---- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 100 +++---- .../elk/sketch.exp.svg | 2 +- .../stable/stylish/dagre/board.exp.json | 8 +- .../stable/stylish/dagre/sketch.exp.svg | 2 +- .../stable/stylish/elk/board.exp.json | 8 +- .../stable/stylish/elk/sketch.exp.svg | 2 +- .../stable/tooltips/dagre/board.exp.json | 8 +- .../stable/tooltips/dagre/sketch.exp.svg | 2 +- .../stable/tooltips/elk/board.exp.json | 8 +- .../stable/tooltips/elk/sketch.exp.svg | 2 +- .../transparent_3d/dagre/board.exp.json | 4 +- .../transparent_3d/dagre/sketch.exp.svg | 2 +- .../stable/transparent_3d/elk/board.exp.json | 4 +- .../stable/transparent_3d/elk/sketch.exp.svg | 2 +- .../unnamed_only_height/dagre/board.exp.json | 4 +- .../unnamed_only_height/dagre/sketch.exp.svg | 2 +- .../unnamed_only_height/elk/board.exp.json | 4 +- .../unnamed_only_height/elk/sketch.exp.svg | 2 +- .../unnamed_only_width/dagre/board.exp.json | 4 +- .../unnamed_only_width/dagre/sketch.exp.svg | 2 +- .../unnamed_only_width/elk/board.exp.json | 4 +- .../unnamed_only_width/elk/sketch.exp.svg | 2 +- .../stable/us_map/dagre/board.exp.json | 200 +++++++------- .../stable/us_map/dagre/sketch.exp.svg | 2 +- .../testdata/stable/us_map/elk/board.exp.json | 200 +++++++------- .../testdata/stable/us_map/elk/sketch.exp.svg | 2 +- .../container_child_edge/dagre/board.exp.json | 12 +- .../container_child_edge/dagre/sketch.exp.svg | 2 +- .../container_child_edge/elk/board.exp.json | 12 +- .../container_child_edge/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 20 +- .../dagre/sketch.exp.svg | 2 +- .../elk/board.exp.json | 20 +- .../elk/sketch.exp.svg | 2 +- .../font_sizes_large/dagre/board.exp.json | 20 +- .../font_sizes_large/dagre/sketch.exp.svg | 2 +- .../todo/font_sizes_large/elk/board.exp.json | 20 +- .../todo/font_sizes_large/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 32 +-- .../dagre/sketch.exp.svg | 12 +- .../elk/board.exp.json | 32 +-- .../elk/sketch.exp.svg | 12 +- .../dagre/board.exp.json | 32 +-- .../dagre/sketch.exp.svg | 8 +- .../elk/board.exp.json | 32 +-- .../elk/sketch.exp.svg | 8 +- .../dagre/board.exp.json | 64 ++--- .../dagre/sketch.exp.svg | 6 +- .../shape_set_width_height/elk/board.exp.json | 64 ++--- .../shape_set_width_height/elk/sketch.exp.svg | 6 +- .../todo/tall_edge_label/dagre/board.exp.json | 8 +- .../todo/tall_edge_label/dagre/sketch.exp.svg | 2 +- .../todo/tall_edge_label/elk/board.exp.json | 8 +- .../todo/tall_edge_label/elk/sketch.exp.svg | 2 +- 465 files changed, 3900 insertions(+), 3900 deletions(-) diff --git a/d2renderers/d2sketch/testdata/all_shapes/sketch.exp.svg b/d2renderers/d2sketch/testdata/all_shapes/sketch.exp.svg index 05eaa9547..6e4e30c89 100644 --- a/d2renderers/d2sketch/testdata/all_shapes/sketch.exp.svg +++ b/d2renderers/d2sketch/testdata/all_shapes/sketch.exp.svg @@ -51,7 +51,7 @@ width="1410" height="712" viewBox="-102 -102 1410 712">x

                                  linux: because a PC is a terrible thing to waste

                                  -
                                  a You don't have to know how the computer works,just how to work the computer. +
                              a You don't have to know how the computer works,just how to work the computer. x

                              linux: because a PC is a terrible thing to waste

                              -
                              a You don't have to know how the computer works,just how to work the computer. +
                            a You don't have to know how the computer works,just how to work the computer. aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 +aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 diff --git a/e2etests/testdata/stable/chaos2/elk/board.exp.json b/e2etests/testdata/stable/chaos2/elk/board.exp.json index 73b4ac46a..397ce1bee 100644 --- a/e2etests/testdata/stable/chaos2/elk/board.exp.json +++ b/e2etests/testdata/stable/chaos2/elk/board.exp.json @@ -37,8 +37,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 32, - "labelHeight": 41, + "labelWidth": 27, + "labelHeight": 36, "labelPosition": "INSIDE_TOP_CENTER", "zIndex": 0, "level": 1 @@ -78,8 +78,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 31, - "labelHeight": 36, + "labelWidth": 26, + "labelHeight": 31, "labelPosition": "INSIDE_TOP_CENTER", "zIndex": 0, "level": 2 @@ -119,8 +119,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 24, - "labelHeight": 31, + "labelWidth": 19, + "labelHeight": 26, "labelPosition": "INSIDE_TOP_CENTER", "zIndex": 0, "level": 3 @@ -160,8 +160,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 22, - "labelHeight": 26, + "labelWidth": 17, + "labelHeight": 21, "labelPosition": "INSIDE_TOP_CENTER", "zIndex": 0, "level": 4 @@ -241,8 +241,8 @@ "italic": false, "bold": true, "underline": false, - "labelWidth": 17, - "labelHeight": 26, + "labelWidth": 12, + "labelHeight": 21, "labelPosition": "INSIDE_MIDDLE_CENTER", "zIndex": 0, "level": 5 @@ -322,8 +322,8 @@ "italic": false, "bold": true, "underline": false, - "labelWidth": 23, - "labelHeight": 26, + "labelWidth": 18, + "labelHeight": 21, "labelPosition": "INSIDE_MIDDLE_CENTER", "zIndex": 0, "level": 4 @@ -363,8 +363,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 14, - "labelHeight": 31, + "labelWidth": 9, + "labelHeight": 26, "labelPosition": "INSIDE_TOP_CENTER", "zIndex": 0, "level": 3 @@ -404,8 +404,8 @@ "italic": false, "bold": true, "underline": false, - "labelWidth": 15, - "labelHeight": 26, + "labelWidth": 10, + "labelHeight": 21, "labelPosition": "INSIDE_MIDDLE_CENTER", "zIndex": 0, "level": 4 @@ -445,8 +445,8 @@ "italic": false, "bold": true, "underline": false, - "labelWidth": 22, - "labelHeight": 26, + "labelWidth": 17, + "labelHeight": 21, "labelPosition": "INSIDE_MIDDLE_CENTER", "zIndex": 0, "level": 3 @@ -486,8 +486,8 @@ "italic": false, "bold": true, "underline": false, - "labelWidth": 14, - "labelHeight": 26, + "labelWidth": 9, + "labelHeight": 21, "labelPosition": "INSIDE_MIDDLE_CENTER", "zIndex": 0, "level": 2 @@ -527,8 +527,8 @@ "italic": false, "bold": true, "underline": false, - "labelWidth": 31, - "labelHeight": 26, + "labelWidth": 26, + "labelHeight": 21, "labelPosition": "INSIDE_MIDDLE_CENTER", "zIndex": 0, "level": 2 @@ -608,8 +608,8 @@ "italic": false, "bold": true, "underline": false, - "labelWidth": 23, - "labelHeight": 26, + "labelWidth": 18, + "labelHeight": 21, "labelPosition": "INSIDE_MIDDLE_CENTER", "zIndex": 0, "level": 2 diff --git a/e2etests/testdata/stable/chaos2/elk/sketch.exp.svg b/e2etests/testdata/stable/chaos2/elk/sketch.exp.svg index 032dcf16a..5d59df29d 100644 --- a/e2etests/testdata/stable/chaos2/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/chaos2/elk/sketch.exp.svg @@ -796,7 +796,7 @@ width="1098" height="2616" viewBox="-90 -90 1098 2616">aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 +aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 diff --git a/e2etests/testdata/stable/child_parent_edges/dagre/board.exp.json b/e2etests/testdata/stable/child_parent_edges/dagre/board.exp.json index 1f67893d2..04f3c5c80 100644 --- a/e2etests/testdata/stable/child_parent_edges/dagre/board.exp.json +++ b/e2etests/testdata/stable/child_parent_edges/dagre/board.exp.json @@ -37,8 +37,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 17, - "labelHeight": 41, + "labelWidth": 12, + "labelHeight": 36, "labelPosition": "INSIDE_TOP_CENTER", "zIndex": 0, "level": 1 @@ -78,8 +78,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 17, - "labelHeight": 36, + "labelWidth": 12, + "labelHeight": 31, "labelPosition": "INSIDE_TOP_CENTER", "zIndex": 0, "level": 2 @@ -119,8 +119,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 14, - "labelHeight": 31, + "labelWidth": 9, + "labelHeight": 26, "labelPosition": "INSIDE_TOP_CENTER", "zIndex": 0, "level": 3 @@ -160,8 +160,8 @@ "italic": false, "bold": true, "underline": false, - "labelWidth": 14, - "labelHeight": 26, + "labelWidth": 9, + "labelHeight": 21, "labelPosition": "INSIDE_MIDDLE_CENTER", "zIndex": 0, "level": 4 diff --git a/e2etests/testdata/stable/child_parent_edges/dagre/sketch.exp.svg b/e2etests/testdata/stable/child_parent_edges/dagre/sketch.exp.svg index 67aa3c6cc..52569b01a 100644 --- a/e2etests/testdata/stable/child_parent_edges/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/child_parent_edges/dagre/sketch.exp.svg @@ -39,7 +39,7 @@ width="638" height="570" viewBox="-102 -102 638 570">xyThe top of the mountain

                            Cats, no less liquid than their shadows, offer no angles to the wind.

                            +xyThe top of the mountain

                            Cats, no less liquid than their shadows, offer no angles to the wind.

                            If we can't fix it, it ain't broke.

                            Dieters live life in the fasting lane.

                            -
                            JoeDonaldi am top lefti am top righti am bottom lefti am bottom right +
                            JoeDonaldi am top lefti am top righti am bottom lefti am bottom right xyThe top of the mountain

                            Cats, no less liquid than their shadows, offer no angles to the wind.

                            +xyThe top of the mountain

                            Cats, no less liquid than their shadows, offer no angles to the wind.

                            If we can't fix it, it ain't broke.

                            Dieters live life in the fasting lane.

                            -
                            JoeDonaldi am top lefti am top righti am bottom lefti am bottom right +
                            JoeDonaldi am top lefti am top righti am bottom lefti am bottom right poll the peopleresultsunfavorablefavorablewill of the people

                            A winning strategy

                            -
                            +
                        poll the peopleresultsunfavorablefavorablewill of the people

                        A winning strategy

                        -
                        +
                      mixed togethersugarsolution we get +mixed togethersugarsolution we get mixed togethersugarsolution we get +mixed togethersugarsolution we get

                      Markdown: Syntax

                      -
                      ab +
                  ab

                  Markdown: Syntax

                  -
                  ab +
                ab markdown

                Lorem ipsum dolor sit amet, consectetur adipiscing elit,
                sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

                -
                +
            markdown

            Lorem ipsum dolor sit amet, consectetur adipiscing elit,
            sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

            -
            +
          markdown

          Lorem ipsum dolor sit amet, consectetur adipiscing elit,
          sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

          -
          +
      markdown

      Lorem ipsum dolor sit amet, consectetur adipiscing elit,
      sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

      -
      +

      code

      -
      ab +
ab

code

-
ab +
ab containerscloudtall cylinderclass- +containerscloudtall cylinderclass- num int- timeout @@ -808,7 +808,7 @@ width="2482" height="2672" viewBox="-102 -102 2482 2672">containerscloudtall cylinderclass- +containerscloudtall cylinderclass- num int- timeout @@ -808,7 +808,7 @@ width="2622" height="2644" viewBox="-90 -90 2622 2644">1Like starbucks or something -2I'm not sure what this is +}]]>1Like starbucks or something +2I'm not sure what this is