mirror of
https://github.com/Azgaar/Fantasy-Map-Generator.git
synced 2025-12-17 17:51:24 +01:00
refactor(es modules): migrate a few more functions
This commit is contained in:
parent
63e9b9c87e
commit
865a98199f
18 changed files with 330 additions and 309 deletions
|
|
@ -1,6 +1,6 @@
|
|||
const d3 = window.d3;
|
||||
|
||||
const c12 = [
|
||||
const c12: Hex[] = [
|
||||
"#dababf",
|
||||
"#fb8072",
|
||||
"#80b1d3",
|
||||
|
|
@ -38,3 +38,21 @@ export function getMixedColor(hexColor: string, mixation = 0.2, bright = 0.3) {
|
|||
|
||||
return d3.color(mixedColor).brighter(bright).hex();
|
||||
}
|
||||
|
||||
export function getColorScheme(schemeName: string) {
|
||||
return colorSchemeMap[schemeName] || colorSchemeMap.default;
|
||||
}
|
||||
|
||||
type ColorScheme = (n: number) => RGB;
|
||||
const colorSchemeMap: Dict<ColorScheme> = {
|
||||
default: d3.scaleSequential(d3.interpolateSpectral),
|
||||
bright: d3.scaleSequential(d3.interpolateSpectral),
|
||||
light: d3.scaleSequential(d3.interpolateRdYlGn),
|
||||
green: d3.scaleSequential(d3.interpolateGreens),
|
||||
monochrome: d3.scaleSequential(d3.interpolateGreys)
|
||||
};
|
||||
|
||||
export function getHeightColor(height: number, scheme = getColorScheme("default")) {
|
||||
const fittedValue = height < 20 ? height - 5 : height;
|
||||
return scheme(1 - fittedValue / 100);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue