fniessen / emacs-leuven-theme

This Emacs theme reduces eye strain with a light, high-contrast color scheme, syntax highlighting, and support for multiple modes. Enhance your coding experience! #emacs #theme #coding #orgmode
GNU General Public License v3.0
696 stars 59 forks source link

Dark theme adjustment (do more than just invert) #62

Closed blairdrummond closed 4 years ago

blairdrummond commented 5 years ago

Thanks for creating the greatest and most complete emacs theme in existence --- This might not be perfectly complete, but I was thinking that instead of simply negating the colors in order to create a dark theme, one could just apply a slightly funkier transformation. For instance, here I inverted the colors, but then I lifted the colors away from #000000 by adding 2*sqrt(255 - color) if the color was fairly small. This just makes the theme a little brighter. Here's the code

    # flip but avoid 0
    r2 = max(255 - r, 1)
    g2 = max(255 - g, 1)
    b2 = max(255 - b, 1)

    # Make colors a bit brighter
    # Non-linearly scale away from 0
    if r2 + g2 + b2 < MAGIC_NUMBER:
        ## Changing the '2*' mulitplier is a good way to
        ## brighten or darken.
        r2 = min(255, r2 + int(2*sqrt(255 - r2)))
        g2 = min(255, g2 + int(2*sqrt(255 - g2)))
        b2 = min(255, b2 + int(2*sqrt(255 - b2)))

    ## Rotate: Just for fun
    ## r2, g2, b2 = (b2, r2, g2)

    # Increase the blue and red a little
    from math import log
    b2 += int(log(max(1,255 - b2)))
    b2 += int(log(max(1,255 - b2)))
    r2 += int(log(max(1,255 - r2)))

I played around with it, but I'm not really a designer (and it might be best to let people just mess around to taste, or you can even experiment yourself and decide what you think looks best)

Some screenshots:

2019-03-19-123646_1920x1080_scrot 2019-03-19-123633_1920x1080_scrot

Again, I'm not set on these exact colors, but I think this general approach could work, and imho it imporoves upon the existing dark theme.

Cheers, Blair

fniessen commented 4 years ago

Dear @blairdrummond , thanks for the improvement!

(Feel free to re-run it on the updated version of Leuven theme, with the fixes for Emacs 27.)