mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-16 17:31:24 +01:00
v. 0.559
Some fixes
This commit is contained in:
parent
750003a280
commit
9bd3d5aba2
6 changed files with 24 additions and 23 deletions
BIN
index.css
BIN
index.css
Binary file not shown.
12
index.html
12
index.html
|
|
@ -22,14 +22,14 @@
|
|||
<script src="libs/jquery-3.1.1.min.js"></script>
|
||||
<script src="libs/d3.v4.min.js"></script>
|
||||
<script src="libs/d3-scale-chromatic.v1.min.js"></script>
|
||||
<script src="libs/priority-queue.js"></script>
|
||||
<script src="libs/priority-queue.min.js"></script>
|
||||
<script src="names.js"></script>
|
||||
<script src="libs/jquery-ui.min.js"></script>
|
||||
<script src="libs/polylabel.js"></script>
|
||||
<script src="libs/quantize.js" defer></script>
|
||||
<script src="libs/polylabel.min.js"></script>
|
||||
<script src="libs/quantize.min.js" defer></script>
|
||||
<script src="libs/d3-hexbin.v0.2.min.js" defer></script>
|
||||
<link rel="stylesheet" type="text/css" href="index.css?version=0.558b"/>
|
||||
<link rel="stylesheet" type="text/css" href="icons.css?version=0.558b"/>
|
||||
<link rel="stylesheet" type="text/css" href="index.css?version=0.559b"/>
|
||||
<link rel="stylesheet" type="text/css" href="icons.css?version=0.559b"/>
|
||||
<link rel="stylesheet" type="text/css" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"/>
|
||||
</head>
|
||||
<body class="fullscreen">
|
||||
|
|
@ -761,5 +761,5 @@
|
|||
Type: <span id="feature">no</span>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript" src="script.js?version=0.558b"></script>
|
||||
<script type="text/javascript" src="script.js?version=0.559b"></script>
|
||||
</body>
|
||||
1
libs/polylabel.min.js
vendored
Normal file
1
libs/polylabel.min.js
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).polylabel=t()}}(function(){return function t(n,e,r){function o(a,u){if(!e[a]){if(!n[a]){var f="function"==typeof require&&require;if(!u&&f)return f(a,!0);if(i)return i(a,!0);var h=new Error("Cannot find module '"+a+"'");throw h.code="MODULE_NOT_FOUND",h}var s=e[a]={exports:{}};n[a][0].call(s.exports,function(t){var e=n[a][1][t];return o(e||t)},s,s.exports,t,n,e,r)}return e[a].exports}for(var i="function"==typeof require&&require,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(t,n,e){"use strict";var r=t("tinyqueue");function o(t,n){return n.max-t.max}function i(t,n,e,r){this.x=t,this.y=n,this.h=e,this.d=function(t,n,e){for(var r=!1,o=1/0,i=0;i<e.length;i++)for(var u=e[i],f=0,h=u.length,s=h-1;f<h;s=f++){var d=u[f],l=u[s];d[1]>n!=l[1]>n&&t<(l[0]-d[0])*(n-d[1])/(l[1]-d[1])+d[0]&&(r=!r),o=Math.min(o,a(t,n,d,l))}return(r?1:-1)*Math.sqrt(o)}(t,n,r),this.max=this.d+this.h*Math.SQRT2}function a(t,n,e,r){var o=e[0],i=e[1],a=r[0]-o,u=r[1]-i;if(0!==a||0!==u){var f=((t-o)*a+(n-i)*u)/(a*a+u*u);f>1?(o=r[0],i=r[1]):f>0&&(o+=a*f,i+=u*f)}return(a=t-o)*a+(u=n-i)*u}n.exports=function(t,n,e){var a,u,f,h;n=n||1;for(var s=0;s<t[0].length;s++){var d=t[0][s];(!s||d[0]<a)&&(a=d[0]),(!s||d[1]<u)&&(u=d[1]),(!s||d[0]>f)&&(f=d[0]),(!s||d[1]>h)&&(h=d[1])}for(var l=f-a,p=h-u,c=Math.min(l,p),v=c/2,g=new r(null,o),x=a;x<f;x+=c)for(var y=u;y<h;y+=c)g.push(new i(x+v,y+v,v,t));var w=function(t){for(var n=0,e=0,r=0,o=t[0],a=0,u=o.length,f=u-1;a<u;f=a++){var h=o[a],s=o[f],d=h[0]*s[1]-s[0]*h[1];e+=(h[0]+s[0])*d,r+=(h[1]+s[1])*d,n+=3*d}return new i(e/n,r/n,0,t)}(t),m=g.length;for(;g.length;){var b=g.pop();b.d>w.d&&(w=b,e&&console.log("found best %d after %d probes",Math.round(1e4*b.d)/1e4,m)),b.max-w.d<=n||(v=b.h/2,g.push(new i(b.x-v,b.y-v,v,t)),g.push(new i(b.x+v,b.y-v,v,t)),g.push(new i(b.x-v,b.y+v,v,t)),g.push(new i(b.x+v,b.y+v,v,t)),m+=4)}e&&(console.log("num probes: "+m),console.log("best distance: "+w.d));return[w.x,w.y]}},{tinyqueue:2}],2:[function(t,n,e){"use strict";function r(t,n){if(!(this instanceof r))return new r(t,n);if(this.data=t||[],this.length=this.data.length,this.compare=n||o,t)for(var e=Math.floor(this.length/2);e>=0;e--)this._down(e)}function o(t,n){return t<n?-1:t>n?1:0}function i(t,n,e){var r=t[n];t[n]=t[e],t[e]=r}n.exports=r,r.prototype={push:function(t){this.data.push(t),this.length++,this._up(this.length-1)},pop:function(){var t=this.data[0];return this.data[0]=this.data[this.length-1],this.length--,this.data.pop(),this._down(0),t},peek:function(){return this.data[0]},_up:function(t){for(var n=this.data,e=this.compare;t>0;){var r=Math.floor((t-1)/2);if(!(e(n[t],n[r])<0))break;i(n,r,t),t=r}},_down:function(t){for(var n=this.data,e=this.compare,r=this.length;;){var o=2*t+1,a=o+1,u=t;if(o<r&&e(n[o],n[u])<0&&(u=o),a<r&&e(n[a],n[u])<0&&(u=a),u===t)return;i(n,u,t),t=u}}}},{}]},{},[1])(1)});
|
||||
1
libs/priority-queue.min.js
vendored
Normal file
1
libs/priority-queue.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
libs/quantize.min.js
vendored
Normal file
1
libs/quantize.min.js
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
if(!pv)var pv={map:function(r,n){var o={};return n?r.map(function(r,t){return o.index=t,n.call(o,r)}):r.slice()},naturalOrder:function(r,n){return r<n?-1:r>n?1:0},sum:function(r,n){var o={};return r.reduce(n?function(r,t,u){return o.index=u,r+n.call(o,t)}:function(r,n){return r+n},0)},max:function(r,n){return Math.max.apply(null,n?pv.map(r,n):r)}};var MMCQ=function(){var r=5,n=8-r,o=1e3,t=.75;function u(n,o,t){return(n<<2*r)+(o<<r)+t}function e(r){var n=[],o=!1;function t(){n.sort(r),o=!0}return{push:function(r){n.push(r),o=!1},peek:function(r){return o||t(),void 0===r&&(r=n.length-1),n[r]},pop:function(){return o||t(),n.pop()},size:function(){return n.length},map:function(r){return n.map(r)},debug:function(){return o||t(),n}}}function i(r,n,o,t,u,e,i){var c=this;c.r1=r,c.r2=n,c.g1=o,c.g2=t,c.b1=u,c.b2=e,c.histo=i}function c(){this.vboxes=new e(function(r,n){return pv.naturalOrder(r.vbox.count()*r.vbox.volume(),n.vbox.count()*n.vbox.volume())})}function f(r,n){if(n.count()){var o=n.r2-n.r1+1,t=n.g2-n.g1+1,e=n.b2-n.b1+1,i=pv.max([o,t,e]);if(1==n.count())return[n.copy()];var c,f,a,v,s=0,p=[],l=[];if(i==o)for(c=n.r1;c<=n.r2;c++){for(v=0,f=n.g1;f<=n.g2;f++)for(a=n.b1;a<=n.b2;a++)v+=r[u(c,f,a)]||0;s+=v,p[c]=s}else if(i==t)for(c=n.g1;c<=n.g2;c++){for(v=0,f=n.r1;f<=n.r2;f++)for(a=n.b1;a<=n.b2;a++)v+=r[u(f,c,a)]||0;s+=v,p[c]=s}else for(c=n.b1;c<=n.b2;c++){for(v=0,f=n.r1;f<=n.r2;f++)for(a=n.g1;a<=n.g2;a++)v+=r[u(f,a,c)]||0;s+=v,p[c]=s}return p.forEach(function(r,n){l[n]=s-r}),h(i==o?"r":i==t?"g":"b")}function h(r){var o,t,u,e,i,f=r+"1",a=r+"2",v=0;for(c=n[f];c<=n[a];c++)if(p[c]>s/2){for(u=n.copy(),e=n.copy(),i=(o=c-n[f])<=(t=n[a]-c)?Math.min(n[a]-1,~~(c+t/2)):Math.max(n[f],~~(c-1-o/2));!p[i];)i++;for(v=l[i];!v&&p[i-1];)v=l[--i];return u[a]=i,e[f]=u[a]+1,[u,e]}}}return i.prototype={volume:function(r){var n=this;return n._volume&&!r||(n._volume=(n.r2-n.r1+1)*(n.g2-n.g1+1)*(n.b2-n.b1+1)),n._volume},count:function(r){var n=this,o=n.histo;if(!n._count_set||r){var t,e,i,c=0;for(t=n.r1;t<=n.r2;t++)for(e=n.g1;e<=n.g2;e++)for(i=n.b1;i<=n.b2;i++)c+=o[u(t,e,i)]||0;n._count=c,n._count_set=!0}return n._count},copy:function(){var r=this;return new i(r.r1,r.r2,r.g1,r.g2,r.b1,r.b2,r.histo)},avg:function(n){var o=this,t=o.histo;if(!o._avg||n){var e,i,c,f,a=0,v=1<<8-r,s=0,p=0,l=0;for(i=o.r1;i<=o.r2;i++)for(c=o.g1;c<=o.g2;c++)for(f=o.b1;f<=o.b2;f++)a+=e=t[u(i,c,f)]||0,s+=e*(i+.5)*v,p+=e*(c+.5)*v,l+=e*(f+.5)*v;o._avg=a?[~~(s/a),~~(p/a),~~(l/a)]:[~~(v*(o.r1+o.r2+1)/2),~~(v*(o.g1+o.g2+1)/2),~~(v*(o.b1+o.b2+1)/2)]}return o._avg},contains:function(r){var o=this,t=r[0]>>n;return gval=r[1]>>n,bval=r[2]>>n,t>=o.r1&&t<=o.r2&&gval>=o.g1&&gval<=o.g2&&bval>=o.b1&&bval<=o.b2}},c.prototype={push:function(r){this.vboxes.push({vbox:r,color:r.avg()})},palette:function(){return this.vboxes.map(function(r){return r.color})},size:function(){return this.vboxes.size()},map:function(r){for(var n=this.vboxes,o=0;o<n.size();o++)if(n.peek(o).vbox.contains(r))return n.peek(o).color;return this.nearest(r)},nearest:function(r){for(var n,o,t,u=this.vboxes,e=0;e<u.size();e++)((o=Math.sqrt(Math.pow(r[0]-u.peek(e).color[0],2)+Math.pow(r[1]-u.peek(e).color[1],2)+Math.pow(r[2]-u.peek(e).color[2],2)))<n||void 0===n)&&(n=o,t=u.peek(e).color);return t},forcebw:function(){var r=this.vboxes;r.sort(function(r,n){return pv.naturalOrder(pv.sum(r.color),pv.sum(n.color))});var n=r[0].color;n[0]<5&&n[1]<5&&n[2]<5&&(r[0].color=[0,0,0]);var o=r.length-1,t=r[o].color;t[0]>251&&t[1]>251&&t[2]>251&&(r[o].color=[255,255,255])}},{quantize:function(a,v){if(v++,!a.length||v<2||v>256)return!1;var s,p,l,h,b,g,m=(s=a,g=new Array(1<<3*r),s.forEach(function(r){l=r[0]>>n,h=r[1]>>n,b=r[2]>>n,p=u(l,h,b),g[p]=(g[p]||0)+1}),g);m.forEach(function(){});var x,_,d,w,z,M,y,k,O,E,q=(x=m,z=1e6,M=0,y=1e6,k=0,O=1e6,E=0,a.forEach(function(r){_=r[0]>>n,d=r[1]>>n,w=r[2]>>n,_<z?z=_:_>M&&(M=_),d<y?y=d:d>k&&(k=d),w<O?O=w:w>E&&(E=w)}),new i(z,M,y,k,O,E,x)),A=new e(function(r,n){return pv.naturalOrder(r.count(),n.count())});function C(r,n){for(var t,u=1,e=0;e<o;)if((t=r.pop()).count()){var i=f(m,t),c=i[0],a=i[1];if(!c)return;if(r.push(c),a&&(r.push(a),u++),u>=n)return;if(e++>o)return}else r.push(t),e++}A.push(q),C(A,t*v);for(var Q=new e(function(r,n){return pv.naturalOrder(r.count()*r.volume(),n.count()*n.volume())});A.size();)Q.push(A.pop());C(Q,v-Q.size());for(var j=new c;Q.size();)j.push(Q.pop());return j}}}();
|
||||
32
script.js
32
script.js
|
|
@ -1586,16 +1586,14 @@ function fantasyMap() {
|
|||
}
|
||||
|
||||
function editRiver() {
|
||||
if (elSelected) {
|
||||
if ($("#riverNew").hasClass('pressed')) {
|
||||
var point = d3.mouse(this);
|
||||
addRiverPoint({scX:point[0], scY:point[1]});
|
||||
redrawRiver();
|
||||
$("#riverNew").click();
|
||||
return;
|
||||
}
|
||||
unselect();
|
||||
if ($("#riverNew").hasClass('pressed')) {
|
||||
var point = d3.mouse(this);
|
||||
addRiverPoint({scX:point[0], scY:point[1]});
|
||||
redrawRiver();
|
||||
$("#riverNew").click();
|
||||
return;
|
||||
}
|
||||
unselect();
|
||||
elSelected = d3.select(this);
|
||||
elSelected.call(d3.drag().on("start", riverDrag)).classed("draggable", true);
|
||||
var points = JSON.parse(elSelected.attr("data-points"));
|
||||
|
|
@ -1623,7 +1621,7 @@ function fantasyMap() {
|
|||
elSelected = null;
|
||||
if ($("#riverEditor").is(":visible")) {$("#riverEditor").dialog("close");}
|
||||
if ($("#labelEditor").is(":visible")) {$("#labelEditor").dialog("close");}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function addRiverPoint(point) {
|
||||
|
|
@ -3168,7 +3166,7 @@ function fantasyMap() {
|
|||
}
|
||||
|
||||
function editLabel() {
|
||||
if (elSelected) {unselect();}
|
||||
unselect();
|
||||
elSelected = d3.select(this);
|
||||
elSelected.call(d3.drag().on("drag", dragged).on("end", dragended)).classed("draggable", true);
|
||||
var group = d3.select(this.parentNode);
|
||||
|
|
@ -3367,6 +3365,7 @@ function fantasyMap() {
|
|||
|
||||
// on any Editor input change
|
||||
$("#labelEditor .editTrigger").change(function() {
|
||||
if (!elSelected) {return;}
|
||||
$(this).attr("title", $(this).val());
|
||||
elSelected.text(editText.value); // change Label text
|
||||
// check if Group was changed
|
||||
|
|
@ -3523,17 +3522,16 @@ function fantasyMap() {
|
|||
var blob = new Blob([svg_xml], {type:'image/svg+xml;charset=utf-8'});
|
||||
var url = window.URL.createObjectURL(blob);
|
||||
var link = document.createElement("a");
|
||||
link.target = "_blank";
|
||||
if (type === "png") {
|
||||
canvas.width = mapWidth * 2;
|
||||
canvas.height = mapHeight * 2;
|
||||
canvas.width = $(window).width();
|
||||
canvas.height = $(window).height();
|
||||
var img = new Image();
|
||||
img.src = url;
|
||||
img.onload = function(){
|
||||
ctx.drawImage(img, 0, 0, canvas.width, canvas.height);
|
||||
link.download = "fantasy_map_" + Date.now() + ".png";
|
||||
link.href = canvas.toDataURL('image/png');
|
||||
canvas.width = mapWidth;
|
||||
canvas.height = mapHeight;
|
||||
canvas.style.opacity = 0;
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
|
|
@ -3545,7 +3543,7 @@ function fantasyMap() {
|
|||
link.click();
|
||||
}
|
||||
console.timeEnd("saveAsImage");
|
||||
window.setTimeout(function() {window.URL.revokeObjectURL(url);}, 5000);
|
||||
window.setTimeout(function() {window.URL.revokeObjectURL(url);}, 10000);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -3682,7 +3680,7 @@ function fantasyMap() {
|
|||
oceanPattern = ocean.select("#oceanPattern");
|
||||
landmass = viewbox.select("#landmass");
|
||||
grid = viewbox.select("#grid");
|
||||
overlay = viewbox.select("id", "overlay");
|
||||
overlay = viewbox.select("#overlay");
|
||||
terrs = viewbox.select("#terrs");
|
||||
cults = viewbox.select("#cults");
|
||||
routes = viewbox.select("#routes");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue