mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-19 02:21:24 +01:00
refactor(es modules): split layers to modules
This commit is contained in:
parent
05564ef5d9
commit
7755d8b588
37 changed files with 2035 additions and 1998 deletions
41
src/layers/renderers/drawPopulation.js
Normal file
41
src/layers/renderers/drawPopulation.js
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
export function drawPopulation(event) {
|
||||
population.selectAll("line").remove();
|
||||
|
||||
const {cells, burgs} = pack;
|
||||
const p = {cells};
|
||||
const show = d3.transition().duration(2000).ease(d3.easeSinIn);
|
||||
|
||||
const rural = Array.from(
|
||||
cells.i.filter(i => cells.pop[i] > 0),
|
||||
i => [p[i][0], p[i][1], p[i][1] - cells.pop[i] / 8]
|
||||
);
|
||||
|
||||
population
|
||||
.select("#rural")
|
||||
.selectAll("line")
|
||||
.data(rural)
|
||||
.enter()
|
||||
.append("line")
|
||||
.attr("x1", d => d[0])
|
||||
.attr("y1", d => d[1])
|
||||
.attr("x2", d => d[0])
|
||||
.attr("y2", d => d[1])
|
||||
.transition(show)
|
||||
.attr("y2", d => d[2]);
|
||||
|
||||
const urban = burgs.filter(b => b.i && !b.removed).map(b => [b.x, b.y, b.y - (b.population / 8) * urbanization]);
|
||||
|
||||
population
|
||||
.select("#urban")
|
||||
.selectAll("line")
|
||||
.data(urban)
|
||||
.enter()
|
||||
.append("line")
|
||||
.attr("x1", d => d[0])
|
||||
.attr("y1", d => d[1])
|
||||
.attr("x2", d => d[0])
|
||||
.attr("y2", d => d[1])
|
||||
.transition(show)
|
||||
.delay(500)
|
||||
.attr("y2", d => d[2]);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue