Skip to content

Commit

Permalink
Refactor the basemap and introduce new themes (#706)
Browse files Browse the repository at this point in the history
  • Loading branch information
bchapuis authored Jun 18, 2023
1 parent 812da8e commit c0b9e92
Show file tree
Hide file tree
Showing 18 changed files with 470 additions and 159 deletions.
13 changes: 13 additions & 0 deletions basemap/themes/achromatomaly.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import style from './default.js';
import {Color, ColorBlind} from "../utils/color.js";

export default Object.entries(style).reduce((acc, [key, value]) => {
let color = Color.fromString(value);
if (color == null) {
acc[key] = value;
return acc;
} else {
acc[key] = color.colorblind(ColorBlind.Achromatomaly).toString();
return acc;
}
}, {});
13 changes: 13 additions & 0 deletions basemap/themes/achromatopsia.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import style from './default.js';
import {Color, ColorBlind} from "../utils/color.js";

export default Object.entries(style).reduce((acc, [key, value]) => {
let color = Color.fromString(value);
if (color == null) {
acc[key] = value;
return acc;
} else {
acc[key] = color.colorblind(ColorBlind.Achromatopsia).toString();
return acc;
}
}, {});
13 changes: 13 additions & 0 deletions basemap/themes/contrast.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import style from './default.js';
import {Color} from "../utils/color.js";

export default Object.entries(style).reduce((acc, [key, value]) => {
let color = Color.fromString(value);
if (color == null) {
acc[key] = value;
return acc;
} else {
acc[key] = color.contrast(0.1).toString();
return acc;
}
}, {});
13 changes: 13 additions & 0 deletions basemap/themes/dark.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import style from './light.js';
import {Color} from "../utils/color.js";

export default Object.entries(style).reduce((acc, [key, value]) => {
let color = Color.fromString(value);
if (color == null) {
acc[key] = value;
return acc;
} else {
acc[key] = color.grayscale().invert().toString();
return acc;
}
}, {});
3 changes: 0 additions & 3 deletions basemap/themes/default.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
export default {

aerialwayStyleLinePaintLineColor: 'rgb(177, 177, 175)',
aerowayLineRunwayLineColor: 'rgba(187, 187, 204, 1.0)',
aerowayLineTaxiwayLineColor: 'rgba(187, 187, 204, 1.0)',
Expand Down Expand Up @@ -607,6 +606,4 @@ export default {
waterwayLineWaterwayLineColor: 'rgb(170, 211, 223)',
waterwayTunnelCasingLineColor: 'rgb(170, 211, 223)',
waterwayTunnelLineLineColor: 'rgb(243, 247, 247)'


};
13 changes: 13 additions & 0 deletions basemap/themes/deuteranomaly.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import style from './default.js';
import {Color, ColorBlind} from "../utils/color.js";

export default Object.entries(style).reduce((acc, [key, value]) => {
let color = Color.fromString(value);
if (color == null) {
acc[key] = value;
return acc;
} else {
acc[key] = color.colorblind(ColorBlind.Deuteranomaly).toString();
return acc;
}
}, {});
13 changes: 13 additions & 0 deletions basemap/themes/deuteranopia.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import style from './default.js';
import {Color, ColorBlind} from "../utils/color.js";

export default Object.entries(style).reduce((acc, [key, value]) => {
let color = Color.fromString(value);
if (color == null) {
acc[key] = value;
return acc;
} else {
acc[key] = color.colorblind(ColorBlind.Deuteranopia).toString();
return acc;
}
}, {});
13 changes: 13 additions & 0 deletions basemap/themes/grayscale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import style from './default.js';
import {Color} from "../utils/color.js";

export default Object.entries(style).reduce((acc, [key, value]) => {
let color = Color.fromString(value);
if (color == null) {
acc[key] = value;
return acc;
} else {
acc[key] = color.grayscale().toString();
return acc;
}
}, {});
58 changes: 11 additions & 47 deletions basemap/themes/light.js
Original file line number Diff line number Diff line change
@@ -1,49 +1,13 @@
import * as importedTools from "./tools.js";
import positronScheme from "./positron.js";

const CLARITYFACTOR = 4.7;


function lightScheme(string) {
const table = importedTools.cutRgbString(string);
if (table[1] != null) {
let newColor = importedTools.max - importedTools.clamp(table[0] / CLARITYFACTOR);
return importedTools.giveNewColorString(table, newColor, newColor, newColor);
import style from './grayscale.js';
import {Color} from "../utils/color.js";

export default Object.entries(style).reduce((acc, [key, value]) => {
let color = Color.fromString(value);
if (color == null) {
acc[key] = value;
return acc;
} else {
acc[key] = color.grayscale().lighten(0.1).toString();
return acc;
}
return null;
}

export default Object.entries(positronScheme).reduce((acc, [key, value]) => {
acc[key] = lightScheme(value);
return {
...acc,
attractionStyleWaterSlideLineColor: 'rgb(175,175,175)',
landuseBackgroundBasinFillColor: 'rgb(175,175,175)',
leisureBackgroundSwimmingPoolFillColor: 'rgb(175,175,175)',
leisureOverlaySwimmingPoolFillOutlineColor: 'rgb(175,175,175)',
naturalBackgroundWaterFillColor: 'rgb(175,175,175)',
naturalOverlayLakeFillColor: 'rgb(175,175,175)',
naturalWaterFillColor: 'rgb(175,175,175)',
oceanWaterFillColor: 'rgb(175,175,175)',
pointCountryLabelCountryTextColor: 'rgb(90, 56, 90)',
pointCountryLabelPaintTextHaloColor: 'rgba(255, 255, 255, 0.8)',
pointIconWaterfallIconColor: 'rgb(175,175,175)',
pointIconWaterfallTextColor: 'rgb(175,175,175)',
pointLabelCityFilterOneLabelColor: 'rgb(100, 100, 100)',
pointLabelCityFilterTwoLabelColor: 'rgb(50, 50, 50)',
pointLabelCityLabelColor: 'rgb(25, 25, 25)',
pointLabelLocalityLabelColor: 'rgb(100, 100, 100)',
pointLabelPaintTextHaloColor: 'rgba(255, 255, 255, 0.8)',
pointLabelPlaceTextColor: 'rgba(100, 100, 100, 1)',
pointLabelTownFilterOneLabelColor: 'rgb(100, 100, 100)',
pointLabelTownFilterTwoLabelColor: 'rgb(75, 75, 75)',
pointLabelVillageLabelColor: 'rgb(100, 100, 100)',
waterwayLabelTextColor: 'rgb(175,175,175)',
waterwayLabelTextHaloColor: 'rgb(175,175,175)',
waterwayLineWaterwayLineColor: 'rgb(175,175,175)',
waterwayTunnelCasingLineColor: 'rgb(175,175,175)',
waterwayTunnelLineLineColor: 'rgb(175,175,175)',
};


}, {});
18 changes: 0 additions & 18 deletions basemap/themes/positron.js

This file was deleted.

13 changes: 13 additions & 0 deletions basemap/themes/protanomaly.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import style from './default.js';
import {Color, ColorBlind} from "../utils/color.js";

export default Object.entries(style).reduce((acc, [key, value]) => {
let color = Color.fromString(value);
if (color == null) {
acc[key] = value;
return acc;
} else {
acc[key] = color.colorblind(ColorBlind.Protanomaly).toString();
return acc;
}
}, {});
13 changes: 13 additions & 0 deletions basemap/themes/protanopia.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import style from './default.js';
import {Color, ColorBlind} from "../utils/color.js";

export default Object.entries(style).reduce((acc, [key, value]) => {
let color = Color.fromString(value);
if (color == null) {
acc[key] = value;
return acc;
} else {
acc[key] = color.colorblind(ColorBlind.Protanopia).toString();
return acc;
}
}, {});
15 changes: 0 additions & 15 deletions basemap/themes/road.js

This file was deleted.

36 changes: 0 additions & 36 deletions basemap/themes/tools.js

This file was deleted.

20 changes: 20 additions & 0 deletions basemap/themes/transportation.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import style from './default.js';
import {Color} from "../utils/color.js";

export default Object.entries(style).reduce((acc, [key, value]) => {
let color = Color.fromString(value);
if (color == null) {
acc[key] = value;
return acc;
} else if (key.toLowerCase().includes("highway")
|| key.toLowerCase().includes("tunnel")
|| key.toLowerCase().includes("bridge")
|| key.toLowerCase().includes("rail")
|| key.toLowerCase().includes("ferry")) {
acc[key] = color.darken(0.2).toString();
return acc;
} else {
acc[key] = color.grayscale().lighten(0.1).toString();
return acc;
}
}, {});
13 changes: 13 additions & 0 deletions basemap/themes/tritanomaly.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import style from './default.js';
import {Color, ColorBlind} from "../utils/color.js";

export default Object.entries(style).reduce((acc, [key, value]) => {
let color = Color.fromString(value);
if (color == null) {
acc[key] = value;
return acc;
} else {
acc[key] = color.colorblind(ColorBlind.Tritanomaly).toString();
return acc;
}
}, {});
13 changes: 13 additions & 0 deletions basemap/themes/tritanopia.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import style from './default.js';
import {Color, ColorBlind} from "../utils/color.js";

export default Object.entries(style).reduce((acc, [key, value]) => {
let color = Color.fromString(value);
if (color == null) {
acc[key] = value;
return acc;
} else {
acc[key] = color.colorblind(ColorBlind.Tritanopia).toString();
return acc;
}
}, {});
Loading

0 comments on commit c0b9e92

Please sign in to comment.