Merge pull request #601 from evolvedexperiment/1k

Added 1k, 2k, and 5k options
This commit is contained in:
Azgaar 2021-03-04 15:24:51 +03:00 committed by GitHub
commit e5a1e64c6e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 56 additions and 25 deletions

View file

@ -942,7 +942,7 @@
<td></td> <td></td>
<td>Points number</td> <td>Points number</td>
<td> <td>
<input id="densityInput" type="range" min=1 max=10 value=1> <input id="densityInput" type="range" min=1 max=13 value=4>
</td> </td>
<td> <td>
<output id="densityOutput">10K</output> <output id="densityOutput">10K</output>

22
main.js
View file

@ -12,6 +12,21 @@ const TIME = !PRODUCTION;
const WARN = 1; const WARN = 1;
const ERROR = 1; const ERROR = 1;
// constants to link density values to number of cells
const POINTS_1K = 1;
const POINTS_2K = 2;
const POINTS_5K = 3;
const POINTS_10K = 4;
const POINTS_20K = 5;
const POINTS_30K = 6;
const POINTS_40K = 7;
const POINTS_50K = 8;
const POINTS_60K = 9;
const POINTS_70K = 10;
const POINTS_80K = 11;
const POINTS_90K = 12;
const POINTS_100K = 13;
// if map version is not stored, clear localStorage and show a message // if map version is not stored, clear localStorage and show a message
if (rn(localStorage.getItem("version"), 2) !== rn(version, 2)) { if (rn(localStorage.getItem("version"), 2) !== rn(version, 2)) {
localStorage.clear(); localStorage.clear();
@ -615,7 +630,12 @@ function generateSeed() {
// Place points to calculate Voronoi diagram // Place points to calculate Voronoi diagram
function placePoints() { function placePoints() {
TIME && console.time("placePoints"); TIME && console.time("placePoints");
const cellsDesired = 10000 * densityInput.value; // generate 10k points for each densityInput point let cellsDesired = 10000 * (+densityInput.value - POINTS_5K); // generate 10k points for each densityInput point
switch (+densityInput.value) {
case POINTS_1K: cellsDesired = 1000; break;
case POINTS_2K: cellsDesired = 2000; break;
case POINTS_5K: cellsDesired = 5000; break;
}
const spacing = grid.spacing = rn(Math.sqrt(graphWidth * graphHeight / cellsDesired), 2); // spacing between points before jirrering const spacing = grid.spacing = rn(Math.sqrt(graphWidth * graphHeight / cellsDesired), 2); // spacing between points before jirrering
grid.boundary = getBoundaryPoints(graphWidth, graphHeight, spacing); grid.boundary = getBoundaryPoints(graphWidth, graphHeight, spacing);
grid.points = getJitteredGrid(graphWidth, graphHeight, spacing); // jittered square grid grid.points = getJitteredGrid(graphWidth, graphHeight, spacing); // jittered square grid

View file

@ -187,31 +187,37 @@
function getBlobPower() { function getBlobPower() {
switch (+densityInput.value) { switch (+densityInput.value) {
case 1: return .98; case POINTS_1K: return .93;
case 2: return .985; case POINTS_2K: return .95;
case 3: return .987; case POINTS_5K: return .96;
case 4: return .9892; case POINTS_10K: return .98;
case 5: return .9911; case POINTS_20K: return .985;
case 6: return .9921; case POINTS_30K: return .987;
case 7: return .9934; case POINTS_40K: return .9892;
case 8: return .9942; case POINTS_50K: return .9911;
case 9: return .9946; case POINTS_60K: return .9921;
case 10: return .995; case POINTS_70K: return .9934;
case POINTS_80K: return .9942;
case POINTS_90K: return .9946;
case POINTS_100K: return .995;
} }
} }
function getLinePower() { function getLinePower() {
switch (+densityInput.value) { switch (+densityInput.value) {
case 1: return .81; case POINTS_1K: return .74;
case 2: return .82; case POINTS_2K: return .75;
case 3: return .83; case POINTS_5K: return .78;
case 4: return .84; case POINTS_10K: return .81;
case 5: return .855; case POINTS_20K: return .82;
case 6: return .87; case POINTS_30K: return .83;
case 7: return .885; case POINTS_40K: return .84;
case 8: return .91; case POINTS_50K: return .855;
case 9: return .92; case POINTS_60K: return .87;
case 10: return .93; case POINTS_70K: return .885;
case POINTS_80K: return .91;
case POINTS_90K: return .92;
case POINTS_100K: return .93;
} }
} }

View file

@ -276,9 +276,14 @@ function copyMapURL() {
} }
function changeCellsDensity(value) { function changeCellsDensity(value) {
densityOutput.value = value * 10 + "K"; switch (value) {
if (value > 5) densityOutput.style.color = "#b12117"; case POINTS_1K : densityOutput.value = "1K"; break;
else if (value > 1) densityOutput.style.color = "#dfdf12"; case POINTS_2K : densityOutput.value = "2K"; break;
case POINTS_5K : densityOutput.value = "5K"; break;
default: densityOutput.value = (value-POINTS_5K) * 10 + "K";
}
if (value > POINTS_50K) densityOutput.style.color = "#b12117";
else if (value > POINTS_10K) densityOutput.style.color = "#dfdf12";
else densityOutput.style.color = "#038603"; else densityOutput.style.color = "#038603";
} }