moonrockz/diagrams-svg/railroad-layout
Types
Channel
pub(all) enum Channel {
Matched
NotMatched
Taken
Failure
} derive(Eq, @moonbitlang/core/debug.Debug)The four static trace highlight channels.
Channel::equal
fn Channel::equal(Channel, Channel) -> BoolChannel::not_equal
fn Channel::not_equal(x : Channel, y : Channel) -> BoolChannel::to_repr
fn Channel::to_repr(Channel) -> @moonbitlang/core/debug.ReprFinding
pub struct Finding {
rule : Rule
identities : ReadOnlyArray[String]
message : String
} derive(Eq, @moonbitlang/core/debug.Debug)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.ReprFrame
pub struct Frame {
owner : String
role : FrameRole
rect : Rect
label : Label
} derive(Eq, @moonbitlang/core/debug.Debug)Frame::equal
fn Frame::equal(Frame, Frame) -> BoolFrame::not_equal
fn Frame::not_equal(x : Frame, y : Frame) -> BoolFrame::to_repr
fn Frame::to_repr(Frame) -> @moonbitlang/core/debug.ReprFrameRole
pub(all) enum FrameRole {
Group
Except
} derive(Eq, @moonbitlang/core/debug.Debug)FrameRole::equal
fn FrameRole::equal(FrameRole, FrameRole) -> BoolFrameRole::not_equal
fn FrameRole::not_equal(x : FrameRole, y : FrameRole) -> BoolFrameRole::to_repr
fn FrameRole::to_repr(FrameRole) -> @moonbitlang/core/debug.ReprGeometry
pub struct Geometry {
topology : @moonrockz/diagrams/railroad-trace.Topology
width : Double
height : Double
title : Label?
tracks : ReadOnlyArray[TrackBox]
terms : ReadOnlyArray[TermBox]
frames : ReadOnlyArray[Frame]
wires : ReadOnlyArray[Wire]
notes : ReadOnlyArray[NoteBox]
// private fields
}Deterministic railroad geometry. Every drawn connector of the topology has one wire; every term has one box.
Geometry::new
fn Geometry::new(topology : @moonrockz/diagrams/railroad-trace.Topology, width : Double, height : Double, tracks : ArrayView[TrackBox], terms : ArrayView[TermBox], frames : ArrayView[Frame], wires : ArrayView[Wire], notes : ArrayView[NoteBox], points : ArrayView[(String, Point)], title? : Label) -> GeometryMake geometry from parts, for tests of the legibility checker.
Geometry::point
fn Geometry::point(self : Geometry, id : String) -> Point?The coordinates of a topology point.
Geometry::points
fn Geometry::points(self : Geometry) -> Array[(String, Point)]Label
pub struct Label {
lines : ReadOnlyArray[String]
x : Double
size : Double
weight : Int
box : Rect
owner : String
} derive(Eq, @moonbitlang/core/debug.Debug)Measured text. x is the horizontal centre and box the text bounds.
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.ReprLimits
pub struct Limits {
nodes : Int
depth : Int
work : Int
width : Int
output_units : Int
minimum_approach : Double
} derive(Eq, @moonbitlang/core/debug.Debug)Explicit bounds for railroad layout and painting.
Limits::equal
fn Limits::equal(Limits, Limits) -> BoolLimits::new
fn Limits::new(nodes? : Int, depth? : Int, work? : Int, width? : Int, output_units? : Int, minimum_approach? : Double) -> LimitsLimits::not_equal
fn Limits::not_equal(x : Limits, y : Limits) -> BoolLimits::to_repr
fn Limits::to_repr(Limits) -> @moonbitlang/core/debug.ReprLimits::with_minimum_approach
fn Limits::with_minimum_approach(self : Limits, minimum_approach : Double) -> LimitsModel
pub(all) enum Model {
Regex(@moonrockz/diagrams/regex.Regex)
Ebnf(@moonrockz/diagrams/ebnf.Grammar)
} derive(Eq, @moonbitlang/core/debug.Debug)The two railroad source models.
Model::equal
fn Model::equal(Model, Model) -> BoolModel::not_equal
fn Model::not_equal(x : Model, y : Model) -> BoolModel::to_repr
fn Model::to_repr(Model) -> @moonbitlang/core/debug.ReprNoteBox
pub struct NoteBox {
id : String
rect : Rect
label : Label
} derive(Eq, @moonbitlang/core/debug.Debug)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.ReprPoint
pub(all) struct Point {
x : Double
y : Double
} derive(Eq, @moonbitlang/core/debug.Debug)Point::equal
fn Point::equal(Point, Point) -> BoolPoint::not_equal
fn Point::not_equal(x : Point, y : Point) -> BoolPoint::to_repr
fn Point::to_repr(Point) -> @moonbitlang/core/debug.ReprRect
pub(all) struct Rect {
x : Double
y : Double
width : Double
height : Double
} derive(Eq, @moonbitlang/core/debug.Debug)Rect::contains
fn Rect::contains(self : Rect, other : Rect, tolerance? : Double) -> BoolRect::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) -> BoolRect::to_repr
fn Rect::to_repr(Rect) -> @moonbitlang/core/debug.ReprResult
pub struct Result {
geometry : Geometry?
diagnostics : ReadOnlyArray[@moonrockz/diagrams.Diagnostic]
}Rule
pub(all) enum Rule {
Overlap
Fit
Contrast
Endpoint
Length
Limit
} derive(Eq, @moonbitlang/core/debug.Debug)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.ReprShape
pub(all) enum Shape {
Pill
Square
Class
Special
Anchor
Lookaround
Dot
} derive(Eq, @moonbitlang/core/debug.Debug)The visual form of a term.
Shape::equal
fn Shape::equal(Shape, Shape) -> BoolShape::not_equal
fn Shape::not_equal(x : Shape, y : Shape) -> BoolShape::to_repr
fn Shape::to_repr(Shape) -> @moonbitlang/core/debug.ReprTermBox
pub struct TermBox {
term : @moonrockz/diagrams/railroad-trace.Term
shape : Shape
rect : Rect
label : Label
notes : ReadOnlyArray[Label]
} derive(Eq, @moonbitlang/core/debug.Debug)TermBox::equal
fn TermBox::equal(TermBox, TermBox) -> BoolTermBox::not_equal
fn TermBox::not_equal(x : TermBox, y : TermBox) -> BoolTermBox::to_repr
fn TermBox::to_repr(TermBox) -> @moonbitlang/core/debug.ReprTermBox::with_rect
fn TermBox::with_rect(self : TermBox, rect : Rect) -> TermBoxThe term with another rectangle, for supplied test geometry.
TrackBox
pub struct TrackBox {
track : @moonrockz/diagrams/railroad-trace.Track
label : Label
start : Point
end : Point
notes : ReadOnlyArray[Label]
} derive(Eq, @moonbitlang/core/debug.Debug)TrackBox::equal
fn TrackBox::equal(TrackBox, TrackBox) -> BoolTrackBox::not_equal
fn TrackBox::not_equal(x : TrackBox, y : TrackBox) -> BoolTrackBox::to_repr
fn TrackBox::to_repr(TrackBox) -> @moonbitlang/core/debug.ReprWire
pub struct Wire {
connector : @moonrockz/diagrams/railroad-trace.Connector
points : ReadOnlyArray[Point]
label : Label?
} derive(Eq, @moonbitlang/core/debug.Debug)The drawn path of one connector, as a polyline in its semantic direction. Corners are rounded when painted.
Wire::equal
fn Wire::equal(Wire, Wire) -> BoolWire::length
fn Wire::length(self : Wire) -> DoubleThe polyline length of a wire.
Wire::not_equal
fn Wire::not_equal(x : Wire, y : Wire) -> BoolWire::path
fn Wire::path(self : Wire, radius? : Double) -> StringThe SVG path data of a wire, with rounded corners.
Wire::to_repr
fn Wire::to_repr(Wire) -> @moonbitlang/core/debug.ReprWire::with_points
fn Wire::with_points(self : Wire, points : ArrayView[Point]) -> WireThe wire with other points, for supplied test geometry.
Values
channel_color
fn channel_color(palette : @moonrockz/diagrams-svg/theme.Palette, channel : Channel) -> @moonrockz/diagrams-svg/theme.ColorThe theme colour of a highlight channel.
check
fn check(geometry : Geometry, palette : @moonrockz/diagrams-svg/theme.Palette, work_limit? : Int, highlight_colors? : ArrayView[@moonrockz/diagrams-svg/theme.Color]) -> Array[Finding]Check attachment, connector length, crossings, label fit and contrast.
colors overrides the highlight colours to check, for example caller
styles of a trace highlight.
layout
fn layout(model : Model, limits? : Limits) -> ResultLay out a regex or grammar railroad. Rules stay in source order; each drawn connector of the topology gets one wire.
svg_number
fn svg_number(value : Double) -> StringFormat a coordinate for SVG with at most three decimals.
term_colors
fn term_colors(palette : @moonrockz/diagrams-svg/theme.Palette, shape : Shape) -> (@moonrockz/diagrams-svg/theme.Color, @moonrockz/diagrams-svg/theme.Color, @moonrockz/diagrams-svg/theme.Color)The fill, stroke and text colours of a term shape in one palette. The painter and the checker use the same choice.