mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 17:51:24 +01:00
refactor(religions): render religions
This commit is contained in:
parent
707cdd77ac
commit
7a3a87e935
10 changed files with 137 additions and 55 deletions
|
|
@ -1,22 +1,44 @@
|
|||
import * as d3 from "d3";
|
||||
|
||||
import {getPaths} from "./utilts";
|
||||
import {pick} from "utils/functionUtils";
|
||||
|
||||
export function drawCultures() {
|
||||
/* uses */ const {cells, vertices, cultures} = pack;
|
||||
d3.select("#cults").selectAll("g").remove();
|
||||
|
||||
const getType = (cellId: number) => cells.culture[cellId];
|
||||
const paths = getPaths(cells.c, cells.v, vertices, getType);
|
||||
/* uses */ const {cells, vertices, features, cultures} = pack;
|
||||
|
||||
const getColor = (i: number) => i && (cultures[i] as ICulture).color;
|
||||
const paths = getPaths({
|
||||
getType: (cellId: number) => cells.culture[cellId],
|
||||
cells: pick(cells, "c", "v", "b", "h", "f"),
|
||||
vertices,
|
||||
features
|
||||
});
|
||||
|
||||
const getColor = (i: number) => (cultures[i] as ICulture).color;
|
||||
|
||||
d3.select("#cults")
|
||||
.append("g")
|
||||
.attr("fill", "none")
|
||||
.attr("stroke-width", 3)
|
||||
.selectAll("path")
|
||||
.remove()
|
||||
.data(Object.entries(paths))
|
||||
.data(paths)
|
||||
.enter()
|
||||
.append("path")
|
||||
.attr("d", ([, path]) => path)
|
||||
.attr("d", ([, path]) => path.waterGap)
|
||||
.attr("stroke", ([i]) => getColor(Number(i)))
|
||||
.attr("id", ([i]) => "culture-gap" + i);
|
||||
|
||||
d3.select("#cults")
|
||||
.append("g")
|
||||
.attr("stroke", "none")
|
||||
.selectAll("path")
|
||||
.remove()
|
||||
.data(paths)
|
||||
.enter()
|
||||
.append("path")
|
||||
.attr("d", ([, path]) => path.fill)
|
||||
.attr("fill", ([i]) => getColor(Number(i)))
|
||||
.attr("id", ([i]) => "culture" + i);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue