diff --git a/packages/tui-colors-tw/package.json b/packages/tui-colors-tw/package.json index 0694f71..ced9171 100644 --- a/packages/tui-colors-tw/package.json +++ b/packages/tui-colors-tw/package.json @@ -7,6 +7,10 @@ "lint": "prettier --check . && eslint . && publint", "check:publish": "pnpm run lint && " }, + "files": [ + "index.js", + "colors.js" + ], "author": "", "license": "MIT", "peerDependencies": { diff --git a/packages/tui-colors-tw/tui-color-gen/colors/__init__.py b/packages/tui-colors-tw/tui-color-gen/colors/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/packages/tui-colors-tw/tui-color-gen/colors/base_colors.py b/packages/tui-colors-tw/tui-color-gen/colors/base_colors.py new file mode 100644 index 0000000..69d1e4b --- /dev/null +++ b/packages/tui-colors-tw/tui-color-gen/colors/base_colors.py @@ -0,0 +1,9 @@ +from color import TUI_Color + +colors = [ + TUI_Color( + 'step-base', + (248, 248, 248), + (15, 15, 15) + ) +] diff --git a/packages/tui-colors-tw/tui-color-gen/colors/color.py b/packages/tui-colors-tw/tui-color-gen/colors/color.py new file mode 100644 index 0000000..7dd0aa3 --- /dev/null +++ b/packages/tui-colors-tw/tui-color-gen/colors/color.py @@ -0,0 +1,8 @@ +from dataclasses import dataclass + + +@dataclass +class TUI_Color: + name: str + light: tuple[int, int, int] + dark: tuple[int, int, int] diff --git a/packages/tui-colors-tw/tui-color-gen/colors/export.py b/packages/tui-colors-tw/tui-color-gen/colors/export.py new file mode 100644 index 0000000..14e2544 --- /dev/null +++ b/packages/tui-colors-tw/tui-color-gen/colors/export.py @@ -0,0 +1,100 @@ +from generate_colors import colors +from generate_step_colors_two_parts import colors as colors_steps +from base_colors import colors as colors_base + +colors = [*colors_base, *colors_steps, *colors] + +# CSS Colors + +colors_rgb_light = [ + f"--{color.name}-rgb-light: {color.light[0]}, {color.light[1]}, {color.light[2]};" for color in colors +] +color_rgbs_dark = [ + f"--{color.name}-rgb-dark: {color.dark[0]}, {color.dark[1]}, {color.dark[2]};" for color in colors +] + +colors_light = [ + f"--{color.name}-light: rgb(var(--{color.name}-rgb-light));" for color in colors +] +colors_dark = [ + f"--{color.name}-dark: rgb(var(--{color.name}-rgb-dark));" for color in colors +] + +colors_rgb_if_light = [ + f"--{color.name}-rgb: var(--{color.name}-rgb-light);" for color in colors +] +colors_rgb_if_dark = [ + f"--{color.name}-rgb: var(--{color.name}-rgb-dark);" for color in colors +] + +colors_def = [ + f"--{color.name}: rgb(var(--{color.name}-rgb));" for color in colors +] + +# Tailwind Color Config + +tailwind_config_colors_light = [ + f"\"{color.name}-light\": \"rgb(var(--{color.name}-rgb-light), )\"," for color in colors +] +tailwind_config_colors_dark = [ + f"\"{color.name}-dark\": \"rgb(var(--{color.name}-rgb-dark), )\"," for color in colors +] +tailwind_config_colors = [ + f"\"{color.name}\": \"rgb(var(--{color.name}-rgb), )\"," for color in colors +] + +# Export format + +content_colors_rgb_light = "\n".join(colors_rgb_light) +content_color_rgbs_dark = "\n".join(color_rgbs_dark) +content_colors_light = "\n".join(colors_light) +content_colors_dark = "\n".join(colors_dark) +content_colors_rgb_if_light = "\n".join(colors_rgb_if_light) +content_colors_rgb_if_dark = "\n".join(colors_rgb_if_dark) +content_colors_def = "\n".join(colors_def) + +content = f""" +html {{ +{content_colors_rgb_light} +}} + +html {{ +{content_color_rgbs_dark} +}} + +html {{ +{content_colors_light} +}} + +html {{ +{content_colors_dark} +}} + +html {{ +{content_colors_rgb_if_light} +}} + +html.dark {{ +{content_colors_rgb_if_dark} +}} + +html {{ +{content_colors_def} +}} +""" + +content_tailwind_config_colors_light = "\n".join(tailwind_config_colors_light) +content_tailwind_config_colors_dark = "\n".join(tailwind_config_colors_dark) +content_tailwind_config_colors = "\n".join(tailwind_config_colors) + +content_tailwind = f""" +{content_tailwind_config_colors_light} +{content_tailwind_config_colors_dark} +{content_tailwind_config_colors} +""" + +with open('../export/colors.css', 'w') as f: + f.write(content) + +with open('../export/tailwind-colors.txt', 'w') as f: + f.write(content_tailwind) diff --git a/packages/tui-colors-tw/tui-color-gen/colors/generate_colors.py b/packages/tui-colors-tw/tui-color-gen/colors/generate_colors.py new file mode 100644 index 0000000..c1127b2 --- /dev/null +++ b/packages/tui-colors-tw/tui-color-gen/colors/generate_colors.py @@ -0,0 +1,118 @@ +from pprint import pprint +from dataclasses import dataclass +from colour import Color +import numpy as np + +from color import TUI_Color + + +with open("../source-colors-from-apple.txt", "r") as f: + source_colors = f.readlines() +source_colors = [x.strip() for x in source_colors] + +LINES_PER_COLOR = 7 +count_colors = len(source_colors) // LINES_PER_COLOR + + +@dataclass +class Local_Color: + name: str + + light_000: Color + dark_000: Color + + light_050: Color + light_100: Color + light_150: Color + light_200: Color + light_250: Color + + dark_050: Color + dark_100: Color + dark_150: Color + dark_200: Color + dark_250: Color + + def __init__(self, name: str, light: Color, dark: Color): + self.name = name + + dark = Color(dark) + dark.set_luminance(dark.get_luminance() * 0.85) + dark.set_saturation(dark.get_saturation() * 0.8) + + self.dark_000 = Color(dark) + self.dark_000.set_luminance(dark.get_luminance() * 1.0) + self.dark_050 = Color(dark) + self.dark_050.set_luminance(dark.get_luminance() * 1.075) + self.dark_100 = Color(dark) + self.dark_100.set_luminance(dark.get_luminance() * 1.1) + self.dark_150 = Color(dark) + self.dark_150.set_luminance(dark.get_luminance() * 1.175) + self.dark_200 = Color(dark) + self.dark_200.set_luminance(dark.get_luminance() * 1.25) + self.dark_250 = Color(dark) + self.dark_250.set_luminance(dark.get_luminance() * 1.325) + + light = Color(light) + light.set_luminance(light.get_luminance() * 1.5) + # light.set_saturation(light.get_saturation() * 0.8) + + self.light_000 = Color(light) + self.light_000.set_luminance(light.get_luminance() * 1.0) + self.light_050 = Color(light) + self.light_050.set_luminance(light.get_luminance() * 0.925) + self.light_100 = Color(light) + self.light_100.set_luminance(light.get_luminance() * 0.9) + self.light_150 = Color(light) + self.light_150.set_luminance(light.get_luminance() * 0.825) + self.light_200 = Color(light) + self.light_200.set_luminance(light.get_luminance() * 0.75) + self.light_250 = Color(light) + self.light_250.set_luminance(light.get_luminance() * 0.675) + + +local_colors: list[Local_Color] = [] +for i in range(count_colors): + source = source_colors[i*LINES_PER_COLOR:i*LINES_PER_COLOR+LINES_PER_COLOR] + (r_light, g_light, b_light) = [int(x[2:]) for x in source[0:3]] + (r_dark, g_dark, b_dark) = [int(x[2:]) for x in source[3:6]] + + name = source[6].split("\t")[0].lower() # "red" | "green" | "blue" + local_colors.append(Local_Color(name, Color(rgb=(r_light/255, g_light/255, b_light/255)), + Color(rgb=(r_dark/255, g_dark/255, b_dark/255)))) + + +colors: list[TUI_Color] = [] +for color in local_colors: + colors.append(TUI_Color( + f'{color.name}-000', + tuple(np.rint(np.array(color.light_000.get_rgb()) * 255).astype(int)), + tuple(np.rint(np.array(color.dark_000.get_rgb()) * 255).astype(int)), + )) + colors.append(TUI_Color( + f'{color.name}-050', + tuple(np.rint(np.array(color.light_050.get_rgb()) * 255).astype(int)), + tuple(np.rint(np.array(color.dark_050.get_rgb()) * 255).astype(int)), + )) + colors.append(TUI_Color( + f'{color.name}-100', + tuple(np.rint(np.array(color.light_100.get_rgb()) * 255).astype(int)), + tuple(np.rint(np.array(color.dark_100.get_rgb()) * 255).astype(int)), + )) + colors.append(TUI_Color( + f'{color.name}-150', + tuple(np.rint(np.array(color.light_150.get_rgb()) * 255).astype(int)), + tuple(np.rint(np.array(color.dark_150.get_rgb()) * 255).astype(int)), + )) + colors.append(TUI_Color( + f'{color.name}-200', + tuple(np.rint(np.array(color.light_200.get_rgb()) * 255).astype(int)), + tuple(np.rint(np.array(color.dark_200.get_rgb()) * 255).astype(int)), + )) + colors.append(TUI_Color( + f'{color.name}-250', + tuple(np.rint(np.array(color.light_250.get_rgb()) * 255).astype(int)), + tuple(np.rint(np.array(color.dark_250.get_rgb()) * 255).astype(int)), + )) + +pprint(colors) diff --git a/packages/tui-colors-tw/tui-color-gen/colors/generate_step_colors_two_parts.py b/packages/tui-colors-tw/tui-color-gen/colors/generate_step_colors_two_parts.py new file mode 100644 index 0000000..7ec81e7 --- /dev/null +++ b/packages/tui-colors-tw/tui-color-gen/colors/generate_step_colors_two_parts.py @@ -0,0 +1,32 @@ +from pprint import pprint +import numpy as np + +from color import TUI_Color + +N_1 = 5 + 5 # 000-450 +N_2 = 5 + 4 # 500-900 +N = N_1 + N_2 + +steps = np.linspace(0, 900, N).astype(int) +print(f'{steps = }') + +values_1 = np.linspace(23, 105, N_1) +values_2 = np.linspace(155, 255, N_2) + +values = np.rint(np.concatenate((values_1, values_2))).astype(int) +print(f'{values = }') + +for val in values: + print(val) + +# Export + +colors = [ + TUI_Color( + f"step-{step:03d}", + (value_light, value_light, value_light), + (value_dark, value_dark, value_dark) + ) + for step, value_light, value_dark in zip(steps, values[::-1], values) +] +pprint(colors) diff --git a/packages/tui-colors-tw/tui-color-gen/convert.py b/packages/tui-colors-tw/tui-color-gen/convert.py new file mode 100644 index 0000000..6859f42 --- /dev/null +++ b/packages/tui-colors-tw/tui-color-gen/convert.py @@ -0,0 +1,112 @@ +from colour import Color +from dataclasses import dataclass + +# with open("source-colors-from-apple.txt", "r") as f: +with open("tweaked-colors-by-tim.txt", "r") as f: + source_colors = f.readlines() +source_colors = [x.strip() for x in source_colors] + +LINES_PER_COLOR = 7 +count_colors = len(source_colors) // LINES_PER_COLOR + + +@dataclass +class TUI_Color: + name: str + + light_000: Color + dark_000: Color + + light_050: Color | None = None + light_100: Color | None = None + light_150: Color | None = None + light_200: Color | None = None + light_250: Color | None = None + + dark_050: Color | None = None + dark_100: Color | None = None + dark_150: Color | None = None + dark_200: Color | None = None + dark_250: Color | None = None + + def __init__(self, name: str, light: Color, dark: Color): + self.name = name + + dark = Color(dark) + dark.set_luminance(dark.get_luminance() * 0.85) + dark.set_saturation(dark.get_saturation() * 0.8) + + self.dark_000 = Color(dark) + self.dark_000.set_luminance(dark.get_luminance() * 1.0) + self.dark_050 = Color(dark) + self.dark_050.set_luminance(dark.get_luminance() * 1.075) + self.dark_100 = Color(dark) + self.dark_100.set_luminance(dark.get_luminance() * 1.1) + self.dark_150 = Color(dark) + self.dark_150.set_luminance(dark.get_luminance() * 1.175) + self.dark_200 = Color(dark) + self.dark_200.set_luminance(dark.get_luminance() * 1.25) + self.dark_250 = Color(dark) + self.dark_250.set_luminance(dark.get_luminance() * 1.325) + + light = Color(light) + light.set_luminance(light.get_luminance() * 1.5) + # light.set_saturation(light.get_saturation() * 0.8) + + self.light_000 = Color(light) + self.light_000.set_luminance(light.get_luminance() * 1.0) + self.light_050 = Color(light) + self.light_050.set_luminance(light.get_luminance() * 0.925) + self.light_100 = Color(light) + self.light_100.set_luminance(light.get_luminance() * 0.9) + self.light_150 = Color(light) + self.light_150.set_luminance(light.get_luminance() * 0.825) + self.light_200 = Color(light) + self.light_200.set_luminance(light.get_luminance() * 0.75) + self.light_250 = Color(light) + self.light_250.set_luminance(light.get_luminance() * 0.675) + + +colors: list[TUI_Color] = [] +for i in range(count_colors): + source = source_colors[i*LINES_PER_COLOR:i*LINES_PER_COLOR+LINES_PER_COLOR] + (r_light, g_light, b_light) = [int(x[2:]) for x in source[0:3]] + (r_dark, g_dark, b_dark) = [int(x[2:]) for x in source[3:6]] + name = source[6].split("\t")[0].lower() + colors.append(TUI_Color(name, Color(rgb=(r_light/255, g_light/255, b_light/255)), + Color(rgb=(r_dark/255, g_dark/255, b_dark/255)))) + + +output: list[str] = [] +for color in colors: + # color.dark_000.set_luminance(color.dark_000.get_luminance() * 0.8) + # color.dark_000.set_saturation(color.dark_000.get_saturation() * 0.8) + # color.dark_100 = Color(color.dark_000) + # color.dark_100.set_luminance(color.dark_100.get_luminance() * 1.1) + # color.dark_200 = Color(color.dark_000) + # color.dark_200.set_luminance(color.dark_200.get_luminance() * 1.25) + + # color.light_000.set_luminance(color.light_000.get_luminance() * 1.4) + # # color.light.set_saturation(color.light.get_saturation() * 0.8) + # color.light_100 = Color(color.light_000) + # color.light_100.set_luminance(color.light_100.get_luminance() * 0.9) + # color.light_200 = Color(color.light_000) + # color.light_200.set_luminance(color.light_200.get_luminance() * 0.75) + + output.append(f'"{color.name}-000": "{color.light_000}",') + output.append(f'"{color.name}-050": "{color.light_050}",') + output.append(f'"{color.name}-100": "{color.light_100}",') + output.append(f'"{color.name}-150": "{color.light_150}",') + output.append(f'"{color.name}-200": "{color.light_200}",') + output.append(f'"{color.name}-250": "{color.light_250}",') + + output.append(f'"{color.name}-000-dark": "{color.dark_000}",') + output.append(f'"{color.name}-050-dark": "{color.dark_050}",') + output.append(f'"{color.name}-100-dark": "{color.dark_100}",') + output.append(f'"{color.name}-150-dark": "{color.dark_150}",') + output.append(f'"{color.name}-200-dark": "{color.dark_200}",') + output.append(f'"{color.name}-250-dark": "{color.dark_250}",') + + +for o in output: + print(o) diff --git a/packages/tui-colors-tw/tui-color-gen/generate_step_colors.py b/packages/tui-colors-tw/tui-color-gen/generate_step_colors.py new file mode 100644 index 0000000..3303cf1 --- /dev/null +++ b/packages/tui-colors-tw/tui-color-gen/generate_step_colors.py @@ -0,0 +1,116 @@ +import numpy as np + +N = 10 + 9 + +steps = np.rint(np.linspace(0, 900, N)) +light_values = np.linspace(255, 23, N) +dark_values = np.linspace(23, 255, N) + +print(light_values) + +# light = [] +dark = [] +for i in range(N-1): + dark.append(dark_values[i]) + dark.append(dark_values[i] + 10) +dark.append(dark_values[N-1]) + +# print(light) +print(dark) + +# light = np.rint(np.array(light)) +dark = np.rint(np.array(dark)) + + +print(steps) +# print(light) +print(dark) + +# ! Linear +# !! Light +# 255 +# 242 +# 229 +# 216 +# 203 +# 191 +# 178 +# 165 +# 152 +# 139 +# 126 +# 113 +# 100 +# 87 +# 75 +# 62 +# 49 +# 36 +# 23 +# !! Dark +# 23 +# 36 +# 49 +# 62 +# 75 +# 87 +# 100 +# 113 +# 126 +# 139 +# 152 +# 165 +# 178 +# 191 +# 203 +# 216 +# 229 +# 242 +# 255 + +# ! Linear but 50s are x1.2 +# !! Dark +# 23 +# 28 +# 49 +# 59 +# 75 +# 89 +# 100 +# 120 +# 126 +# 151 +# 152 +# 182 +# 178 +# 213 +# 203 +# 244 +# 229 +# 275 +# 255 +# 306 +# 255 + + +# ! Linear but 50s are +10 +# !! Dark +# 23 +# 33 +# 49 +# 59 +# 75 +# 85 +# 100 +# 110 +# 126 +# 136 +# 152 +# 162 +# 178 +# 188 +# 203 +# 213 +# 229 +# 239 +# 255 diff --git a/packages/tui-colors-tw/tui-color-gen/plot_array_values.py b/packages/tui-colors-tw/tui-color-gen/plot_array_values.py new file mode 100644 index 0000000..d7ea533 --- /dev/null +++ b/packages/tui-colors-tw/tui-color-gen/plot_array_values.py @@ -0,0 +1,32 @@ +import plotly.graph_objects as go + +# Your data +x = [0, 50, 100, 150, 200, 250, 300, 350, 400, 450, 500, 550, 600, 650, 700, 750, 800, 850, 900] +y = [ + 23, + 32, + 41, + 50, + 59, + 69, + 78, + 87, + 96, + 105, + 155, + 168, + 180, + 192, + 205, + 218, + 230, + 242, + 255, +] + + +# Create a scatter plot +fig = go.Figure(data=go.Scatter(x=x, y=y, mode='markers')) + +# Show the plot +fig.show() diff --git a/packages/tui-colors-tw/tui-color-gen/source-colors-from-apple.txt b/packages/tui-colors-tw/tui-color-gen/source-colors-from-apple.txt new file mode 100644 index 0000000..bab9c2a --- /dev/null +++ b/packages/tui-colors-tw/tui-color-gen/source-colors-from-apple.txt @@ -0,0 +1,91 @@ +R 194 +G 6 +B 24 +R 255 +G 65 +B 54 +Red systemRedColor +R 173 +G 58 +B 0 +R 255 +G 179 +B 64 +Orange systemOrangeColor +R 146 +G 81 +B 0 +R 255 +G 212 +B 38 +Yellow systemYellowColor +R 0 +G 112 +B 24 +R 49 +G 222 +B 75 +Green systemGreenColor +R 11 +G 117 +B 112 +R 102 +G 212 +B 207 +Mint systemMintColor +R 0 +G 119 +B 140 +R 93 +G 230 +B 255 +Teal systemTealColor +R 0 +G 103 +B 150 +R 112 +G 215 +B 255 +Cyan systemCyanColor +R 0 +G 64 +B 221 +R 64 +G 156 +B 255 +Blue systemBlueColor +R 54 +G 52 +B 163 +R 125 +G 122 +B 255 +Indigo systemIndigoColor +R 173 +G 68 +B 171 +R 218 +G 143 +B 255 +Purple systemPurpleColor +R 193 +G 16 +B 50 +R 255 +G 58 +B 95 +Pink systemPinkColor +R 119 +G 93 +B 59 +R 181 +G 148 +B 105 +Brown systemBrownColor +R 97 +G 97 +B 101 +R 152 +G 152 +B 157 +Gray systemGrayColor diff --git a/packages/tui-colors-tw/tui-color-gen/step-colors.txt b/packages/tui-colors-tw/tui-color-gen/step-colors.txt new file mode 100644 index 0000000..f2737f6 --- /dev/null +++ b/packages/tui-colors-tw/tui-color-gen/step-colors.txt @@ -0,0 +1,31 @@ +// --step-base-rgb: 250, 250, 250; +255 +246 +240 +233 +214 +204 +196 +183 +163 +115 +66 +49 +33 +23 + +// --step-base-rgb: 15, 15, 15; +23 +32 +38 +45 +64 +74 +82 +95 +115 +163 +212 +229 +245 +255