Skip to content

Commit

Permalink
Color palettes
Browse files Browse the repository at this point in the history
  • Loading branch information
crzdg committed Oct 1, 2022
1 parent a7dd15a commit 4ef0473
Show file tree
Hide file tree
Showing 6 changed files with 223 additions and 42 deletions.
60 changes: 18 additions & 42 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@ React with typescript example
Telescope theme inspired by https://github.com/NvChad/NvChad (You have to enable it via config variable)
![telescope-theme](https://user-images.githubusercontent.com/31720261/151669762-1470aa12-b6ff-47c1-a4e9-ec9b37e0eabe.png)

#### Data from images:

Font: **Jetbrains Mono patched with nerd fonts**

Terminal: https://github.com/wez/wezterm

## ⚙️ Installation

```vim
Expand Down Expand Up @@ -134,47 +128,29 @@ require('lualine').setup {
}
}
```
## 👽 Extras

Extra color configs for **iTerm2** can be found on [extras](extras/)

## 🌈 Palette

![gruvbox palette](https://user-images.githubusercontent.com/31720261/147415431-13f6c6af-2f76-46c9-8448-20c71e359fc5.png)
### 👶 Medium Intensity
![gruvbox-baby medium](extras/palettes/medium.svg)

```
dark = "#202020",
foreground = "#ebdbb2",
background = "#282828",
background_dark = "#242424",
background_light = "#32302f",
medium_gray = "#504945",
comment = "#665c54",
gray = "#DEDEDE",
soft_yellow = "#EEBD35",
soft_green = "#98971a",
bright_yellow = "#fabd2f",
orange = "#d65d0e",
red = "#fb4934",
error_red = "#cc241d",
magenta = "#b16286",
pink = "#D4879C",
light_blue = "#7fa2ac",
dark_gray = "#83a598",
blue_gray = "#458588",
forest_green = "#689d6a",
clean_green = "#8ec07c",
milk = "#E7D7AD",
-- Dark theme changes colors to
["dark"] = {
dark = "#161616",
background = "#202020",
background_dark = "#161616",
},
```
## Aknowledgments
### 🎱 Dark Intensity
![gruvbox-baby dark](extras/palettes/dark.svg)

### 🍦 Soft Intensity
![gruvbox-baby soft](extras/palettes/soft.svg)

### 🥿 Soft Flat Intensity
![gruvbox-baby soft flat](extras/palettes/soft_flat.svg)

## 👽 Extras

Extra color configs for **iTerm2** can be found on [extras](extras/)

## 👆 Acknowledgments

- Shutout to @ThePrimeagen for the inspiration for the plugin name, Gruvbox baby!
- I based my structure on https://github.com/folke/tokyonight.nvim (and also copied some of it)
- The all father 👴 https://github.com/morhetz/gruvbox
- Used terminal wezterm https://github.com/wez/wezterm
- Used font: **Jetbrains Mono patched with nerd fonts**
201 changes: 201 additions & 0 deletions extras/create_palette.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
from collections import OrderedDict, defaultdict
from copy import copy
from tempfile import TemporaryFile
from typing import Tuple

import svgwrite

colors: OrderedDict = OrderedDict(
the_palette=OrderedDict(
dark0="#0d0e0f",
dark="#202020",
background_dark="#1d2021",
background="#282828",
background_light="#32302f",
foreground="#ebdbb2",
gray="#dedede",
medium_gray="#504945",
comment="#665c54",
milk="#e7d7ad",
error_red="#cc241d",
red="#fb4934",
orange="#d65d0e",
bright_yellow="#fabd2f",
soft_yellow="#eebd35",
pink="#d4879c",
magenta="#b16286",
soft_green="#98971a",
forest_green="#689d6a",
clean_green="#8ec07c",
blue_gray="#458588",
dark_gray="#83a598",
light_blue="#7fa2ac",
),
intensities=OrderedDict(
dark=OrderedDict(
dark="#0d0e0f",
background_dark="#171A1A",
background="#1d2021",
),
soft_flat=OrderedDict(
background="#32302f", background_dark="#32302f", background_light="#3c3a39"
),
soft=OrderedDict(
background="#32302f", background_dark="#282626", background_light="#3c3a39"
),
medium=OrderedDict(background="#282828", background_dark="#242424"),
),
)


text_colors: dict = defaultdict(lambda: None)

INVERSE_COLOR = "milk"
text_colors["dark0"] = colors["the_palette"][INVERSE_COLOR]
text_colors["dark"] = colors["the_palette"][INVERSE_COLOR]
text_colors["background_dark"] = colors["the_palette"][INVERSE_COLOR]
text_colors["background"] = colors["the_palette"][INVERSE_COLOR]
text_colors["background_light"] = colors["the_palette"][INVERSE_COLOR]

X_PLANE = 1920
Y_PLANE = 1080
COLOR_BOX_X = 280
COLOR_BOX_Y = 160
START_X = 0
START_Y = 0
X_MARGIN_RIGHT = 80
Y_MARGIN_TOP = 45
COLOR_BOX_RX = 20
COLOR_BOX_RY = 20


def hex_to_rgb(hex_string: str) -> str:
hex_ = hex_string.lstrip("#")
rgb = tuple(int(hex_[i : i + 2], 16) for i in (0, 2, 4))
return f"rgb({rgb[0]},{rgb[1]},{rgb[2]})"


def draw_background(
dwg: svgwrite.Drawing,
color: str,
) -> None:
dwg.add(
dwg.rect(
insert=(0, 0),
size=(X_PLANE, Y_PLANE),
fill=hex_to_rgb(color),
)
)


def draw_text(
dwg: svgwrite.Drawing,
color_name: str,
color_value: str,
default_text_color: str,
x: int,
y: int,
):
text_color = text_colors[color_name]
if text_color is None:
text_color = default_text_color
dwg.add(
svgwrite.text.Text(
color_name.replace("_", " "),
insert=(x + 25, y + 35),
fill=hex_to_rgb(text_color),
font_size="28px",
font_weight="bold",
)
)
dwg.add(
svgwrite.text.Text(
color_value,
insert=(x + 25, y + COLOR_BOX_Y - 15),
fill=hex_to_rgb(text_color),
font_size="28px",
)
)


def create_color_box(
dwg: svgwrite.Drawing,
color_name: str,
color_value: str,
default_text_color: str,
x: int,
y: int,
) -> None:
dwg.add(
dwg.rect(
insert=(x, y),
size=(COLOR_BOX_X, COLOR_BOX_Y),
rx=COLOR_BOX_RX,
ry=COLOR_BOX_RY,
fill=hex_to_rgb(color_value),
stroke=hex_to_rgb(colors["the_palette"]["comment"]),
stroke_width=5,
)
)
draw_text(dwg, color_name, color_value, default_text_color, x, y)


def max_x() -> int:
return X_PLANE - COLOR_BOX_X - X_MARGIN_RIGHT


def max_y() -> int:
return Y_PLANE - COLOR_BOX_Y - Y_MARGIN_TOP


def move_position(x: int, y: int) -> Tuple[int, int]:
new_x = x + COLOR_BOX_X + X_MARGIN_RIGHT
new_y = y
if new_x > max_x():
new_y = y + Y_MARGIN_TOP + COLOR_BOX_Y
new_x = START_X + X_MARGIN_RIGHT
return new_x, new_y


def draw_intensity_map_text(
dwg: svgwrite.Drawing, intensity_string: str, x: int, y: int
) -> None:
dwg.add(
svgwrite.text.Text(
intensity_string,
insert=(x + 25, y + 3 * (COLOR_BOX_Y / 4)),
fill=colors["the_palette"]["milk"],
font_size="96px",
font_weight="bold",
)
)


def create_palette(palette_dict: dict, name: str) -> None:
svg_file = TemporaryFile("r+", encoding="utf-8")
dwg = svgwrite.Drawing(svg_file, profile="tiny", size=(1920, 1080))

current_x = START_X + X_MARGIN_RIGHT
current_y = START_Y + Y_MARGIN_TOP

draw_background(dwg, palette_dict["background"])
for color_name, color_value in palette_dict.items():
create_color_box(
dwg, color_name, color_value, palette["background"], current_x, current_y
)
current_x, current_y = move_position(current_x, current_y)
draw_intensity_map_text(dwg, name, current_x, current_y)
with open(f"palettes/{name}.svg", "w", encoding="utf-8") as file:
file.write(dwg.tostring())


if __name__ == "__main__":
print("To run the 'svgwrite' package needs to be installed!")
print("To install: pip install svgwrite")
print("https://pypi.org/project/svgwrite/")
for intensity, value in colors["intensities"].items():
print(f"Creating palette for intensity: {intensity} ...")
palette = copy(colors["the_palette"])
palette.update(value)
create_palette(palette, intensity)
print("Done!")
1 change: 1 addition & 0 deletions extras/palettes/dark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 4ef0473

Please sign in to comment.