askill
railway-drawio

railway-drawioSafety 95Repository

Generate top-down schematic railway track diagrams as draw.io (.drawio) XML files. LEGO/BRIO-style snap-together pieces using turtle graphics — straight, bend, wide bend, turnout, merger. Use when the user asks to create railway track diagrams, causal flow topology diagrams with track metaphors, or draw.io files with railway-style layouts.

0 stars
1.2k downloads
Updated 2/28/2026

Package Files

Loading files...
SKILL.md

Railway Track — draw.io Generation

Generate top-down schematic railway track diagrams as .drawio XML files with LEGO/BRIO-style building pieces that snap together via turtle graphics.

See README.md in this folder for full component specifications, dimensions, and derived constants.

Engine Location

.cursor/skills/railway-drawio/_railway-engine.js

Building Pieces

PieceAPILengthDescription
Straightt.straight()200pxStandard straight track
Half Straightt.halfStraight()100pxHalf-length straight
Bendt.bendRight() / t.bendLeft()45° arc, R=283Standard curve (dx=200, grid-aligned)
Wide Bendt.wideBendRight() / t.wideBendLeft()45° arc, R=449Outer oval curve
Turnoutt.turnoutLeft(fn) / t.turnoutRight(fn)400pxS-curve switch — both exits parallel, 166px offset
Mergert.mergerLeft() / t.mergerRight()400pxReverse S-curve — branch merges into main
Labelt.label(text)Text label at current position

Key Geometry

  • L = 200px — straight piece length
  • R = 283px — bend radius (L/sin 45°), makes bend dx = L
  • GAP = 166px — track-to-track offset from turnout S-curve
  • R_WIDE = 449px — wide bend radius (R + GAP), for outer ovals
  • 4 bends = 180° half-circle; 4 wide bends = wider half-circle matching GAP

Turtle Graphics

Each piece's exit defines the next piece's entry. No manual coordinate math.

const r = require('./_railway-engine');
r.reset();
const t = r.track(x, y, heading);  // heading in radians (0 = right)
t.straight().bendRight().straight();
r.writeXml('output.drawio');

Turnout branches receive a new TrackBuilder in the callback:

t.turnoutLeft(branch => {
  branch.straight().wideBendRight().wideBendRight()
    .straight().wideBendRight().wideBendRight().straight();
});

Examples

  • example-race.js — double-oval race track with inner/outer ovals connected by a turnout and merger
  • example-race.drawio — generated output (open in draw.io)

Usage Pattern

  1. Create a generator script in this folder (or require the engine from elsewhere)
  2. Call r.reset(), build tracks with r.track(), call r.writeXml(path)
  3. Open the .drawio file in draw.io to view

Install

Download ZIP
Requires askill CLI v1.0+

AI Quality Score

65/100Analyzed 3/2/2026

Well-structured technical reference for generating draw.io railway diagrams with turtle graphics. Has clear API documentation, geometry specs, and code examples. However, uses internal .cursor directory (project-specific), has mismatched tags (ci-cd/api don't fit), references external README we can't see, and lacks troubleshooting/error handling content. Good reference skill but project-tailored."

95
80
55
65
80

Metadata

Licenseunknown
Version-
Updated2/28/2026
Publishercjjohansen

Tags

apici-cd