Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 46 47 48 49 50 51 52 53 54 | import { invertColor } from '../util/color' /** * A transit Route, as defined in the input data. * Routes contain one or more Patterns. */ export default class Route { constructor(data) { for (const key in data) { if (key === 'patterns') continue this[key] = data[key] } this.patterns = [] } /** * Add Pattern * * @param {Pattern} */ addPattern(pattern) { this.patterns.push(pattern) pattern.route = this } /** * Rather than rely on the route text color field to be defined, simply return * the black or white inverse of the background color. */ getTextColor() { const bgColor = this.getColor() if (bgColor) return invertColor(bgColor) } getColor() { if (this.route_color) { if (this.route_color.charAt(0) === '#') return this.route_color return '#' + this.route_color } // assign a random shade of gray /* var c = 128 + Math.floor(64 * Math.random()); var hex = c.toString(16); hex = (hex.length === 1) ? '0' + hex : hex; this.route_color = '#' + hex + hex + hex; return this.route_color; */ } } |