Skip to content
GitLab
  • Menu
Projects Groups Snippets
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
    • Switch to GitLab Next
  • Sign in / Register
  • modus-themes modus-themes
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 9
    • Issues 9
    • List
    • Boards
    • Service Desk
    • Milestones
    • Requirements
  • Merge requests 1
    • Merge requests 1
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages & Registries
    • Packages & Registries
    • Package Registry
    • Container Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Protesilaos Stavrou
  • modus-themesmodus-themes
  • Issues
  • #269
Closed
Open
Created Dec 30, 2021 by Alex Griffin@ajgrfContributor

Programatic color palette blending

Just thought I would share a little snippet I put together for my Emacs configuration (obviously based on code that's already in the manual). It blends a theme's palette with a given pair of colors, one for the background colors and one for the foreground colors. The colors I chose here give modus-themes a yellowish, Gruvbox-esque tint.

(setq modus-operandi-bg-blend "#fbf1c7"
      modus-operandi-fg-blend "#3a4042"
      modus-vivendi-bg-blend "#3a4042"
      modus-vivendi-fg-blend "#d7b765")

(defun modus-themes-tint-palette (palette bg-blend fg-blend)
  "Modify Modus PALETTE programmatically and return a new palette.
Blend background colors with BG-BLEND and foreground colors with FG-BLEND."
  (require 'kurecolor)
  (let (name cons colors)
    (dolist (cons palette)
      (let ((blend (if (string-match "bg" (symbol-name (car cons)))
                       bg-blend
                     fg-blend)))
        (setq name (kurecolor-interpolate (cdr cons) blend)))
      (setq name (format "%s" name))
      (setq cons `(,(car cons) . ,name))
      (push cons colors))
    colors))

(define-minor-mode modus-themes-tinted-mode
  "Tweak some Modus themes colors."
  :init-value nil
  :global t
  (if modus-themes-tinted-mode
      (setq modus-themes-operandi-color-overrides
            (modus-themes-tint-palette modus-themes-operandi-colors
                                       modus-operandi-bg-blend
                                       modus-operandi-fg-blend)
            modus-themes-vivendi-color-overrides
            (modus-themes-tint-palette modus-themes-vivendi-colors
                                       modus-vivendi-bg-blend
                                       modus-vivendi-fg-blend))
    (setq modus-themes-operandi-color-overrides nil
          modus-themes-vivendi-color-overrides nil)))

(modus-themes-tinted-mode 1)

(Instead of kurecolor-interpolate, you can also use doom-blend from doom-themes.)

Edited Dec 30, 2021 by Alex Griffin
Assignee
Assign to
Time tracking