moonrockz/diagrams-svg/layout

Types

ActivationBar

pub(all) struct ActivationBar {
  participant : String
  depth : Int
  box : Rect
} derive(Eq, @moonbitlang/core/debug.Debug)

One activation, numbered from depth zero. Nested bars move right by 4 px.

Source

ActivationBar::equal

fn ActivationBar::equal(ActivationBar, ActivationBar) -> Bool

Source

ActivationBar::not_equal

fn ActivationBar::not_equal(x : ActivationBar, y : ActivationBar) -> Bool

Source

ActivationBar::to_repr

fn ActivationBar::to_repr(ActivationBar) -> @moonbitlang/core/debug.Repr

Source

Finding

pub(all) struct Finding {
  rule : Rule
  message : String
} derive(Eq, @moonbitlang/core/debug.Debug)

One break of a legibility rule.

Source

Finding::equal

fn Finding::equal(Finding, Finding) -> Bool

Source

Finding::not_equal

fn Finding::not_equal(x : Finding, y : Finding) -> Bool

Source

Finding::to_repr

fn Finding::to_repr(Finding) -> @moonbitlang/core/debug.Repr

Source

FrameBox

pub(all) struct FrameBox {
  index : Int
  parent : Int?
  kind : @moonrockz/diagrams/sequence.FrameKind
  colour : String?
  box : Rect
  header : Label?
  chip : Rect?
  sections : ReadOnlyArray[FrameSection]
} derive(Eq, @moonbitlang/core/debug.Debug)

A frame and its ordered sections. The array of frames is in preorder.

Source

FrameBox::equal

fn FrameBox::equal(FrameBox, FrameBox) -> Bool

Source

FrameBox::not_equal

fn FrameBox::not_equal(x : FrameBox, y : FrameBox) -> Bool

Source

FrameBox::to_repr

fn FrameBox::to_repr(FrameBox) -> @moonbitlang/core/debug.Repr

Source

FrameSection

pub(all) struct FrameSection {
  box : Rect
  label : Label?
  chip : Rect?
  divider : Segment?
} derive(Eq, @moonbitlang/core/debug.Debug)

One frame section, with an optional label and preceding divider.

Source

FrameSection::equal

fn FrameSection::equal(FrameSection, FrameSection) -> Bool

Source

FrameSection::not_equal

fn FrameSection::not_equal(x : FrameSection, y : FrameSection) -> Bool

Source

FrameSection::to_repr

fn FrameSection::to_repr(FrameSection) -> @moonbitlang/core/debug.Repr

Source

Geometry

pub(all) struct Geometry {
  width : Int
  height : Int
  lifeline_top : Int
  lifeline_bottom : Int
  participants : ReadOnlyArray[ParticipantBox]
  messages : ReadOnlyArray[MessageLine]
  notes : ReadOnlyArray[NoteBox]
  activations : ReadOnlyArray[ActivationBar]
  frames : ReadOnlyArray[FrameBox]
  groups : ReadOnlyArray[GroupBox]
  title : Label?
  title_box : Rect?
} derive(Eq, @moonbitlang/core/debug.Debug)

The geometry of a sequence diagram. The painter draws it, and the legibility check reads it.

Source

Geometry::equal

fn Geometry::equal(Geometry, Geometry) -> Bool

Source

Geometry::not_equal

fn Geometry::not_equal(x : Geometry, y : Geometry) -> Bool

Source

Geometry::to_repr

fn Geometry::to_repr(Geometry) -> @moonbitlang/core/debug.Repr

Source

GroupBox

pub(all) struct GroupBox {
  group : @moonrockz/diagrams/sequence.BoxGroup
  box : Rect
  label : Label
  chip : Rect
} derive(Eq, @moonbitlang/core/debug.Debug)

A participant group and its title. The box includes its members and their lifelines, including members created later in the diagram.

Source

GroupBox::equal

fn GroupBox::equal(GroupBox, GroupBox) -> Bool

Source

GroupBox::not_equal

fn GroupBox::not_equal(x : GroupBox, y : GroupBox) -> Bool

Source

GroupBox::to_repr

fn GroupBox::to_repr(GroupBox) -> @moonbitlang/core/debug.Repr

Source

Ink

pub(all) enum Ink {
  Primary
  Muted
  Accent(@moonrockz/diagrams-svg/theme.Family)
  Color(@moonrockz/diagrams-svg/theme.Color)
} derive(Eq, @moonbitlang/core/debug.Debug)

The colour role of a text.

Source

Ink::equal

fn Ink::equal(Ink, Ink) -> Bool

Source

Ink::not_equal

fn Ink::not_equal(x : Ink, y : Ink) -> Bool

Source

Ink::to_repr

fn Ink::to_repr(Ink) -> @moonbitlang/core/debug.Repr

Source

Label

pub(all) struct Label {
  content : String
  x : Int
  baseline : Int
  size : Int
  weight : Int
  box : Rect
  ink : Ink
  backdrop : ReadOnlyArray[Layer]
  owner : String
} derive(Eq, @moonbitlang/core/debug.Debug)

A text with its measured box. x is the centre, and baseline is the y of the baseline. backdrop lists the layers behind the text, bottom first. owner names the element that the text belongs to.

Source

Label::equal

fn Label::equal(Label, Label) -> Bool

Source

Label::not_equal

fn Label::not_equal(x : Label, y : Label) -> Bool

Source

Label::to_repr

fn Label::to_repr(Label) -> @moonbitlang/core/debug.Repr

Source

Layer

