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.
ActivationBar::equal
fn ActivationBar::equal(ActivationBar, ActivationBar) -> BoolActivationBar::not_equal
fn ActivationBar::not_equal(x : ActivationBar, y : ActivationBar) -> BoolActivationBar::to_repr
fn ActivationBar::to_repr(ActivationBar) -> @moonbitlang/core/debug.ReprFinding
pub(all) struct Finding {
rule : Rule
message : String
} derive(Eq, @moonbitlang/core/debug.Debug)One break of a legibility rule.
Finding::equal
fn Finding::equal(Finding, Finding) -> BoolFinding::not_equal
fn Finding::not_equal(x : Finding, y : Finding) -> BoolFinding::to_repr
fn Finding::to_repr(Finding) -> @moonbitlang/core/debug.ReprFrameBox
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.
FrameBox::equal
fn FrameBox::equal(FrameBox, FrameBox) -> BoolFrameBox::not_equal
fn FrameBox::not_equal(x : FrameBox, y : FrameBox) -> BoolFrameBox::to_repr
fn FrameBox::to_repr(FrameBox) -> @moonbitlang/core/debug.ReprFrameSection
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.
FrameSection::equal
fn FrameSection::equal(FrameSection, FrameSection) -> BoolFrameSection::not_equal
fn FrameSection::not_equal(x : FrameSection, y : FrameSection) -> BoolFrameSection::to_repr
fn FrameSection::to_repr(FrameSection) -> @moonbitlang/core/debug.ReprGeometry
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.
Geometry::equal
fn Geometry::equal(Geometry, Geometry) -> BoolGeometry::not_equal
fn Geometry::not_equal(x : Geometry, y : Geometry) -> BoolGeometry::to_repr
fn Geometry::to_repr(Geometry) -> @moonbitlang/core/debug.ReprGroupBox
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.
GroupBox::equal
fn GroupBox::equal(GroupBox, GroupBox) -> BoolGroupBox::not_equal
fn GroupBox::not_equal(x : GroupBox, y : GroupBox) -> BoolGroupBox::to_repr
fn GroupBox::to_repr(GroupBox) -> @moonbitlang/core/debug.ReprInk
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.
Ink::equal
fn Ink::equal(Ink, Ink) -> BoolInk::not_equal
fn Ink::not_equal(x : Ink, y : Ink) -> BoolInk::to_repr
fn Ink::to_repr(Ink) -> @moonbitlang/core/debug.ReprLabel
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.
Label::equal
fn Label::equal(Label, Label) -> BoolLabel::not_equal
fn Label::not_equal(x : Label, y : Label) -> BoolLabel::to_repr
fn Label::to_repr(Label) -> @moonbitlang/core/debug.ReprLayer
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.
Layer::equal
fn Layer::equal(Layer, Layer) -> BoolLayer::not_equal
fn Layer::not_equal(x : Layer, y : Layer) -> BoolLayer::to_repr
fn Layer::to_repr(Layer) -> @moonbitlang/core/debug.ReprMessageLine
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.
MessageLine::equal
fn MessageLine::equal(MessageLine, MessageLine) -> BoolMessageLine::not_equal
fn MessageLine::not_equal(x : MessageLine, y : MessageLine) -> BoolMessageLine::to_repr
fn MessageLine::to_repr(MessageLine) -> @moonbitlang/core/debug.ReprNoteBox
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.
NoteBox::equal
fn NoteBox::equal(NoteBox, NoteBox) -> BoolNoteBox::not_equal
fn NoteBox::not_equal(x : NoteBox, y : NoteBox) -> BoolNoteBox::to_repr
fn NoteBox::to_repr(NoteBox) -> @moonbitlang/core/debug.ReprParticipantBox
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.
ParticipantBox::equal
fn ParticipantBox::equal(ParticipantBox, ParticipantBox) -> BoolParticipantBox::not_equal
fn ParticipantBox::not_equal(x : ParticipantBox, y : ParticipantBox) -> BoolParticipantBox::to_repr
fn ParticipantBox::to_repr(ParticipantBox) -> @moonbitlang/core/debug.ReprRect
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.
Rect::equal
fn Rect::equal(Rect, Rect) -> BoolRect::not_equal
fn Rect::not_equal(x : Rect, y : Rect) -> BoolRect::overlaps
fn Rect::overlaps(self : Rect, other : Rect) -> BoolTrue when two rectangles share an area.
Rect::to_repr
fn Rect::to_repr(Rect) -> @moonbitlang/core/debug.ReprRule
pub(all) enum Rule {
Overlap
Fit
Size
Contrast
} derive(Eq, @moonbitlang/core/debug.Debug)A legibility rule.
Rule::equal
fn Rule::equal(Rule, Rule) -> BoolRule::not_equal
fn Rule::not_equal(x : Rule, y : Rule) -> BoolRule::to_repr
fn Rule::to_repr(Rule) -> @moonbitlang/core/debug.ReprSegment
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.
Segment::equal
fn Segment::equal(Segment, Segment) -> BoolSegment::not_equal
fn Segment::not_equal(x : Segment, y : Segment) -> BoolSegment::to_repr
fn Segment::to_repr(Segment) -> @moonbitlang/core/debug.ReprValues
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.
layout
fn layout(sequence : @moonrockz/diagrams/sequence.Sequence, minimum_approach? : Double) -> GeometryLayout in two passes: measured horizontal constraints, then an event cursor for rows. The result retains every sequence element for a separate painter.
min_contrast
let min_contrast : DoubleThe smallest contrast ratio of text against the colour behind it.
min_text_size
let min_text_size : IntThe smallest text size, in pixels.