Skip to content

Commit d4aed84

Browse files
committed
Merge branch 'master' into main
2 parents 502098b + ae05e1f commit d4aed84

File tree

12 files changed

+644
-372
lines changed

12 files changed

+644
-372
lines changed

data/icons.json

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -670,6 +670,12 @@
670670
"information"
671671
]
672672
},
673+
"cloth": {
674+
"groups": [
675+
"clothes",
676+
"home"
677+
]
678+
},
673679
"clothes_hanger": {
674680
"groups": [
675681
"clothes"
@@ -794,6 +800,11 @@
794800
"home"
795801
]
796802
},
803+
"detergent_bottle": {
804+
"groups": [
805+
"home"
806+
]
807+
},
797808
"diamond": {
798809
"groups": [
799810
"highways",
@@ -888,6 +899,12 @@
888899
"sports"
889900
]
890901
},
902+
"fighter_jet": {
903+
"groups": [
904+
"aeroways",
905+
"vehicles"
906+
]
907+
},
891908
"fire_hydrant": {
892909
"groups": [
893910
"water"
@@ -1231,6 +1248,12 @@
12311248
"water"
12321249
]
12331250
},
1251+
"latrine": {
1252+
"groups": [
1253+
"buildings",
1254+
"camping"
1255+
]
1256+
},
12341257
"laundry": {
12351258
"groups": [
12361259
"home",
@@ -1799,6 +1822,12 @@
17991822
"snow"
18001823
]
18011824
},
1825+
"sailboat": {
1826+
"groups": [
1827+
"vehicles",
1828+
"water"
1829+
]
1830+
},
18021831
"sailing": {
18031832
"groups": [
18041833
"sports",
@@ -2201,6 +2230,12 @@
22012230
"sports"
22022231
]
22032232
},
2233+
"tents": {
2234+
"groups": [
2235+
"buildings",
2236+
"camping"
2237+
]
2238+
},
22042239
"ticket": {
22052240
"groups": [
22062241
"information"
@@ -2551,6 +2586,12 @@
25512586
"water"
25522587
]
25532588
},
2589+
"water_bottle": {
2590+
"groups": [
2591+
"food",
2592+
"water"
2593+
]
2594+
},
25542595
"water_device": {
25552596
"groups": [
25562597
"utilities",

dist/temaki-symbol.svg

Lines changed: 24 additions & 0 deletions
Loading

dist/temaki-view.svg

Lines changed: 383 additions & 359 deletions
Loading

docs/index.html

Lines changed: 88 additions & 1 deletion
Large diffs are not rendered by default.

icons/cloth.svg

Lines changed: 6 additions & 0 deletions
Loading

icons/detergent_bottle.svg

Lines changed: 5 additions & 0 deletions
Loading

icons/fighter_jet.svg

Lines changed: 4 additions & 0 deletions
Loading

icons/latrine.svg

Lines changed: 5 additions & 0 deletions
Loading

icons/sailboat.svg

Lines changed: 6 additions & 0 deletions
Loading

icons/tents.svg

Lines changed: 5 additions & 0 deletions
Loading

icons/water_bottle.svg

Lines changed: 7 additions & 0 deletions
Loading

scripts/check.js

Lines changed: 70 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,49 @@ function ellipseAttrsToPathD(rx, cx, ry, cy) {
1010
return `M${cx - rx},${cy}a${rx},${ry} 0 1,0 ${rx * 2},0a${rx},${ry} 0 1,0 -${rx * 2},0z`;
1111
}
1212

13+
// https://github.com/elrumordelaluz/element-to-path/blob/master/src/index.js
14+
function rectAttrsToPathD(attrs) {
15+
const w = parseFloat(attrs('width'));
16+
const h = parseFloat(attrs('height'));
17+
const x = attrs('x') ? parseFloat(attrs('x')) : 0;
18+
const y = attrs('y') ? parseFloat(attrs('y')) : 0;
19+
let rx = attrs('rx') || 'auto';
20+
let ry = attrs('ry') || 'auto';
21+
if (rx === 'auto' && ry === 'auto') {
22+
rx = ry = 0;
23+
} else if (rx !== 'auto' && ry === 'auto') {
24+
rx = ry = calcValue(rx, w);
25+
} else if (ry !== 'auto' && rx === 'auto') {
26+
ry = rx = calcValue(ry, h);
27+
} else {
28+
rx = calcValue(rx, w);
29+
ry = calcValue(ry, h);
30+
}
31+
if (rx > w / 2) {
32+
rx = w / 2;
33+
}
34+
if (ry > h / 2) {
35+
ry = h / 2;
36+
}
37+
const hasCurves = rx > 0 && ry > 0;
38+
return [
39+
`M${x + rx} ${y}`,
40+
`H${x + w - rx}`,
41+
(hasCurves ? `A${rx} ${ry} 0 0 1 ${x + w} ${y + ry}` : ''),
42+
`V${y + h - ry}`,
43+
(hasCurves ? `A${rx} ${ry} 0 0 1 ${x + w - rx} ${y + h}` : ''),
44+
`H${x + rx}`,
45+
(hasCurves ? `A${rx} ${ry} 0 0 1 ${x} ${y + h - ry}` : ''),
46+
`V${y + ry}`,
47+
(hasCurves ? `A${rx} ${ry} 0 0 1 ${x + rx} ${y}` : ''),
48+
'z',
49+
].filter(Boolean).join('');
50+
51+
function calcValue(val, base) {
52+
return /%$/.test(val) ? (val.replace('%', '') * 100) / base : parseFloat(val);
53+
}
54+
}
55+
1356
function checkIcons() {
1457
const START = '✅ ' + colors.yellow('Checking icons...');
1558
const END = '👍 ' + colors.green('done');
@@ -38,6 +81,7 @@ function checkIcons() {
3881
let warnings = [];
3982

4083
let childrenToRemove = new Set();
84+
let pathDataToAdd = new Set();
4185

4286
xml.each((child, index, level) => {
4387
const node = child.node;
@@ -73,37 +117,40 @@ function checkIcons() {
73117
// convert ellipses to paths
74118
if (node.nodeName === 'ellipse') {
75119
const attr = (name) => parseFloat(node.getAttribute(name));
76-
child.up().ele('path', {
77-
d: ellipseAttrsToPathD(attr('rx'), attr('cx'), attr('ry'), attr('cy'))
78-
});
120+
pathDataToAdd.add(ellipseAttrsToPathD(attr('rx'), attr('cx'), attr('ry'), attr('cy')));
121+
childrenToRemove.add(child);
122+
return;
123+
124+
// convert rects to paths
125+
} else if (node.nodeName === 'rect') {
126+
const attr = (name) => node.getAttribute(name);
127+
pathDataToAdd.add(rectAttrsToPathD(attr));
79128
childrenToRemove.add(child);
80129
return;
81130

82131
// convert polygons to paths
83132
} else if (node.nodeName === 'polygon') {
84-
child.up().ele('path', {
85-
d: 'M ' + node.getAttribute('points') + 'z'
86-
});
133+
pathDataToAdd.add('M ' + node.getAttribute('points') + 'z');
87134
childrenToRemove.add(child);
88135
return;
89136
// remove metadata nodes
90137
} else if (node.nodeName === 'title' || node.nodeName === 'desc') {
91138
childrenToRemove.add(child);
92139
return;
140+
} else if (node.nodeName === 'g') {
141+
// groups will be emptied so remove them
142+
childrenToRemove.add(child);
143+
return;
93144
}
94145

95146
if (level > 2) {
96147
let parent = child.up();
97148
if (parent.node.nodeName === 'g') {
98149
// move the node out of the group
99-
parent.up().ele(child.toString());
150+
pathDataToAdd.add(child.toString());
100151
childrenToRemove.add(child);
101152
}
102-
} else if (level === 2 && node.nodeName === 'g') {
103-
// groups will be emptied so remove them
104-
childrenToRemove.add(child);
105-
return;
106-
}
153+
}
107154

108155
// suspicious elements
109156
if (node.nodeName !== 'path') {
@@ -133,6 +180,17 @@ function checkIcons() {
133180
child.remove();
134181
});
135182

183+
Array.from(pathDataToAdd).forEach((pathData) => {
184+
if (pathData[0] === '<') {
185+
xml.root().ele(pathData);
186+
} else {
187+
xml.root().ele('path', {
188+
d: pathData
189+
});
190+
}
191+
});
192+
193+
136194
if (warnings.length) {
137195
warnings.forEach(w => console.warn(w));
138196
console.warn(' in ' + file);

0 commit comments

Comments
 (0)