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.

Source

Channel::equal

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

Source

Channel::not_equal

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

Source

Channel::to_repr

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

Source

Finding

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

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

Frame

pub struct Frame {
  owner : String
  role : FrameRole
  rect : Rect
  label : Label
} derive(Eq, @moonbitlang/core/debug.Debug)

Source

Frame::equal

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

Source

Frame::not_equal

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

Source

Frame::to_repr

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

Source

FrameRole

pub(all) enum FrameRole {
  Group
  Except
} derive(Eq, @moonbitlang/core/debug.Debug)

Source

FrameRole::equal

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

Source

FrameRole::not_equal

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

Source

FrameRole::to_repr

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

Source

Geometry

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.

Source

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) -> Geometry

Make geometry from parts, for tests of the legibility checker.

Source

Geometry::point

fn Geometry::point(self : Geometry, id : String) -> Point?

The coordinates of a topology point.

Source

Geometry::points

fn Geometry::points(self : Geometry) -> Array[(String, Point)]

Source

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.

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

Limits

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.

Source

Limits::equal

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

Source

Limits::new

fn Limits::new(nodes? : Int, depth? : Int, work? : Int, width? : Int, output_units? : Int, minimum_approach? : Double) -> Limits

Source

Limits::not_equal

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

Source

Limits::to_repr

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

Source

Limits::with_minimum_approach

fn Limits::with_minimum_approach(self : Limits, minimum_approach : Double) -> Limits

Source

Model

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.

Source

Model::equal

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

Source

Model::not_equal

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

Source

Model::to_repr

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

Source

NoteBox

pub struct NoteBox {
  id : String
  rect : Rect
  label : Label
} derive(Eq, @moonbitlang/core/debug.Debug)

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

Point

pub(all) struct Point {
  x : Double
  y : Double
} derive(Eq, @moonbitlang/core/debug.Debug)

Source

Point::equal

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

Source

Point::not_equal

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

Source

Point::to_repr

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

Source

Rect

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

Source

Rect::contains

fn Rect::contains(self : Rect, other : Rect, tolerance? : Double) -> Bool

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

Source

Rect::to_repr

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

Source

Result

pub struct Result {
  geometry : Geometry?
  diagnostics : ReadOnlyArray[@moonrockz/diagrams.Diagnostic]
}

Source

Rule

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

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

Shape

pub(all) enum Shape {
  Pill
  Square
  Class
  Special
  Anchor
  Lookaround
  Dot
} derive(Eq, @moonbitlang/core/debug.Debug)

The visual form of a term.

Source

Shape::equal

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

Source

Shape::not_equal

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

Source

Shape::to_repr

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

Source

TermBox

pub struct TermBox {
  term : @moonrockz/diagrams/railroad-trace.Term
  shape : Shape
  rect : Rect
  label : Label
  notes : ReadOnlyArray[Label]
} derive(Eq, @moonbitlang/core/debug.Debug)

Source

TermBox::equal

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

Source

TermBox::not_equal

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

Source

TermBox::to_repr

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

Source

TermBox::with_rect

fn TermBox::with_rect(self : TermBox, rect : Rect) -> TermBox

The term with another rectangle, for supplied test geometry.

Source

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)

Source

TrackBox::equal

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

Source

TrackBox::not_equal

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

Source

TrackBox::to_repr

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

Source

Wire

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.

Source

Wire::equal

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

Source

Wire::length

fn Wire::length(self : Wire) -> Double

The polyline length of a wire.

Source

Wire::not_equal

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

Source

Wire::path

fn Wire::path(self : Wire, radius? : Double) -> String

The SVG path data of a wire, with rounded corners.

Source

Wire::to_repr

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

Source

Wire::with_points

fn Wire::with_points(self : Wire, points : ArrayView[Point]) -> Wire

The wire with other points, for supplied test geometry.

Source

Values

channel_color

fn channel_color(palette : @moonrockz/diagrams-svg/theme.Palette, channel : Channel) -> @moonrockz/diagrams-svg/theme.Color

The theme colour of a highlight channel.

Source

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.

Source

layout

fn layout(model : Model, limits? : Limits) -> Result

Lay out a regex or grammar railroad. Rules stay in source order; each drawn connector of the topology gets one wire.

Source

svg_number

fn svg_number(value : Double) -> String

Format a coordinate for SVG with at most three decimals.

Source

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.

Source