pub(all) enum Layer {
  Mask
  Fill(@moonrockz/diagrams-svg/theme.Family)
  Tint(@moonrockz/diagrams-svg/theme.Color)
} derive(Eq, @moonbitlang/core/debug.Debug)

One layer that is painted behind a text, above the background.

Source

Layer::equal

fn Layer::equal(Layer, Layer) -> Bool

Source

Layer::not_equal

fn Layer::not_equal(x : Layer, y : Layer) -> Bool

Source

Layer::to_repr

fn Layer::to_repr(Layer) -> @moonbitlang/core/debug.Repr

Source

MessageLine

pub(all) struct MessageLine {
  index : Int
  sender : String
  receiver : String
  family : @moonrockz/diagrams-svg/theme.Family
  x1 : Int
  x2 : Int
  y : Int
  chip : Rect
  label : Label
  sublabel : Label?
  path : ReadOnlyArray[Segment]
  message : @moonrockz/diagrams/sequence.Message
} derive(Eq, @moonbitlang/core/debug.Debug)

A message line from x1 to x2 at y, with its label on a chip.

Source

MessageLine::equal

fn MessageLine::equal(MessageLine, MessageLine) -> Bool

Source

MessageLine::not_equal

fn MessageLine::not_equal(x : MessageLine, y : MessageLine) -> Bool

Source

MessageLine::to_repr

fn MessageLine::to_repr(MessageLine) -> @moonbitlang/core/debug.Repr

Source

NoteBox

pub(all) struct NoteBox {
  index : Int
  note : @moonrockz/diagrams/sequence.Note
  box : Rect
  label : Label
} derive(Eq, @moonbitlang/core/debug.Debug)

A note with measured text. The box spans each anchor for an over note.

Source

NoteBox::equal

fn NoteBox::equal(NoteBox, NoteBox) -> Bool

Source

NoteBox::not_equal

fn NoteBox::not_equal(x : NoteBox, y : NoteBox) -> Bool

Source

NoteBox::to_repr

fn NoteBox::to_repr(NoteBox) -> @moonbitlang/core/debug.Repr

Source

ParticipantBox

pub(all) struct ParticipantBox {
  icon_box : Rect?
  id : String
  family : @moonrockz/diagrams-svg/theme.Family
  box : Rect
  label : Label
  lifeline_x : Int
  lifeline_top : Int
  lifeline_bottom : Int
  destroyed : Bool
  participant : @moonrockz/diagrams/sequence.Participant
  sublabel : Label?
} derive(Eq, @moonbitlang/core/debug.Debug)

A participant box with its label and the x of its lifeline.

Source

ParticipantBox::equal

fn ParticipantBox::equal(ParticipantBox, ParticipantBox) -> Bool

Source

ParticipantBox::not_equal

fn ParticipantBox::not_equal(x : ParticipantBox, y : ParticipantBox) -> Bool

Source

ParticipantBox::to_repr

fn ParticipantBox::to_repr(ParticipantBox) -> @moonbitlang/core/debug.Repr

Source

Rect

pub(all) struct Rect {
  x : Int
  y : Int
  width : Int
  height : Int
} derive(Eq, @moonbitlang/core/debug.Debug)

A rectangle in SVG user units. x and y are the top-left corner.

Source

Rect::equal

fn Rect::equal(Rect, Rect) -> Bool

Source

Rect::not_equal

fn Rect::not_equal(x : Rect, y : Rect) -> Bool

Source

Rect::overlaps

fn Rect::overlaps(self : Rect, other : Rect) -> Bool

True when two rectangles share an area.

Source

Rect::to_repr

fn Rect::to_repr(Rect) -> @moonbitlang/core/debug.Repr

Source

Rule

pub(all) enum Rule {
  Overlap
  Fit
  Size
  Contrast
} derive(Eq, @moonbitlang/core/debug.Debug)

A legibility rule.

Source

Rule::equal

fn Rule::equal(Rule, Rule) -> Bool

Source

Rule::not_equal

fn Rule::not_equal(x : Rule, y : Rule) -> Bool

Source

Rule::to_repr

fn Rule::to_repr(Rule) -> @moonbitlang/core/debug.Repr

Source

Segment

pub(all) struct Segment {
  x1 : Int
  y1 : Int
  x2 : Int
  y2 : Int
  owner : String
} derive(Eq, @moonbitlang/core/debug.Debug)

One axis-aligned path segment. Owners associate a path with its label.

Source

Segment::equal

fn Segment::equal(Segment, Segment) -> Bool

Source

Segment::not_equal

fn Segment::not_equal(x : Segment, y : Segment) -> Bool

Source

Segment::to_repr

fn Segment::to_repr(Segment) -> @moonbitlang/core/debug.Repr

Source

Values

check

fn check(geometry : Geometry, palette : @moonrockz/diagrams-svg/theme.Palette) -> Array[Finding]

Check every text block and its actual container. Lifelines are the sole excluded lines: opaque label chips may cover them. Frame and group borders, section dividers, message paths, activation bars and lifetime crosses count. Contrast composes background layers in paint order and then the text alpha.

Source

layout

fn layout(sequence : @moonrockz/diagrams/sequence.Sequence, minimum_approach? : Double) -> Geometry

Layout in two passes: measured horizontal constraints, then an event cursor for rows. The result retains every sequence element for a separate painter.

Source

min_contrast

let min_contrast : Double

The smallest contrast ratio of text against the colour behind it.

Source

min_text_size

let min_text_size : Int

The smallest text size, in pixels.

Source