Giter Site home page Giter Site logo

Comments (15)

ema2159 avatar ema2159 commented on June 29, 2024 1

@neeasade hey! Thanks! Yeah, I discovered these a little bit too late. They should do the work, however, I'm not sure if this PR will still be accepted though. I think the best thing to do is to redo it. I was quite inexperienced with elisp back then (still am, but a little bit less).

from base16-emacs.

belak avatar belak commented on June 29, 2024

Having a lighten and darken function is something I’ve considered for the diff functionality as well. I would accept a PR to add this.

from base16-emacs.

belak avatar belak commented on June 29, 2024

On a side note, why would it need to be darker than base00?

from base16-emacs.

ema2159 avatar ema2159 commented on June 29, 2024

Having a lighten and darken function is something I’ve considered for the diff functionality as well. I would accept a PR to add this.

I know how to do this, but in Elisp it's a little bit harder because there's no function for converting hex to rgb, though there's a way to convert it backwards. I'll implement it as soon as I can

from base16-emacs.

ema2159 avatar ema2159 commented on June 29, 2024

On a side note, why would it need to be darker than base00?

The principle of Solaire mode is to dim the non editing buffers to give contrast. Though sometimes in certain themes some authors do lighten instead of darken the theme (i.e. doom-iovskem) that just happens for themes that are too dark, the usual and in my personal opinion more aesthetic way to go is to darken the non editing buffers.

from base16-emacs.

belak avatar belak commented on June 29, 2024

Is there another format it could be in that would make it easier? I could change the generated templates to include the data in another format if needed.

from base16-emacs.

ema2159 avatar ema2159 commented on June 29, 2024

Is there another format it could be in that would make it easier? I could change the generated templates to include the data in another format if needed.

I think we'd have to transform base 16 in base 18 😅. What did you have in mind?

from base16-emacs.

belak avatar belak commented on June 29, 2024

You mentioned the conversion from hex to rgb not existing in elisp - I could update the provided color variables exposed to also provide rgb values. (See http://chriskempson.com/projects/base16/#template-variables)

from base16-emacs.

ema2159 avatar ema2159 commented on June 29, 2024

You mentioned the conversion from hex to rgb not existing in elisp - I could update the provided color variables exposed to also provide rgb values. (See http://chriskempson.com/projects/base16/#template-variables)

Ok, I think I only need the rgb value for the base00, however I don't know if it would be needed for the others in the future so you can decide. From there is just multiply the r, g and b of the base00 for a certain factor (it could be 0.5 for darkening and 1.5 for lightening, though I'd like to try some and then we can decide) and generate the new, darker version of base00 for solaire-default/any other face that needs it.

from base16-emacs.

belak avatar belak commented on June 29, 2024

After playing with it, I'd rather not go this route - https://github.com/belak/base16-emacs/tree/rgb-experiment

It's pretty ugly and introduces data duplication. Unfortunately, I think it would make more sense to have functions for converting from rgb to hex and back..

from base16-emacs.

ema2159 avatar ema2159 commented on June 29, 2024

Yes , the latter one already exist (no clue why the function for converting from hex to rgb doen't exist but from rgb to hex does) so let's start from there. I should go like this, take for example the following hex color: #ABCD12, the RGB would be (AB, CD, 12) converted to decimal if I'm not wrong.

from base16-emacs.

belak avatar belak commented on June 29, 2024

Right, so (171, 205, 18)

from base16-emacs.

ema2159 avatar ema2159 commented on June 29, 2024
(defun base16-hex-to-rgb (hexcolor)
  `(,(string-to-number (substring hexcolor 1 3) 16)
    ,(string-to-number (substring hexcolor 3 5) 16)
    ,(string-to-number (substring hexcolor 5 7) 16)))

There ya go, it was easier than expected.
When using"#191970" as the argument it returns (25 25 112) as expected

I think that I'll be finishing all the implementation of the darken/lighting functions and solaire-mode tomorrow maybe at the end of the morning.

from base16-emacs.

belak avatar belak commented on June 29, 2024

I pushed the functions to a branch called color-darken if you want to play with it a bit more.

from base16-emacs.

neeasade avatar neeasade commented on June 29, 2024

necrobump! I've been playing much with emacs builtin color.el this past week and would like to share some stuff I found.

@ema2159 I learned that emacs ships with conversion functions for hex and rgb (though it uses 0.0 - 1.0 instead of 0-{FF or FFFF}), and some helper functions for lightening and darkening colors. EG:

(require 'color)

(color-name-to-rgb "#999999")
;; => (0.6 0.6 0.6)

;; darken and lighten take percents:
(color-darken-name "#999999" 5)
;; => "#8ccc8ccc8ccc"

(color-lighten-name "#999999" 5)
;; => "#a665a665a665"


;; convert a color to RGB , add some blue, convert it back:
(->> (color-name-to-rgb "#999999")
  (apply (lambda (R G B)
           ;; RGB are all in a 0.0-1.0 range
           (list R G (+ 0.2 B))))
  (apply 'color-rgb-to-hex))
;; => "#99999999cccc"

I'm not sure what the minimum emacs version is for color.el, the copyright is 2010. It's got some other helpers for working with other colorspaces as well (HSL/HSV, LAB/LCH).

On top of these I built some helpers (feel free to steal) for comparing colors and "tweaking" them in different colorspaces while I tried things, which is currently culminating on a bootstrap using the base16 builder (thanks for your awesome work/wide package coverage, @belak)

Of interest to the base16 repo might be the contrast comparison stuff (ns/color-contrast-ratio, ns/color-iterate) - you could then EG enforce a minimum contrast between colors.

from base16-emacs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.