diff --git a/src/layers/renderers/drawBiomes.js b/src/layers/renderers/drawBiomes.js index e1d7424f..91856940 100644 --- a/src/layers/renderers/drawBiomes.js +++ b/src/layers/renderers/drawBiomes.js @@ -18,10 +18,7 @@ export function drawBiomes() { const edgeVerticle = cells.v[i].find(v => vertices.c[v].some(i => cells.biome[i] !== b)); const chain = connectVertices(edgeVerticle, b); if (chain.length < 3) continue; - const points = clipPoly( - chain.map(v => vertices.p[v]), - 1 - ); + const points = clipPoly(chain.map(v => vertices.p[v])); paths[b] += "M" + points.join("L") + "Z"; } diff --git a/src/modules/coastline.js b/src/modules/coastline.js index da1d0af2..d801ba38 100644 --- a/src/modules/coastline.js +++ b/src/modules/coastline.js @@ -37,10 +37,7 @@ export function drawCoastline() { let vchain = connectVertices(start, type); if (features[f].type === "lake") relax(vchain, 1.2); used[f] = 1; - let points = clipPoly( - vchain.map(v => vertices.p[v]), - 1 - ); + let points = clipPoly(vchain.map(v => vertices.p[v])); const area = d3.polygonArea(points); // area with lakes/islands if (area > 0 && features[f].type === "lake") { points = points.reverse(); diff --git a/src/modules/ocean-layers.js b/src/modules/ocean-layers.js index de8f207b..4cbe79db 100644 --- a/src/modules/ocean-layers.js +++ b/src/modules/ocean-layers.js @@ -34,10 +34,7 @@ window.OceanLayers = (function () { const relax = 1 + t * -2; // select only n-th point const relaxed = chain.filter((v, i) => !(i % relax) || vertices.c[v].some(c => c >= pointsN)); if (relaxed.length < 4) continue; - const points = clipPoly( - relaxed.map(v => vertices.p[v]), - 1 - ); + const points = clipPoly(relaxed.map(v => vertices.p[v])); chains.push([t, points]); } diff --git a/src/modules/ui/coastline-editor.js b/src/modules/ui/coastline-editor.js index b91dbb72..6dc4215b 100644 --- a/src/modules/ui/coastline-editor.js +++ b/src/modules/ui/coastline-editor.js @@ -90,10 +90,7 @@ export function editCoastline(node = d3.event.target) { function redrawCoastline() { const f = +elSelected.attr("data-f"); const vertices = pack.features[f].vertices; - const points = clipPoly( - vertices.map(v => pack.vertices.p[v]), - 1 - ); + const points = clipPoly(vertices.map(v => pack.vertices.p[v])); const d = round(lineGen(points)); elSelected.attr("d", d); defs.select("mask#land > path#land_" + f).attr("d", d); // update land mask diff --git a/src/types/modules.d.ts b/src/types/modules.d.ts index bfe96291..6bfd06da 100644 --- a/src/types/modules.d.ts +++ b/src/types/modules.d.ts @@ -1,4 +1,4 @@ declare module "lineclip" { - export function polygon(points: number[][], bbox: number[], result?: number[][]): number[][]; - export function lineclip(points: number[][], bbox: number[]): number[][]; + export function polygon(points: number[][], bbox: number[]): number[][]; + export function lineclip(points: number[][], bbox: number[], result: number[][]): number[][]; } diff --git a/src/utils/lineUtils.ts b/src/utils/lineUtils.ts index d6ff2b2e..d118e496 100644 --- a/src/utils/lineUtils.ts +++ b/src/utils/lineUtils.ts @@ -2,7 +2,7 @@ import {polygon} from "lineclip"; // clip polygon by graph bbox export function clipPoly(points: TPoints) { - return polygon(points, [0, 0, graphWidth, graphWidth]); + return polygon(points, [0, 0, graphWidth, graphHeight]); } // get segment of any point on polyline