23 lines
1.3 KiB
JavaScript
23 lines
1.3 KiB
JavaScript
#!/usr/bin/env node
|
|
"use strict";
|
|
|
|
const fs = require("fs");
|
|
const path = require("path");
|
|
const { templateFor } = require("./lib/turn-lane-arrows");
|
|
|
|
const output = path.resolve(process.argv[2] || path.join("outputs", "turn-lane-arrow-samples.svg"));
|
|
const DISPLAY_SCALE = 60;
|
|
const samples = [{ id: "right", label: "right" }, { id: "through;right", label: "through;right" }];
|
|
const cells = samples.map((sample, index) => {
|
|
const x = 95 + index * 190;
|
|
const polygons = templateFor(sample.id).map((ring) => {
|
|
const points = ring.map(([right, forward]) => `${x + right * DISPLAY_SCALE},${185 - forward * DISPLAY_SCALE}`).join(" ");
|
|
return `<polygon points="${points}"/>`;
|
|
}).join("");
|
|
return `<g><rect x="${x - 70}" y="35" width="140" height="220"/><g class="arrow">${polygons}</g><text x="${x}" y="282">${sample.label}</text></g>`;
|
|
}).join("");
|
|
const svg = `<svg xmlns="http://www.w3.org/2000/svg" width="380" height="300" viewBox="0 0 380 300"><style>rect{fill:#555650}.arrow polygon{fill:#fffff6;stroke:#2b2b28;stroke-width:1.7;stroke-linejoin:round}text{fill:#2b2b28;font:14px sans-serif;text-anchor:middle}</style>${cells}</svg>\n`;
|
|
fs.mkdirSync(path.dirname(output), { recursive: true });
|
|
fs.writeFileSync(output, svg);
|
|
console.log(`TURN_LANE_ARROW_SAMPLES ${output}`);
|