mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-18 02:01:22 +01:00
refactor(es modules): remove gloval var lineGen
This commit is contained in:
parent
32d7db765d
commit
aa214a7826
17 changed files with 27 additions and 22 deletions
|
|
@ -83,8 +83,9 @@ export function editCoastline(node = d3.event.target) {
|
|||
redrawCoastline();
|
||||
}
|
||||
|
||||
const lineGen = d3.line().curve(d3.curveBasisClosed);
|
||||
|
||||
function redrawCoastline() {
|
||||
lineGen.curve(d3.curveBasisClosed);
|
||||
const f = +elSelected.attr("data-f");
|
||||
const vertices = pack.features[f].vertices;
|
||||
const points = clipPoly(
|
||||
|
|
|
|||
|
|
@ -119,9 +119,10 @@ export function editLabel() {
|
|||
redrawLabelPath();
|
||||
}
|
||||
|
||||
const lineGen = d3.line().curve(d3.curveBundle.beta(1));
|
||||
|
||||
function redrawLabelPath() {
|
||||
const path = document.getElementById("textPath_" + elSelected.attr("id"));
|
||||
lineGen.curve(d3.curveBundle.beta(1));
|
||||
const points = [];
|
||||
debug
|
||||
.select("#controlPoints")
|
||||
|
|
|
|||
|
|
@ -117,8 +117,9 @@ export function editLake() {
|
|||
redrawLake();
|
||||
}
|
||||
|
||||
const lineGen = d3.line().curve(d3.curveBasisClosed);
|
||||
|
||||
function redrawLake() {
|
||||
lineGen.curve(d3.curveBasisClosed);
|
||||
const feature = getLake();
|
||||
const points = feature.vertices.map(v => pack.vertices.p[v]);
|
||||
const d = round(lineGen(points));
|
||||
|
|
|
|||
|
|
@ -270,6 +270,7 @@ function drawHeightmap() {
|
|||
const skip = +terrs.attr("skip") + 1;
|
||||
const simplification = +terrs.attr("relax");
|
||||
|
||||
const lineGen = d3.line().curve(d3.curveBasis);
|
||||
switch (+terrs.attr("curve")) {
|
||||
case 0:
|
||||
lineGen.curve(d3.curveBasisClosed);
|
||||
|
|
@ -383,7 +384,8 @@ function toggleTemp(event) {
|
|||
function drawTemp() {
|
||||
TIME && console.time("drawTemp");
|
||||
temperature.selectAll("*").remove();
|
||||
lineGen.curve(d3.curveBasisClosed);
|
||||
|
||||
const lineGen = d3.line().curve(d3.curveBasisClosed);
|
||||
const scheme = d3.scaleSequential(d3.interpolateSpectral);
|
||||
const tMax = +temperatureEquatorOutput.max,
|
||||
tMin = +temperatureEquatorOutput.min,
|
||||
|
|
@ -1615,7 +1617,6 @@ export function drawRivers() {
|
|||
rivers.selectAll("*").remove();
|
||||
|
||||
const {addMeandering, getRiverPath} = Rivers;
|
||||
lineGen.curve(d3.curveCatmullRom.alpha(0.1));
|
||||
|
||||
const riverPaths = pack.rivers.map(({cells, points, i, widthFactor, sourceWidth}) => {
|
||||
if (!cells || cells.length < 2) return;
|
||||
|
|
|
|||
|
|
@ -123,7 +123,6 @@ export function createRiver() {
|
|||
const id = "river" + riverId;
|
||||
|
||||
// render river
|
||||
lineGen.curve(d3.curveCatmullRom.alpha(0.1));
|
||||
viewbox
|
||||
.select("#rivers")
|
||||
.append("path")
|
||||
|
|
|
|||
|
|
@ -166,7 +166,6 @@ export function editRiver(id) {
|
|||
const {widthFactor, sourceWidth} = river;
|
||||
const meanderedPoints = Rivers.addMeandering(river.cells, river.points);
|
||||
|
||||
lineGen.curve(d3.curveCatmullRom.alpha(0.1));
|
||||
const path = Rivers.getRiverPath(meanderedPoints, widthFactor, sourceWidth);
|
||||
elSelected.attr("d", path);
|
||||
|
||||
|
|
|
|||
|
|
@ -88,8 +88,9 @@ export function editRoute(onClick) {
|
|||
redrawRoute();
|
||||
}
|
||||
|
||||
const lineGen = d3.line().curve(d3.curveCatmullRom.alpha(0.1));
|
||||
|
||||
function redrawRoute() {
|
||||
lineGen.curve(d3.curveCatmullRom.alpha(0.1));
|
||||
const points = [];
|
||||
debug
|
||||
.select("#controlPoints")
|
||||
|
|
|
|||
|
|
@ -691,7 +691,6 @@ function addRiverOnClick() {
|
|||
}
|
||||
|
||||
// render river
|
||||
lineGen.curve(d3.curveCatmullRom.alpha(0.1));
|
||||
const path = getRiverPath(meanderedPoints, widthFactor);
|
||||
const id = "river" + riverId;
|
||||
const riversG = viewbox.select("#rivers");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue