summaryrefslogtreecommitdiff
path: root/tools/genunits.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/genunits.js')
-rw-r--r--tools/genunits.js227
1 files changed, 227 insertions, 0 deletions
diff --git a/tools/genunits.js b/tools/genunits.js
new file mode 100644
index 0000000..4e0f30e
--- /dev/null
+++ b/tools/genunits.js
@@ -0,0 +1,227 @@
+const { units } = require("../data.js");
+const print = console.log;
+
+print(`<svg xmlns="http://www.w3.org/2000/svg" width="510" height="510" version="1.2" viewBox="0 0 510 510">
+<defs>
+
+<symbol id="font_1" overflow="visible">
+<path transform="scale(1,-1) translate(-.3333333 0)" d="M .49169923 .7285156 L .49169923 0 L .29052735 0 L .29052735 .47642518 C .25797526 .45183818 .22648113 .4319407 .19604492 .4167328 C .16560872 .40152488 .1274414 .3869629 .08154297 .37304688 L .08154297 .53515627 C .1492513 .5571289 .20182292 .5835317 .23925781 .6143646 C .27669273 .6451976 .3059896 .68324789 .32714845 .7285156 L .49169923 .7285156 Z "/>
+</symbol>
+
+<symbol id="font_2" overflow="visible">
+<path transform="scale(1,-1) translate(-.3333333 0)" d="M .6230469 0 L .026367188 0 C .033203126 .05891927 .053955079 .114339198 .08862305 .16625977 C .123291019 .21818035 .1883138 .27945964 .2836914 .35009767 C .34195964 .39339195 .37923179 .42626954 .3955078 .44873048 C .41178385 .4711914 .41992188 .49251304 .41992188 .5126953 C .41992188 .5345052 .41186524 .5531413 .39575196 .5686035 C .37963868 .58406576 .359375 .5917969 .33496095 .5917969 C .3095703 .5917969 .28881837 .5838928 .27270509 .5680847 C .2565918 .5522766 .24576824 .52437338 .24023438 .484375 L .041015626 .5003357 C .048828126 .5562439 .06315104 .59987899 .083984378 .63124087 C .10481771 .6626129 .13419597 .68666586 .17211914 .70339968 C .21004232 .7201436 .26253257 .7285156 .32958985 .7285156 C .3995768 .7285156 .45402018 .7205302 .49291993 .7045593 C .53181967 .68858847 .56241866 .6640625 .5847168 .63098147 C .60701498 .5979004 .61816409 .5608266 .61816409 .51976016 C .61816409 .47608949 .6053874 .43437196 .579834 .39460755 C .5542806 .35484315 .5078125 .3111979 .4404297 .26367188 C .40039063 .23600261 .37361656 .21663411 .36010743 .2055664 C .3465983 .1944987 .33072917 .18001302 .3125 .16210938 L .6230469 .16210938 L .6230469 0 Z "/>
+</symbol>
+
+<symbol id="font_3" overflow="visible">
+<path transform="scale(1,-1) translate(-.3333333 0)" d="M .23388672 .5097656 L .045898439 .5431061 C .061523439 .60296127 .091552738 .64882406 .13598633 .6806946 C .18041992 .71257528 .24332683 .7285156 .32470704 .7285156 C .4181315 .7285156 .4856771 .7110494 .52734377 .67611697 C .56901046 .6411845 .58984377 .5972748 .58984377 .5443878 C .58984377 .51337179 .5813802 .48529054 .5644531 .46014405 C .54752609 .43500773 .52197268 .41297404 .48779298 .39404298 C .5154622 .38720704 .5366211 .37923179 .55126956 .3701172 C .57503256 .35546876 .59350588 .33618165 .60668948 .31225587 C .61987307 .28833009 .62646487 .25976563 .62646487 .2265625 C .62646487 .18489583 .6155599 .14493816 .59375 .10668945 C .5719401 .06844076 .54052737 .03898112 .49951173 .018310547 C .4584961 -.0023600262 .4046224 -.0126953129 .33789063 -.0126953129 C .27278648 -.0126953129 .22143555 -.0050455729 .18383789 .010253906 C .14624024 .025553385 .11531576 .04793294 .09106445 .07739258 C .06681315 .10685221 .048177083 .1438802 .03515625 .18847656 L .23388672 .21484375 C .24169922 .17480469 .25382487 .14705403 .27026368 .1315918 C .28670249 .116129558 .3076172 .10839844 .3330078 .10839844 C .35970054 .10839844 .38191734 .11816406 .3996582 .13769531 C .41739909 .15722656 .42626954 .18326824 .42626954 .21582031 C .42626954 .24902344 .4177246 .2747396 .40063478 .29296876 C .38354493 .3111979 .36035157 .3203125 .3310547 .3203125 C .3154297 .3203125 .2939453 .31640626 .26660157 .30859376 L .27685548 .45069886 C .2879232 .44906108 .29654948 .4482422 .30273438 .4482422 C .32877604 .4482422 .35050456 .4565684 .36791993 .47322084 C .3853353 .48987327 .39404298 .5096283 .39404298 .53248599 C .39404298 .55436709 .38753257 .5718384 .37451173 .5848999 C .36149089 .5979614 .34358726 .6044922 .32080079 .6044922 C .29736329 .6044922 .2783203 .59748336 .26367188 .5834656 C .24902344 .5694478 .23909505 .54488119 .23388672 .5097656 Z "/>
+</symbol>
+
+<symbol id="font_4" overflow="visible">
+<path transform="scale(1,-1) translate(-.3333333 0)" d="M .3828125 .13378906 L .020507813 .13378906 L .020507813 .2975006 L .3828125 .7285156 L .55615237 .7285156 L .55615237 .28808595 L .6459961 .28808595 L .6459961 .13378906 L .55615237 .13378906 L .55615237 0 L .3828125 0 L .3828125 .13378906 M .3828125 .28808595 L .3828125 .5143585 L .19140625 .28808595 L .3828125 .28808595 Z "/>
+</symbol>
+
+<symbol id="font_6" overflow="visible">
+<path transform="scale(1,-1) translate(-.3333333 0)" d="M .6166992 .5548401 L .4189453 .53027346 C .41373698 .5581258 .4050293 .57778427 .39282228 .58924868 C .38061524 .6007131 .3655599 .6064453 .34765626 .6064453 C .3154297 .6064453 .2903646 .5901286 .27246095 .5574951 C .2594401 .5340068 .24983724 .4837545 .24365235 .40673829 C .26741538 .4308268 .29182945 .44864909 .31689454 .46020509 C .34195964 .47176109 .370931 .47753907 .4038086 .47753907 C .4676107 .47753907 .52156576 .45472718 .5656738 .4091034 C .6097819 .36348979 .63183596 .3056539 .63183596 .2355957 C .63183596 .18835449 .6206868 .1451823 .5983887 .1060791 C .5760905 .066975917 .545166 .037404378 .50561526 .017364502 C .46606446 -.0026753743 .4165039 -.0126953129 .3569336 -.0126953129 C .285319 -.0126953129 .22786458 -.00047302247 .18457031 .023971558 C .14127605 .048416139 .10668945 .08744812 .08081055 .1410675 C .05493164 .19468689 .041992189 .26566569 .041992189 .3540039 C .041992189 .48339845 .06917318 .5781657 .123535159 .63830569 C .17789714 .6984456 .25325523 .7285156 .34960938 .7285156 C .40657554 .7285156 .45157878 .72190859 .48461915 .70869448 C .5176595 .69549056 .54508468 .6761678 .56689456 .6507263 C .5887044 .62528488 .60530599 .59332278 .6166992 .5548401 M .25048829 .2355957 C .25048829 .19678752 .2602539 .16637166 .27978517 .14434815 C .2993164 .1223348 .3232422 .111328128 .3515625 .111328128 C .37760417 .111328128 .39941407 .121276859 .4169922 .14117432 C .4345703 .16107178 .44335938 .1907552 .44335938 .23022461 C .44335938 .27067057 .43424479 .30149333 .41601563 .32269288 C .39778648 .34389244 .37516276 .3544922 .34814454 .3544922 C .32047526 .3544922 .2972819 .34421794 .27856446 .32366944 C .25984703 .30312095 .25048829 .27376304 .25048829 .2355957 Z "/>
+</symbol>
+
+<symbol id="cv4">
+<use href="#font_4" transform="translate(25.5,11) rotate(0) scale(12)"/>
+<use href="#font_3" transform="translate(40,25.5) rotate(90) scale(12)"/>
+<use href="#font_2" transform="translate(25.5,40) rotate(180) scale(12)"/>
+<use href="#font_1" transform="translate(11,25.5) rotate(-90) scale(12)"/>
+</symbol>
+
+<symbol id="cv3">
+<use href="#font_3" transform="translate(25.5,11) rotate(0) scale(12)"/>
+<use href="#font_2" transform="translate(40,25.5) rotate(90) scale(12)"/>
+<use href="#font_1" transform="translate(25.5,40) rotate(180) scale(12)"/>
+</symbol>
+
+<symbol id="cv2">
+<use href="#font_2" transform="translate(25.5,11) rotate(0) scale(12)"/>
+<use href="#font_1" transform="translate(40,25.5) rotate(90) scale(12)"/>
+</symbol>
+
+<symbol id="cv1">
+<use href="#font_1" transform="translate(25.5,11) rotate(0) scale(12)"/>
+</symbol>
+
+<symbol id="cv3e">
+<use href="#font_6" transform="translate(25.5,11) rotate(0) scale(12)"/>
+<use href="#font_4" transform="translate(40,25.5) rotate(90) scale(12)"/>
+<use href="#font_2" transform="translate(25.5,40) rotate(180) scale(12)"/>
+</symbol>
+
+<symbol id="cv2e">
+<use href="#font_4" transform="translate(25.5,11) rotate(0) scale(12)"/>
+<use href="#font_2" transform="translate(40,25.5) rotate(90) scale(12)"/>
+</symbol>
+
+<symbol id="cv1e">
+<use href="#font_2" transform="translate(25.5,11) rotate(0) scale(12)"/>
+</symbol>
+
+</defs>
+<g font-family="Arial,Helvetica,sans-serif" font-weight="bold">`);
+
+SYMBOLS = {
+
+"armor": `
+<path fill="#ccc" stroke="#111" stroke-linejoin="round" stroke-width="1.5" d="M38.3 38.3H12.8V12.9h25.5zm0 0"/>
+<path fill="none" stroke="#111" stroke-width="1.5" d="M33.8 25.4c0 2.7-2.4 5-5.4 5h-5.7c-3 0-5.5-2.3-5.5-5s2.5-4.9 5.5-4.9h5.7c3 0 5.4 2.2 5.4 5zm0 0"/>
+`,
+
+"armor_elite": `
+<path fill="#ccc" stroke="#111" stroke-linejoin="round" stroke-width="1.5" d="M38.3 38.3H12.8V12.9h25.5zm0 0"/>
+<path fill="#a08672" stroke="#111" stroke-width="1.5" d="M33.8 25.4c0 2.7-2.4 5-5.4 5h-5.7c-3 0-5.5-2.3-5.5-5s2.5-4.9 5.5-4.9h5.7c3 0 5.4 2.2 5.4 5zm0 0"/>
+`,
+
+"armor_itank": `
+<path fill="#ccc" stroke="#111" stroke-linejoin="round" stroke-width="1.5" d="M38.3 38.3H12.8V12.9h25.5zm0 0"/>
+<path fill="none" stroke="#111" stroke-width="1.5" d="M34.1 25.4c0 2.7-2.4 4.9-5.4 4.9H23c-3 0-5.5-2.2-5.5-5 0-2.6 2.4-4.8 5.5-4.8h5.7c3 0 5.4 2.2 5.4 4.9zm0 0"/>
+<path fill="#111" d="M27.3 28.3h-3.4v-1h1v-3.8h-1v-1h3.4v1h-1v3.7h1zm0 0"/>
+`,
+
+"artillery": `
+<path fill="#ccc" stroke="#111" stroke-linejoin="round" stroke-width="1.5" d="M38.3 38.3H12.8V12.9h25.5zm0 0"/>
+<path fill="#111" d="M29.8 25.6c0 2.3-2 4.2-4.3 4.2a4.2 4.2 0 0 1-4.2-4.2 4.2 4.2 0 0 1 4.2-4.2c2.4 0 4.3 1.8 4.3 4.2"/>
+`,
+
+"infantry": `
+<path fill="#ccc" stroke="#111" stroke-linejoin="round" stroke-width="1.5" d="M38.3 38.3H12.8V12.9h25.5zm0 0"/>
+<path fill="none" stroke="#111" stroke-width="1.5" d="M12.8 12.8 38.3 38M38.2 13l-25.4 25"/>
+`,
+
+"mechanized_infantry": `
+<path fill="#ccc" stroke="#111" stroke-linejoin="round" stroke-width="1.5" d="M38.3 38.3H12.8V12.9h25.5zm0 0"/>
+<path fill="none" stroke="#111" stroke-width="1.5" d="M12.8 12.8 38.3 38M38.2 13l-25.4 25m21-12.5c0 2.7-2.4 5-5.4 5h-5.7c-3 0-5.5-2.3-5.5-5s2.5-4.9 5.5-4.9h5.7c3 0 5.4 2.2 5.4 5zm0 0"/>
+`,
+
+"mobile_antitank": `
+<path fill="#ccc" stroke="#111" stroke-linejoin="round" stroke-width="1.5" d="M38.3 38.3H12.8V12.9h25.5zm0 0"/>
+<path fill="none" stroke="#111" stroke-width="1.5" d="M33.8 25.4c0 2.7-2.4 5-5.4 5h-5.7c-3 0-5.5-2.3-5.5-5s2.5-4.9 5.5-4.9h5.7c3 0 5.4 2.2 5.4 5zm0 0"/>
+<path fill="#fff" stroke="#111" stroke-width="1.5" d="m25.9 13-9.6 24.9m9.3-25.1 9.1 25.4"/>
+`,
+
+"motorized_antitank_new": `
+<path fill="#ccc" stroke="#111" stroke-linejoin="round" stroke-width="1.5" d="M38.3 38.3H12.8V12.9h25.5zm0 0"/>
+<path fill="#fff" stroke="#111" stroke-width="1.5" d="m25.9 13-9.6 24.9m9.3-25.1 9.1 25.4"/>
+<path fill="#111" d="M23.8 34.8c0 1.3-1 2.3-2.4 2.3-1.3 0-2.4-1-2.4-2.3s1-2.3 2.4-2.3c1.3 0 2.4 1 2.4 2.3m8.2 0c0 1.3-1 2.3-2.4 2.3-1.3 0-2.4-1-2.4-2.3s1-2.3 2.4-2.3c1.3 0 2.4 1 2.4 2.3"/>
+`,
+
+"motorized_antitank_old": `
+<path fill="#ccc" stroke="#111" stroke-linejoin="round" stroke-width="1.5" d="M38.3 38.3H12.8V12.9h25.5zm0 0"/>
+<path fill="#fff" stroke="#111" stroke-width="1.5" d="m25.9 13-9.6 24.9m9.3-25.1 9.1 25.4"/>
+`,
+
+"motorized_infantry": `
+<path fill="#ccc" stroke="#111" stroke-linejoin="round" stroke-width="1.5" d="M38.3 38.3H12.8V12.9h25.5zm0 0"/>
+<path fill="none" stroke="#111" stroke-width="1.5" d="M12.8 12.8 38.3 38M38.2 13l-25.4 25"/>
+<path fill="#111" d="M23.7 34.7c0 1.3-1 2.4-2.4 2.4-1.3 0-2.4-1-2.4-2.4s1-2.3 2.4-2.3c1.3 0 2.4 1 2.4 2.3m8.2 0c0 1.3-1 2.4-2.4 2.4a2.3 2.3 0 1 1 0-4.7c1.4 0 2.4 1 2.4 2.3"/>
+`,
+
+"paratroopers": `
+<path fill="#ccc" stroke="#111" stroke-linejoin="round" stroke-width="1.5" d="M38.3 38.3H12.8V12.9h25.5zm0 0"/>
+<path fill="none" stroke="#111" stroke-width="1.5" d="M12.8 12.8 38.3 38M38.2 13l-25.4 25m12.6-1.5v-2c0-1 1-1.8 2.2-1.8 1.2 0 2.2.9 2.2 1.9v1.9m-8.8 0v-2c0-1 1-1.8 2.2-1.8 1.2 0 2.2.9 2.2 1.9v1.9"/>
+`,
+
+"recon": `
+<path fill="#ccc" stroke="#111" stroke-linejoin="round" stroke-width="1.5" d="M38.3 38.3H12.8V12.9h25.5zm0 0"/>
+<path fill="none" stroke="#111" stroke-width="1.5" d="M33.8 25.4c0 2.7-2.4 5-5.4 5h-5.7c-3 0-5.5-2.3-5.5-5s2.5-4.9 5.5-4.9h5.7c3 0 5.4 2.2 5.4 5zM38.2 13l-25.4 25"/>
+`,
+
+"self_propelled_artillery": `
+<path fill="#ccc" stroke="#111" stroke-linejoin="round" stroke-width="1.5" d="M38.3 38.3H12.8V12.8h25.5zm0 0"/>
+<path fill="none" stroke="#111" stroke-width="1.5" d="M33.8 25.5c0 2.7-2.4 5-5.4 5h-5.7c-3 0-5.5-2.3-5.5-5s2.4-4.9 5.5-4.9h5.7c3 0 5.4 2.2 5.4 5zm0 0"/>
+<path fill="#111" d="M29 25.5a3.4 3.4 0 0 1-3.5 3.4 3.4 3.4 0 0 1-3.4-3.4 3.4 3.4 0 0 1 3.4-3.4 3.4 3.4 0 0 1 3.4 3.4"/>
+`,
+
+}
+
+const TYPEMAP = {
+ "armor": "armor",
+ "artillery": "artillery",
+ "i-tank": "armor_itank",
+ "infantry": "infantry",
+ "mech. inf.": "mechanized_infantry",
+ "mob. a/t": "mobile_antitank",
+ "mot. a/t": "motorized_antitank_new",
+ "mot. inf.": "motorized_infantry",
+ "para": "paratroopers",
+ "recon": "recon",
+ "self prop. arty": "self_propelled_artillery",
+};
+
+// 94 units
+
+let smcp = /(IN|AU|NZ|SA|AT|H|G)$/;
+smcp = /NEVER/;
+
+const COLORMAP = {
+ "italian": "#b0c5d4",
+ "german": "#f9e3b3",
+ "allied": "#cead78",
+ "Pol": "#ffffff",
+ "FF": "#8197cd",
+ "NZ": "#95c3d6",
+ "AU": "#f48480",
+ "SA": "#f9a64a",
+ "IN": "#84c88b",
+}
+
+const BLACK = {
+ italian: "#221f1f",
+ german: "#004e2f",
+ allied: "#5c3a1e"
+}
+
+let x = 0, y = 0;
+for (let u of units) {
+ let type = TYPEMAP[u.type];
+ let black = BLACK[u.nationality];
+ let fill = COLORMAP[u.nationality];
+
+ let [a, b] = u.name.split('/');
+ if (b)
+ b = b.split('+');
+
+ for (let n in COLORMAP)
+ if (a.endsWith(n) || (b && b[0] === n))
+ fill = COLORMAP[n];
+
+ print(`<g transform="translate(${x},${y})">`);
+
+ if (type === 'armor' && u.elite && u.nationality === 'allied')
+ type = 'armor_elite';
+
+ let symbol = SYMBOLS[type];
+ print(symbol.replace(/#ccc/g, fill).replace(/#111/g, black).trim());
+
+ if (u.elite)
+ print(`<use href="#cv${u.steps}e" fill="${black}"/>`);
+ else
+ print(`<use href="#cv${u.steps}" fill="${black}"/>`);
+
+ print(`<g fill="${black}">`);
+ print(`<text text-anchor="start" font-size="7" x="2" y="8">${u.appearance}</text>`);
+ print(`<text text-anchor="start" font-size="7" x="2" y="48">${a}</text>`);
+
+ if (b) {
+ if (b.length > 1) {
+ print(`<text text-anchor="end" font-size="7" x="49" y="43">${b[0]}</text>`);
+ print(`<text text-anchor="end" font-size="7" x="49" y="49">${b[1]}</text>`);
+ } else {
+ print(`<text text-anchor="end" font-size="7" x="48" y="48">${b[0]}</text>`);
+ }
+ }
+
+ print(`</g>`);
+ print(`</g>`);
+ x += 51;
+ if (x >= 510) {
+ y += 51;
+ x = 0;
+ }
+}
+print(`</g>`);
+print(`</svg>`);