A javascript library for constructing toy wooden train track designs in SVG
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


Woodentrack is a coffeescript library for designing and testing toy train track layouts.

It has as few dependencies for running tests, as shown in package.json. run "npm install" to set them up.


This project is an exercise in getting to grips with SVG that may also allow a developer to play with the idea of:

  1. creating a single track from a set number of pieces that a train can fully traverse
  2. automatically designing aesthetically pleasing tracks
  3. touch interfaces

woodentrack.coffee defines an API for building and manipulating the model of a track. svg "painters" are defined that use both d3js and raphaeljs svg libraries. woodentrack.random.coffee provides some functions for randomly generating a track.


To use demos in /etc, try "python -m SimpleHTTPServer 8000".

  1. demo.html: simple page with empty canvas. open console. start building track.
  2. d3.html / raphael.html: random track builders

Potential demos

  1. easy to use track drawing application - use interact.js?
  2. take existing track and click button to morph track into another layout with the same pieces and the same number of loose ends


  • documentation of trigonometry with litcoffee / coffeedoc.info
  • pan / zoom for raphael painter
  • make pan / zoom optional for d3 painter
  • optimisation for random demo that slows up as n increases
  • removeAndJoin method (rename of existing remove method and a new remove added that doesnt change the rest of the track)
  • move method (move a section / part section / piece)
  • add directions (IN/OUT) on connections that need to be matched - i.e. IN+OUT makes a connection