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

Separators have weird colors #2

Closed
Linuus opened this issue Feb 28, 2018 · 5 comments
Closed

Separators have weird colors #2

Linuus opened this issue Feb 28, 2018 · 5 comments

Comments

@Linuus
Copy link

Linuus commented Feb 28, 2018

I'm experimenting with using moody with the zenburn theme on macOS. However, the slants have some weird colors.

Config:

(use-package moody
  :config
  (setq x-underline-at-descent-line t)
  (moody-replace-mode-line-buffer-identification)
  (moody-replace-vc-mode))

  (use-package zenburn-theme
    :demand t
    :config
    (load-theme 'zenburn' t)
    (zenburn-with-color-variables
        (set-face-attribute 'mode-line-inactive nil :overline   zenburn-bg-05)
        (set-face-attribute 'mode-line          nil :overline   zenburn-bg-1)
        (set-face-attribute 'mode-line          nil :underline  zenburn-bg-1)
        (set-face-attribute 'mode-line-inactive nil :underline  zenburn-bg-05)
        (set-face-attribute 'mode-line          nil :box        nil)
        (set-face-attribute 'mode-line-inactive nil :box        nil)
        (set-face-attribute 'mode-line-inactive nil :background zenburn-bg+05)
        (set-face-attribute 'mode-line          nil :background zenburn-bg-1)
        (set-face-attribute 'mode-line          nil :foreground zenburn-blue)
        (set-face-attribute 'mode-line-inactive nil :foreground zenburn-blue-2)))

Looks like this:

screen shot 2018-02-28 at 22 19 29

I don't know if it's the same issue as the one in Powerline, regarding Emacs using different color spaces on macOS for XPM and all other GUI elements, which was fixed here:
milkypostman/powerline@8a24690

What do you think?

Update

It seems to be the same issue. Adding (setq ns-use-srgb-colorspace nil) fixes it. However, that makes the rest of my theme look a bit off so I'd rather not do that.

Would it be possible to implement a similar fix as in powerline?

@tarsius tarsius self-assigned this Feb 28, 2018
@tarsius
Copy link
Owner

tarsius commented Mar 5, 2018

A major reason why I wrote moody is that I couldn't get powerline to do what I wanted (instead of adding the things I wanted I was busy figuring out how to disable the things I did not want, resp. trying to figure out where they were implemented), and the primary reason for that is that it has grown to complex, trying to handle every possible complication. I don't want to go down the same patch with moody.

But there is already an option moody-slant-function, which you can use to implement this. Just write a wrapper around moody-slant and use that to translate c1, c2 and c3 using the code you linked too.

@tarsius tarsius removed their assignment Mar 5, 2018
@Linuus
Copy link
Author

Linuus commented Mar 5, 2018

That sounds extremely reasonable :) I’ll give it a shot! Thanks!
Is it OK if I keep this issue open for now and post the code here and close it when I’m done? I think more people are interested in this.
If not, feel free to close it anyway :)

@Linuus
Copy link
Author

Linuus commented Mar 6, 2018

Ok, so the following code fixes the issue:

  ;; pl functions copied from powerline
  ;; https://github.com/milkypostman/powerline/blob/master/powerline-separators.el
  (defun pl/color-xyz-to-apple-rgb (X Y Z)
    "Convert CIE X Y Z colors to Apple RGB color space."
    (let ((r (+ (* 3.2404542 X) (* -1.5371385 Y) (* -0.4985314 Z)))
          (g (+ (* -0.9692660 X) (* 1.8760108 Y) (* 0.0415560 Z)))
          (b (+ (* 0.0556434 X) (* -0.2040259 Y) (* 1.0572252 Z))))
      (list (expt r (/ 1.8)) (expt g (/ 1.8)) (expt b (/ 1.8)))))

  (defun pl/color-srgb-to-apple-rgb (red green blue)
    "Convert RED GREEN BLUE colors from sRGB color space to Apple RGB.
  RED, GREEN and BLUE should be between 0.0 and 1.0, inclusive."
    (apply 'pl/color-xyz-to-apple-rgb (color-srgb-to-xyz red green blue)))

  (defun linus/hex-to-apple-rgb-hex (hex)
    (apply #'color-rgb-to-hex
      (apply #'pl/color-srgb-to-apple-rgb (color-name-to-rgb hex))))
  
  (defun linus/moody-slant (direction c1 c2 c3 &optional height)
    (apply
      #'moody-slant
      direction
      (linus/hex-to-apple-rgb-hex c1)
      (linus/hex-to-apple-rgb-hex c2)
      (linus/hex-to-apple-rgb-hex c3)
      height))

    (setq moody-slant-function 'linus/moody-slant)

@Linuus Linuus closed this as completed Mar 6, 2018
tarsius added a commit that referenced this issue Mar 7, 2018
This is a wrapper around `moody-slant' that manipulates the colors
so that they use the equivalent Apple RGB colors instead of the
regular sRGB colors.  This appears to be necessary because Emacs
on macOS uses a color space for XPM images than for other things.

Usage: (setq moody-slant-function #'moody-slant-apple-rgb).

Re #2.

This is a port of the equivalent hack used by Powerline.
See milkypostman/powerline#54
and milkypostman/powerline#141.
@tarsius
Copy link
Owner

tarsius commented Mar 7, 2018

I have decided to add this anyway, but only after stuffing everything into a single function.

tarsius added a commit that referenced this issue Mar 7, 2018
This is a wrapper around `moody-slant' that manipulates the colors
so that they use the equivalent Apple RGB colors instead of the
regular sRGB colors.  This appears to be necessary because Emacs
on macOS uses a color space for XPM images than for other things.

Usage: (setq moody-slant-function #'moody-slant-apple-rgb).

Re #2.

This is a port of the equivalent hack used by Powerline.
See milkypostman/powerline#54
and milkypostman/powerline#141.
@Linuus
Copy link
Author

Linuus commented Mar 7, 2018

Oh, nice! Thanks a lot! :)

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

No branches or pull requests

2 participants