SignScribe road signs for web pages
sign.js is a JavaScript library that draws SignScribe road signs in a web page, still or animated. Animated signs are drawn from their construction lines, then filled with their colours and legends. The artwork is the same as SignScribe Desktop exports.
- Download
- 6.4 MB
- Featured signs
- 51
- Desktop layouts
- 126
- AS 1743 templates
- 496
Try the options
Choose a sign and adjust its motion. The configuration below updates as you change the settings and can be pasted into your page.
Configuration
Only the settings that differ from the defaults.
Edit a template
Choose a Desktop layout or an AS 1743 template, type new legends and change colours, then copy the code or download the sign. Signs exported from SignScribe Desktop with Export › sign.js can be opened here too.
Code for your page
Works with the downloaded sign.js. A sign opened from a Desktop export is loaded from its own file.
Sign library
The signs built into sign.js, drawn live. Select a sign to open it in the playground.
Direction, lane and information signs exported from the SignScribe Desktop layout engine, with their roads, arrow endings, legends and borders.
Tourist signs with their AS 1742.6 symbols and destination lettering.
Motorist service signs with their AS 1742.6 symbols.
Template artwork with pictogram movement. With motion.energy at 0 each sign shows its published static face.
Warning, regulatory and supplementary signs, drawn in and out with their construction lines.
Animation is illustrative
Moving signs are for presentation. The static face exported by SignScribe is the governing artwork. Design and review signs in SignScribe Desktop, then export them as sign.js packages for the web.
Getting started
sign.js has no dependencies. Add the script, give the sign an element with a size, and call signJS with the element's id.
Add sign.js and a sized element
Every sign on this page is in the downloaded file. Give the sign an element with a size and call
signJSwith its id.<div id="sign" style="width:320px;height:320px"></div> <script src="sign.js"></script> <script> signJS("sign", { sign: "DIR-ROUNDABOUT" }); </script>Show a Desktop layout
The 126 SignScribe Desktop layouts are shown by their template code.
signJS("sign", { sign: "G1-5" });Change the legends of an AS 1743 template
Any of the 496 AS 1743 templates with editable legends. New text is set in the template's road series and letter height.
signJS("sign", { sign: { template: "R4-1B", legends: ["80"] } });Show a sign designed in Desktop
In SignScribe Desktop, choose Export › sign.js, then load the exported package.
signJS.load("sign", "my-sign.signjs.json");Play a sequence
Each sign draws out before the next draws in.
signJS("hero", { mode: "sequence", signs: ["DIR-ROUNDABOUT", "TOUR-WHALES", "SVC-AHEAD"] });Control the instance
The instance can be driven from your own controls.
var sign = signJS("sign", { sign: "W7-4B" }); sign.pause(); sign.seek(2.5); sign.play(); sign.on("sign", function (e) { console.log(e.code); });
Options reference
Every option has a default, so a sign works without settings. The playground generates the configuration for you.
| Option | Default | Description |
|---|---|---|
sign | "DIR-ROUNDABOUT" | The sign to show: a code from signJS.list(), a template with new legends such as { template: "R4-1B", legends: ["80"] }, or a sign exported from SignScribe Desktop. |
animate | true | false draws the sign still, at its finished face. |
mode | "single" | single shows one sign; sequence moves through signs, each one drawing out before the next draws in. |
signs | [] | The sign codes for sequence. Empty uses the whole library. |
motion.speed | 1 | Playback speed. 0 holds every sign still. |
motion.energy | 1 | How far a pictograph moves: 0 is the published artwork, 1 the designed motion. |
transition.intro | 1.7 | Seconds to draw a sign in: construction outlines first, then the colours. |
transition.outro | 1.0 | Seconds to draw a sign out before the next one replaces it. |
transition.draft | true | Show the construction outlines and centre lines while a sign draws in and out. |
sequence.hold | 5.5 | Seconds each sign holds in a sequence before it leaves. |
fit.padding | 0.08 | Space around the sign, as a fraction of the element. |
interactivity.click | "replay" | Clicking a single sign draws it in again. "none" turns it off. |
interactivity.hover | "none" | "play" animates the sign only while the cursor is over it. |
theme.mode | "auto" | Follows data-theme on the page, then the system setting, for the construction-line colour. The sign artwork does not change with the theme. |
performance.fps_limit | 60 | Frame rate cap. Animation pauses off screen, in background tabs and for visitors who ask for reduced motion. |
API reference
Functions on signJS, and methods on the instance that signJS() returns.
| Function | Description |
|---|---|
signJS(element, options) | Draws a sign in an element (or element id) and returns its instance. |
signJS.use(url) | Loads an extra sign package from a URL. Not needed for the signs in the downloaded file. Returns a promise. |
signJS.load(element, url) | Loads a sign.js package exported from SignScribe Desktop and draws it. |
signJS.register(package) | Registers an exported package you have already fetched. Returns its sign code. |
signJS.list(filter) | Lists the registered signs, optionally filtered by group name or function. |
signJS.get(code) | Returns one sign: code, name, group, size in millimetres and motion. |
signJS.legends(code) | Lists the legends of a template with their road series and capital height. |
signJS.colours(code) | Lists the colours used by a sign. |
signJS.edit(code, changes) | Registers a copy of a template with new legends or colours. Returns its code. |
signJS.svg(code) | Returns the finished sign face as an SVG in millimetres. |
signJS.package(code) | Returns a sign as a portable package for signJS.register. |
signJS.core.render(ctx, code, options) | Draws a sign into your own canvas context at time t, inside box. |
| Method | Description |
|---|---|
show(code) | Draws the current sign out and the given sign in. |
next() · prev() | Moves through a sequence. |
replay() | Draws the current sign in again. |
set(options) | Changes options on the running sign, such as { motion: { speed: 0.5 } }. |
pause() · play() · seek(seconds) | Controls playback. |
on(event, handler) | Listens for events; "sign" fires when a new sign starts. |
current() | Returns the sign being shown. |
export() | Returns the instance configuration. |
destroy() | Stops the sign and removes its canvas. |
sign.js 2.1.2
One JavaScript file with no dependencies. It contains the sign.js runtime, the 51 featured signs, the 126 SignScribe Desktop layouts and the 496 AS 1743 templates, so every sign on this page is available as soon as the file loads.
The runtime code is released under the MIT licence. The sign artwork, symbols and road lettering belong to SignScribe and may be used to display SignScribe signs.