-
-
Notifications
You must be signed in to change notification settings - Fork 310
/
Copy pathicon-gen.js
executable file
·68 lines (55 loc) · 1.57 KB
/
icon-gen.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/env node
const TextToSVG = require('text-to-svg');
const textToSVG = TextToSVG.loadSync('fonts/Px437_IBM_EGA8.otf');
const fs = require('fs');
if(!process.argv[2]) {
console.error("You need to specify a path to generate the svg files in as your argument");
process.exit(-1);
}
const path = (process.argv[2] || '.').replace(/\/$/, '');
var list = ["// This file is auto-generated from icon-gen in the root directory"];
const variationList = [
['black', '#000000'],
['grayLight', '#bbbbbb']
];
[
['[', 'left-brace'],
[']', 'right-brace'],
['[', 'left-brace'],
['-', 'hyphen'],
['\u25B2', 'arrow-up'],
['\u25Bc', 'arrow-down'],
['\u2591', 'shade-25'],
['\u2592', 'shade-50'],
['\u2593', 'shade-75'],
['\u2588', 'shade-100'],
['[\u25A0]', 'checkbox-checked'],
['[ ]', 'checkbox-unchecked'],
[`\u253c\u2584`, 'grid'],
['(\u2022)', 'radio-checked'],
['( )', 'radio-unchecked']
].forEach(row => {
let [str, string] = row;
for(const [name, hex] of variationList) {
let props = {
x: 0, y: 0,
fontSize: 16, anchor: 'top',
attributes: {fill: hex}
};
if (row.length > 3) {
props = Object.assign(props, row[3]);
}
if(name == 'grid') {
props.attributes.fill += '40';
}
const
svg = textToSVG.getSVG(str, props),
fullpath = `${path}/${string}-${name}.svg`
fs.writeFileSync(fullpath, svg);
console.log(fullpath);
}
//if(bsname) {
// list.push(`$${bsname}: url('data:image/svg+xml,${svg}');`);
//}
});
//fs.writeFileSync(`v4.4.1/scss/_autogen.scss`, list.join('\n'));