forked from juliuste/svg-transit-map
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
45 lines (38 loc) · 777 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
'use strict'
const h = require('virtual-dom/virtual-hyperscript/svg')
const generate = require('./lib/generate')
const styles = h('style', {}, `
.line {
stroke: #333;
stroke-width: .09;
fill: none;
stroke-linejoin: round;
stroke-linecap: round;
}
.station {
stroke: none;
}
.transit {
stroke: #555;
stroke-width: .05;
fill: #fff;
}
`)
const generateWrapped = (graph, invertY) => {
const {items, bbox} = generate(graph, invertY)
// padding
const l = bbox.left - .5
const t = bbox.top - .5
const w = bbox.width + 1
const ht = bbox.height + 1
return h('svg', {
xmlns: 'http://www.w3.org/2000/svg',
width: w * 20,
height: ht * 20,
viewBox: [l, t, w, ht].join(' ')
}, [
styles,
h('g', items)
])
}
module.exports = generateWrapped