Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dark theme variant #4412

Closed
vanillajonathan opened this issue May 21, 2021 · 6 comments
Closed

Dark theme variant #4412

vanillajonathan opened this issue May 21, 2021 · 6 comments

Comments

@vanillajonathan
Copy link

Create a dark theme variant. This could be useful when using a device in dark mode or at evening/night time.

@imagico
Copy link
Collaborator

imagico commented May 21, 2021

I think this is out of scope for this style - we try to produce one cartographic design, not a set of several, that would spread our resources too thin and we would end up producing several mediocre designs rather than a single decent one.

What we try to do is making this style easily adaptable, there is room for improvement in that field w.r.t. colors - we still have plenty of colors inline in the code somewhere that could be organized more systematically for easy adjustment.

@HolgerJeromin
Copy link
Contributor

Ref for a nice filter hack: openstreetmap/openstreetmap-website#2332 (comment)

@vanillajonathan
Copy link
Author

vanillajonathan commented May 21, 2021

I didn't propose several alternative styles, just a dark addition to the existing bright one.

This could perhaps done algorithmically by generating the colors by subtracting lightness from the base bright color and adding lightness to the base dark color.

Something like:

from enum import Enum

BASE_LIGHT_LIGHTNESS = 100
BASE_DARK_LIGHTNESS = 0


class ColorVariant(Enum):
    LIGHT = 1
    DARK = 2


def generate_color(hue: int, saturation: int, color_variant: ColorVariant) -> (int, int, int):
    """Generate a color.

    Generate a color in HSL format given a hue, saturation and color variant.

    Args:
        hue -- The hue for the color to generate.
        saturation: The saturation for the color to generate.
        color_variant: The variant of the color to generate.

    Returns:
        A triplet representing a color in HSL format.

    Raises:
        ValueError -- On invalid color variant.

    Example:
        >>> generate_color(220, 50, ColorVariant.LIGHT)
        (220, 50, 90)
        >>> generate_color(220, 50, ColorVariant.DARK)
        (220, 50, 10)
    """
    if not 0 <= saturation <= 100:
        raise ValueError("Saturation must be a value between 0 and 100")
    lightness = 0
    if color_variant is ColorVariant.LIGHT:
        lightness = BASE_LIGHT_LIGHTNESS
        lightness -= 10
    elif color_variant is ColorVariant.DARK:
        lightness = BASE_DARK_LIGHTNESS
        lightness += 10
    else:
        raise ValueError("Unknown color variant")
    return (hue, saturation, lightness)

@matkoniecz
Copy link
Contributor

Are you interested in actually making and deploying such map style? In such case feel free to file issues about things that would make it easier.

But what is attempted here is complicated enough without adding expectations that colour-swapped map style would be ALSO usable.

@vanillajonathan
Copy link
Author

I would hope to see it depoyed on the official OpenStreetMap tile server with a -dark suffix on the filename.

https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png
https://{s}.tile.openstreetmap.org/{z}/{x}/{y}-dark.png

I think that an algorithm (such as the one I provided above in my previous post) could be used to generate both light and dark themes. The color hue is inputted to the algorithm which then outputs a color with lightness (and possibly saturation) adjusted depending on the theme variant.

@imagico
Copy link
Collaborator

imagico commented May 27, 2021

Closing as we agree this is out of scope for this project. If you want to develop a fork/add-on for this style that changes the color palette used to something with dark area fills and brighter lines/symbols - using either some algorithm or manually - and need some changes in this style to facilitate this being technically easier such suggestions are welcome.

Also relevant in that context would be http://blog.imagico.de/managing-patterns/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants