mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 01:41:22 +01:00
v1.5.17 - further optimization
This commit is contained in:
parent
2fa5a4f847
commit
6a1f17b597
2 changed files with 77 additions and 67 deletions
94
index.html
94
index.html
|
|
@ -205,13 +205,6 @@
|
|||
<g id="defs-emblems"></g>
|
||||
</g>
|
||||
|
||||
<g id="defs-icons">
|
||||
<symbol id="icon-anchor" viewBox="0 0 30 28">
|
||||
<title>Port</title>
|
||||
<path d="M15 4c0-0.547-0.453-1-1-1s-1 0.453-1 1 0.453 1 1 1 1-0.453 1-1zM28 18.5v5.5c0 0.203-0.125 0.391-0.313 0.469-0.063 0.016-0.125 0.031-0.187 0.031-0.125 0-0.25-0.047-0.359-0.141l-1.453-1.453c-2.453 2.953-6.859 4.844-11.688 4.844s-9.234-1.891-11.688-4.844l-1.453 1.453c-0.094 0.094-0.234 0.141-0.359 0.141-0.063 0-0.125-0.016-0.187-0.031-0.187-0.078-0.313-0.266-0.313-0.469v-5.5c0-0.281 0.219-0.5 0.5-0.5h5.5c0.203 0 0.391 0.125 0.469 0.313s0.031 0.391-0.109 0.547l-1.563 1.563c1.406 1.891 4.109 3.266 7.203 3.687v-10.109h-3c-0.547 0-1-0.453-1-1v-2c0-0.547 0.453-1 1-1h3v-2.547c-1.188-0.688-2-1.969-2-3.453 0-2.203 1.797-4 4-4s4 1.797 4 4c0 1.484-0.812 2.766-2 3.453v2.547h3c0.547 0 1 0.453 1 1v2c0 0.547-0.453 1-1 1h-3v10.109c3.094-0.422 5.797-1.797 7.203-3.687l-1.563-1.563c-0.141-0.156-0.187-0.359-0.109-0.547s0.266-0.313 0.469-0.313h5.5c0.281 0 0.5 0.219 0.5 0.5z"></path>
|
||||
</symbol>
|
||||
</g>
|
||||
|
||||
<g id="defs-markers">
|
||||
<symbol id="marker0" viewBox="0 0 30 30">
|
||||
<path d="M6,19 l9,10 L24,19" fill="#000000" stroke="none"></path>
|
||||
|
|
@ -223,46 +216,6 @@
|
|||
<pattern id="oceanic" width="100" height="100" patternUnits="userSpaceOnUse">
|
||||
<rect id="oceanicPattern" width='100' height='100' filter="url(#pattern1)" opacity='0.2'/>
|
||||
</pattern>
|
||||
|
||||
<g id="rose" stroke-width="1">
|
||||
<g id="sL" stroke="#3f3f3f">
|
||||
<line id="sL1" x1="0" y1="-20000" x2="0" y2="20000"/>
|
||||
<line id="sL2" x1="-20000" y1="0" x2="20000" y2="0"/>
|
||||
</g>
|
||||
<use href="#sL" transform="rotate(45)"/>
|
||||
<use href="#sL" transform="rotate(22.5)"/>
|
||||
<use href="#sL" transform="rotate(-22.5)"/>
|
||||
<use href="#sL" transform="rotate(11.25)"/>
|
||||
<use href="#sL" transform="rotate(-11.25)"/>
|
||||
<use href="#sL" transform="rotate(56.25)"/>
|
||||
<use href="#sL" transform="rotate(-56.25)"/>
|
||||
<g stroke-width="8" stroke-opacity="1" shape-rendering="geometricprecision">
|
||||
<circle r="9" stroke="#000000" fill="#1b1b1b"/>
|
||||
<circle r="75" stroke="#008000" fill="#ffffff" fill-opacity=".1"></circle>
|
||||
<circle r="212" stroke="#1b1b1b"></circle>
|
||||
<circle r="211" stroke="#008000" fill="#ffffff" fill-opacity=".1"></circle>
|
||||
</g>
|
||||
<g stroke="#1b1b1b" stroke-opacity="1" shape-rendering="geometricprecision">
|
||||
<circle r="71"/>
|
||||
<circle r="79"/>
|
||||
<circle r="94"/>
|
||||
<circle r="152"/>
|
||||
<circle r="164"/>
|
||||
<circle r="207"/>
|
||||
</g>
|
||||
<g id="s3" stroke-opacity="1" shape-rendering="geometricprecision">
|
||||
<g id="s2">
|
||||
<g id="s1" stroke="#1b1b1b">
|
||||
<path d="M 39.416,95.16 C 33.65,103.95 30.76,110.5 28.93,117.18 C 15.24,113.43 13.54,127.15 23.04,131 C 13.71,145.8 7.84,173.93 0,212 L 0,103 A 103,103 0 0,0 39.416,95.16 z" fill="#47a3d1"/>
|
||||
<path d="M 39.416,95.16 C 33.65,103.95 30.76,110.5 28.93,117.18 C 15.24,113.43 13.54,127.15 23.04,131 C 13.71,145.8 7.84,173.93 0,212 L 0,103 A 103,103 0 0,0 39.416,95.16 z" fill="black" transform="scale(-1,1)"/>
|
||||
<path d="M -31.995,160.849 A 164,164 0 0,0 31.995,160.849 C 18.9,170.1 8.4,176.3 0,207 C -8.4,176.3 -18.9,170.1 -31.995,160.849 z" fill="#c2390f" transform="rotate(22.5)"/>
|
||||
</g>
|
||||
<use href="#s1" transform="rotate(45)"/>
|
||||
</g>
|
||||
<use href="#s2" transform="rotate(90)"/>
|
||||
</g>
|
||||
<use href="#s3" transform="scale(-1)"/>
|
||||
</g>
|
||||
</defs>
|
||||
<g id="viewbox"></g>
|
||||
<g id="scaleBar"></g>
|
||||
|
|
@ -3322,7 +3275,7 @@
|
|||
</div>
|
||||
|
||||
<!-- svg elements not required for map display -->
|
||||
<svg width="0" height="0" style="position: absolute">
|
||||
<svg id="defElements" width="0" height="0" style="position: absolute">
|
||||
<defs>
|
||||
<marker id="end-arrow" viewBox="0 -5 10 10" refX="6" markerWidth="7" markerHeight="7" orient="auto">
|
||||
<path d="M0,-5L10,0L0,5" fill="#000"></path>
|
||||
|
|
@ -3332,6 +3285,11 @@
|
|||
<path d="M602 118.6L537.1 15C531.3 5.7 521 0 510 0H106C95 0 84.7 5.7 78.9 15L14 118.6c-33.5 53.5-3.8 127.9 58.8 136.4 4.5.6 9.1.9 13.7.9 29.6 0 55.8-13 73.8-33.1 18 20.1 44.3 33.1 73.8 33.1 29.6 0 55.8-13 73.8-33.1 18 20.1 44.3 33.1 73.8 33.1 29.6 0 55.8-13 73.8-33.1 18.1 20.1 44.3 33.1 73.8 33.1 4.7 0 9.2-.3 13.7-.9 62.8-8.4 92.6-82.8 59-136.4zM529.5 288c-10 0-19.9-1.5-29.5-3.8V384H116v-99.8c-9.6 2.2-19.5 3.8-29.5 3.8-6 0-12.1-.4-18-1.2-5.6-.8-11.1-2.1-16.4-3.6V480c0 17.7 14.3 32 32 32h448c17.7 0 32-14.3 32-32V283.2c-5.4 1.6-10.8 2.9-16.4 3.6-6.1.8-12.1 1.2-18.2 1.2z"></path>
|
||||
</symbol>
|
||||
|
||||
<symbol id="icon-anchor" viewBox="0 0 30 28">
|
||||
<title>Port</title>
|
||||
<path d="M15 4c0-0.547-0.453-1-1-1s-1 0.453-1 1 0.453 1 1 1 1-0.453 1-1zM28 18.5v5.5c0 0.203-0.125 0.391-0.313 0.469-0.063 0.016-0.125 0.031-0.187 0.031-0.125 0-0.25-0.047-0.359-0.141l-1.453-1.453c-2.453 2.953-6.859 4.844-11.688 4.844s-9.234-1.891-11.688-4.844l-1.453 1.453c-0.094 0.094-0.234 0.141-0.359 0.141-0.063 0-0.125-0.016-0.187-0.031-0.187-0.078-0.313-0.266-0.313-0.469v-5.5c0-0.281 0.219-0.5 0.5-0.5h5.5c0.203 0 0.391 0.125 0.469 0.313s0.031 0.391-0.109 0.547l-1.563 1.563c1.406 1.891 4.109 3.266 7.203 3.687v-10.109h-3c-0.547 0-1-0.453-1-1v-2c0-0.547 0.453-1 1-1h3v-2.547c-1.188-0.688-2-1.969-2-3.453 0-2.203 1.797-4 4-4s4 1.797 4 4c0 1.484-0.812 2.766-2 3.453v2.547h3c0.547 0 1 0.453 1 1v2c0 0.547-0.453 1-1 1h-3v10.109c3.094-0.422 5.797-1.797 7.203-3.687l-1.563-1.563c-0.141-0.156-0.187-0.359-0.109-0.547s0.266-0.313 0.469-0.313h5.5c0.281 0 0.5 0.219 0.5 0.5z"></path>
|
||||
</symbol>
|
||||
|
||||
<g id="oceanPatterns">
|
||||
<filter id='emptyImage'></filter>
|
||||
<filter id='mottling'>
|
||||
|
|
@ -3931,6 +3889,46 @@
|
|||
</symbol>
|
||||
</g>
|
||||
|
||||
<g id="rose" stroke-width="1">
|
||||
<g id="sL" stroke="#3f3f3f">
|
||||
<line id="sL1" x1="0" y1="-20000" x2="0" y2="20000"/>
|
||||
<line id="sL2" x1="-20000" y1="0" x2="20000" y2="0"/>
|
||||
</g>
|
||||
<use href="#sL" transform="rotate(45)"/>
|
||||
<use href="#sL" transform="rotate(22.5)"/>
|
||||
<use href="#sL" transform="rotate(-22.5)"/>
|
||||
<use href="#sL" transform="rotate(11.25)"/>
|
||||
<use href="#sL" transform="rotate(-11.25)"/>
|
||||
<use href="#sL" transform="rotate(56.25)"/>
|
||||
<use href="#sL" transform="rotate(-56.25)"/>
|
||||
<g stroke-width="8" stroke-opacity="1" shape-rendering="geometricprecision">
|
||||
<circle r="9" stroke="#000000" fill="#1b1b1b"/>
|
||||
<circle r="75" stroke="#008000" fill="#ffffff" fill-opacity=".1"></circle>
|
||||
<circle r="212" stroke="#1b1b1b"></circle>
|
||||
<circle r="211" stroke="#008000" fill="#ffffff" fill-opacity=".1"></circle>
|
||||
</g>
|
||||
<g stroke="#1b1b1b" stroke-opacity="1" shape-rendering="geometricprecision">
|
||||
<circle r="71"/>
|
||||
<circle r="79"/>
|
||||
<circle r="94"/>
|
||||
<circle r="152"/>
|
||||
<circle r="164"/>
|
||||
<circle r="207"/>
|
||||
</g>
|
||||
<g id="s3" stroke-opacity="1" shape-rendering="geometricprecision">
|
||||
<g id="s2">
|
||||
<g id="s1" stroke="#1b1b1b">
|
||||
<path d="M 39.416,95.16 C 33.65,103.95 30.76,110.5 28.93,117.18 C 15.24,113.43 13.54,127.15 23.04,131 C 13.71,145.8 7.84,173.93 0,212 L 0,103 A 103,103 0 0,0 39.416,95.16 z" fill="#47a3d1"/>
|
||||
<path d="M 39.416,95.16 C 33.65,103.95 30.76,110.5 28.93,117.18 C 15.24,113.43 13.54,127.15 23.04,131 C 13.71,145.8 7.84,173.93 0,212 L 0,103 A 103,103 0 0,0 39.416,95.16 z" fill="black" transform="scale(-1,1)"/>
|
||||
<path d="M -31.995,160.849 A 164,164 0 0,0 31.995,160.849 C 18.9,170.1 8.4,176.3 0,207 C -8.4,176.3 -18.9,170.1 -31.995,160.849 z" fill="#c2390f" transform="rotate(22.5)"/>
|
||||
</g>
|
||||
<use href="#s1" transform="rotate(45)"/>
|
||||
</g>
|
||||
<use href="#s2" transform="rotate(90)"/>
|
||||
</g>
|
||||
<use href="#s3" transform="scale(-1)"/>
|
||||
</g>
|
||||
|
||||
<g id="coas"></g>
|
||||
</defs>
|
||||
</svg>
|
||||
|
|
|
|||
|
|
@ -81,7 +81,8 @@ async function getMapURL(type, subtype) {
|
|||
const clone = d3.select(cloneEl);
|
||||
clone.select("#debug").remove();
|
||||
|
||||
const defs = cloneEl.getElementsByTagName("defs")[0];
|
||||
const cloneDefs = cloneEl.getElementsByTagName("defs")[0];
|
||||
const svgDefs = document.getElementById("defElements");
|
||||
|
||||
const isFirefox = navigator.userAgent.toLowerCase().indexOf('firefox') > -1;
|
||||
if (isFirefox && type === "mesh") clone.select("#oceanPattern").remove();
|
||||
|
|
@ -96,17 +97,6 @@ async function getMapURL(type, subtype) {
|
|||
if (customization && type === "mesh") updateMeshCells(clone);
|
||||
inlineStyle(clone);
|
||||
|
||||
// add displayed emblems
|
||||
if (layerIsOn("toggleEmblems")) {
|
||||
const defs = cloneEl.getElementById("defs-emblems") || cloneEl.getElementById("deftemp");
|
||||
clone.selectAll("#emblems use").each(function() {
|
||||
const href = this.getAttribute("href");
|
||||
if (!href) return;
|
||||
const emblem = document.getElementById(href.slice(1)).cloneNode(true); // clone emblem
|
||||
defs.append(emblem);
|
||||
});
|
||||
}
|
||||
|
||||
// remove unused filters
|
||||
const filters = cloneEl.querySelectorAll("filter");
|
||||
for (let i=0; i < filters.length; i++) {
|
||||
|
|
@ -132,10 +122,22 @@ async function getMapURL(type, subtype) {
|
|||
symbols[i].remove();
|
||||
}
|
||||
|
||||
// add displayed emblems
|
||||
if (layerIsOn("toggleEmblems")) {
|
||||
Array.from(cloneEl.getElementById("emblems").querySelectorAll("use")).forEach(el => {
|
||||
const href = el.getAttribute("href");
|
||||
if (!href) return;
|
||||
const emblem = document.getElementById(href.slice(1)).cloneNode(true); // clone emblem
|
||||
cloneDefs.append(emblem);
|
||||
});
|
||||
}
|
||||
|
||||
// add ocean pattern
|
||||
const patternId = cloneEl.getElementById("oceanicPattern").getAttribute("filter").slice(5,-1);
|
||||
const pattern = document.getElementById(patternId);
|
||||
if (patternId) defs.appendChild(pattern.cloneNode(true));
|
||||
if (cloneEl.getElementById("oceanicPattern")) {
|
||||
const patternId = cloneEl.getElementById("oceanicPattern").getAttribute("filter").slice(5,-1);
|
||||
const pattern = svgDefs.getElementById(patternId);
|
||||
if (patternId) cloneDefs.appendChild(pattern.cloneNode(true));
|
||||
}
|
||||
|
||||
// add relief icons
|
||||
if (cloneEl.getElementById("terrain")) {
|
||||
|
|
@ -145,16 +147,26 @@ async function getMapURL(type, subtype) {
|
|||
uniqueElements.add(terrainElements[i].getAttribute("href"));
|
||||
}
|
||||
|
||||
const defsRelief = document.getElementById("defs-relief");
|
||||
const defsRelief = svgDefs.getElementById("defs-relief");
|
||||
for (const terrain of [...uniqueElements]) {
|
||||
const element = defsRelief.querySelector(terrain);
|
||||
if (element) defs.appendChild(element.cloneNode(true));
|
||||
if (element) cloneDefs.appendChild(element.cloneNode(true));
|
||||
}
|
||||
}
|
||||
|
||||
// add wind rose
|
||||
if (cloneEl.getElementById("compass")) {
|
||||
const rose = svgDefs.getElementById("rose");
|
||||
if (rose) cloneDefs.appendChild(rose.cloneNode(true));
|
||||
}
|
||||
|
||||
// add port icon
|
||||
if (cloneEl.getElementById("anchors")) {
|
||||
const anchor = svgDefs.getElementById("icon-anchor");
|
||||
if (anchor) cloneDefs.appendChild(anchor.cloneNode(true));
|
||||
}
|
||||
|
||||
if (!cloneEl.getElementById("hatching").children.length) cloneEl.getElementById("hatching").remove(); //remove unused hatching group
|
||||
if (!cloneEl.getElementById("defs-icons").children.length) cloneEl.getElementById("defs-icons").remove(); //remove unused icons group
|
||||
if (!cloneEl.getElementById("compass")) cloneEl.getElementById("rose").remove(); //remove unused rose
|
||||
if (!cloneEl.getElementById("fogging-cont")) cloneEl.getElementById("fog").remove(); //remove unused fog
|
||||
if (!cloneEl.getElementById("regions")) cloneEl.getElementById("statePaths").remove(); // removed unused statePaths
|
||||
if (!cloneEl.getElementById("labels")) cloneEl.getElementById("textPaths").remove(); // removed unused textPaths
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue