├── .gitignore ├── LICENSE ├── README.md ├── pencils ├── __init__.py ├── _color.py ├── _colors.py ├── _hsl.py ├── _palette.py ├── _palettes.py ├── _registry.py ├── _rgb.py └── py.typed └── pyproject.toml /.gitignore: -------------------------------------------------------------------------------- 1 | __pycache__/ 2 | .*_cache/ 3 | /dist/ 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | 2022 Gram 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included 13 | in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # pencils 2 | 3 | Pancils is a Python library with a colletion of color palettes. 4 | 5 | Currently available palettes: 6 | 7 | + Everything from [flatuicolors.com](https://flatuicolors.com/) 8 | + Most of the palettes from [materialui.co](https://materialui.co/) 9 | + [Tailwind](https://tailwindcss.com/) color palette. 10 | + [Bootstrap](https://getbootstrap.com/) color palette. 11 | + CSS (HTML) color names. 12 | 13 | Features: 14 | 15 | + A lot of colors from manually picked palettes. 16 | + 100% type safe. 17 | + Best integration with IDEs, autocomplete all the way down. 18 | + Includes multiple representations (HEX, [RGB](https://en.wikipedia.org/wiki/RGB_color_model), [HSL](https://en.wikipedia.org/wiki/HSL_and_HSV)) for each color. 19 | + Zero-dependency. 20 | 21 | Installatiion: 22 | 23 | ```bash 24 | python3 -m pip install pencils 25 | ``` 26 | 27 | ## Usage 28 | 29 | Get the hex representation of "Sunflower" color from [Dutch Palette](https://flatuicolors.com/palette/nl) of [Flat UI Colors](https://flatuicolors.com/): 30 | 31 | ```python 32 | import pencils 33 | 34 | pencils.NLPalette.colors.sunflower.value.hex 35 | # 'FFC312' 36 | ``` 37 | 38 | ![#ffc312](https://via.placeholder.com/15/ffc312/000000?text=+) 39 | 40 | That's a lot of attributes and each one of them has a meaning: 41 | 42 | 1. `NLPalette` is an instance of the `pencils.Palette` class which holds information about palette name, author, source URL, and even emojis associated with the palette. 43 | 1. `colors` attribute is an [enum](https://docs.python.org/3/library/enum.html), a subclass of `pencils.Colors`. 44 | 1. `sunflower` is the color ID. 45 | 1. `value` is used to get the value of the enum. The value is an instance of `pencils.Color` class which contains operations on colors. 46 | 1. `hex` is a lowercase hex representaion of the color without `#`. 47 | 48 | Make the color darker: 49 | 50 | ```python 51 | color = pencils.NLPalette.colors.sunflower.value.hsl 52 | color.lightness = .2 53 | color.hex 54 | # '664c00' 55 | ``` 56 | 57 | ![#664c00](https://via.placeholder.com/15/664c00/000000?text=+) 58 | 59 | Get random color from a random palette: 60 | 61 | ```python 62 | pencils.random_palette().random_color() 63 | # Color(name='Unmellow Yellow', hex='fffa65') 64 | ``` 65 | 66 | ![#fffa65](https://via.placeholder.com/15/fffa65/000000?text=+) 67 | -------------------------------------------------------------------------------- /pencils/__init__.py: -------------------------------------------------------------------------------- 1 | """A collection of color palettes. 2 | """ 3 | from ._palette import Palette 4 | from ._palettes import ( 5 | DefoPalette, 6 | NLPalette, 7 | TRPalette, 8 | INPalette, 9 | SEPalette, 10 | CAPalette, 11 | AUPalette, 12 | RUPalette, 13 | FRPalette, 14 | ESPalette, 15 | DEPalette, 16 | CNPalette, 17 | USPalette, 18 | GBPalette, 19 | SocialPalette, 20 | MetroPalette, 21 | CSSPalette, 22 | TailwindPalette, 23 | BootstrapPalette, 24 | ) 25 | from ._color import Color 26 | from ._colors import Colors 27 | from ._hsl import HSL 28 | from ._rgb import RGB 29 | from ._registry import random_palette, PALETTES 30 | 31 | 32 | __version__ = "0.1.0" 33 | __all__ = [ 34 | 'DefoPalette', 35 | 'NLPalette', 36 | 'TRPalette', 37 | 'INPalette', 38 | 'SEPalette', 39 | 'CAPalette', 40 | 'AUPalette', 41 | 'RUPalette', 42 | 'FRPalette', 43 | 'ESPalette', 44 | 'DEPalette', 45 | 'CNPalette', 46 | 'USPalette', 47 | 'GBPalette', 48 | 'SocialPalette', 49 | 'MetroPalette', 50 | 'CSSPalette', 51 | 'TailwindPalette', 52 | 'BootstrapPalette', 53 | 54 | 'Palette', 55 | 'Color', 56 | 'Colors', 57 | 'Palettes', 58 | 'HSL', 59 | 'RGB', 60 | 'random_palette', 61 | 'PALETTES', 62 | ] 63 | -------------------------------------------------------------------------------- /pencils/_color.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from colorsys import rgb_to_hls 3 | from dataclasses import dataclass 4 | from functools import cached_property 5 | from ._rgb import RGB 6 | from ._hsl import HSL 7 | 8 | 9 | @dataclass 10 | class Color: 11 | name: str 12 | hex: str 13 | 14 | @cached_property 15 | def rgb(self) -> RGB: 16 | assert len(self.hex) == 6 17 | return RGB( 18 | int(self.hex[:2], 16), 19 | int(self.hex[2:4], 16), 20 | int(self.hex[4:], 16), 21 | ) 22 | 23 | @cached_property 24 | def hsl(self) -> HSL: 25 | rgb = self.rgb 26 | hue, ls, sat = rgb_to_hls(rgb.red_float, rgb.green_float, rgb.blue_float) 27 | return HSL(hue, sat, ls) 28 | 29 | @property 30 | def hls(self) -> HSL: 31 | return self.hsl 32 | -------------------------------------------------------------------------------- /pencils/_colors.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from enum import Enum 3 | from random import choice 4 | from ._color import Color 5 | 6 | 7 | class Colors(Enum): 8 | @classmethod 9 | def random_color(cls) -> Color: 10 | return choice(list(cls)).value # type: ignore 11 | 12 | 13 | class DefoColors(Colors): 14 | turquoise = Color(name="Turquoise", hex="1abc9c") 15 | emerald = Color(name="Emerald", hex="2ecc71") 16 | peter_river = Color(name="Peter river", hex="3498db") 17 | amethyst = Color(name="Amethyst", hex="9b59b6") 18 | wet_asphalt = Color(name="Wet Asphalt", hex="34495e") 19 | green_sea = Color(name="Green Sea", hex="16a085") 20 | nephritis = Color(name="Nephritis", hex="27ae60") 21 | belize_hole = Color(name="Belize Hole", hex="2980b9") 22 | wisteria = Color(name="Wisteria", hex="8e44ad") 23 | midnight_blue = Color(name="Midnight Blue", hex="2c3e50") 24 | sun_flower = Color(name="Sun Flower", hex="f1c40f") 25 | carrot = Color(name="Carrot", hex="e67e22") 26 | alizarin = Color(name="Alizarin", hex="e74c3c") 27 | clouds = Color(name="Clouds", hex="ecf0f1") 28 | concrete = Color(name="Concrete", hex="95a5a6") 29 | orange = Color(name="Orange", hex="f39c12") 30 | pumpkin = Color(name="Pumpkin", hex="d35400") 31 | pomegranate = Color(name="Pomegranate", hex="c0392b") 32 | silver = Color(name="Silver", hex="bdc3c7") 33 | asbestos = Color(name="Asbestos", hex="7f8c8d") 34 | 35 | 36 | class USColors(Colors): 37 | light_greenish_blue = Color(name="Light Greenish Blue", hex="55efc4") 38 | faded_poster = Color(name="Faded Poster", hex="81ecec") 39 | green_darner_tail = Color(name="Green Darner Tail", hex="74b9ff") 40 | shy_moment = Color(name="Shy Moment", hex="a29bfe") 41 | city_lights = Color(name="City Lights", hex="dfe6e9") 42 | mint_leaf = Color(name="Mint Leaf", hex="00b894") 43 | robins_egg_blue = Color(name="Robin's Egg Blue", hex="00cec9") 44 | electron_blue = Color(name="Electron Blue", hex="0984e3") 45 | exodus_fruit = Color(name="Exodus Fruit", hex="6c5ce7") 46 | soothing_breeze = Color(name="Soothing Breeze", hex="b2bec3") 47 | sour_lemon = Color(name="Sour Lemon", hex="ffeaa7") 48 | first_date = Color(name="First Date", hex="fab1a0") 49 | pink_glamour = Color(name="Pink Glamour", hex="ff7675") 50 | pico_8_pink = Color(name="Pico-8 Pink", hex="fd79a8") 51 | american_river = Color(name="American River", hex="636e72") 52 | bright_yarrow = Color(name="Bright Yarrow", hex="fdcb6e") 53 | orangeville = Color(name="Orangeville", hex="e17055") 54 | chi_gong = Color(name="Chi-Gong", hex="d63031") 55 | prunus_avium = Color(name="Prunus Avium", hex="e84393") 56 | dracula_orchid = Color(name="Dracula Orchid", hex="2d3436") 57 | 58 | 59 | class AUColors(Colors): 60 | beekeeper = Color(name="Beekeeper", hex="f6e58d") 61 | spiced_nectarine = Color(name="Spiced Nectarine", hex="ffbe76") 62 | pink_glamour = Color(name="Pink Glamour", hex="ff7979") 63 | june_bud = Color(name="June Bud", hex="badc58") 64 | coastal_breeze = Color(name="Coastal Breeze", hex="dff9fb") 65 | turbo = Color(name="Turbo", hex="f9ca24") 66 | quince_jelly = Color(name="Quince Jelly", hex="f0932b") 67 | carmine_pink = Color(name="Carmine Pink", hex="eb4d4b") 68 | pure_apple = Color(name="Pure Apple", hex="6ab04c") 69 | hint_of_ice_pack = Color(name="Hint of Ice Pack", hex="c7ecee") 70 | middle_blue = Color(name="Middle Blue", hex="7ed6df") 71 | heliotrope = Color(name="Heliotrope", hex="e056fd") 72 | exodus_fruit = Color(name="Exodus Fruit", hex="686de0") 73 | deep_koamaru = Color(name="Deep Koamaru", hex="30336b") 74 | soaring_eagle = Color(name="Soaring Eagle", hex="95afc0") 75 | greenland_green = Color(name="Greenland Green", hex="22a6b3") 76 | steel_pink = Color(name="Steel Pink", hex="be2edd") 77 | blurple = Color(name="Blurple", hex="4834d4") 78 | deep_cove = Color(name="Deep Cove", hex="130f40") 79 | wizard_grey = Color(name="Wizard Grey", hex="535c68") 80 | 81 | 82 | class GBColors(Colors): 83 | protoss_pylon = Color(name="Protoss Pylon", hex="00a8ff") 84 | periwinkle = Color(name="Periwinkle", hex="9c88ff") 85 | rise_n_shine = Color(name="Rise-N-Shine", hex="fbc531") 86 | download_progress = Color(name="Download Progress", hex="4cd137") 87 | seabrook = Color(name="Seabrook", hex="487eb0") 88 | vanadyl_blue = Color(name="Vanadyl Blue", hex="0097e6") 89 | matt_purple = Color(name="Matt Purple", hex="8c7ae6") 90 | nanohanacha_gold = Color(name="Nanohanacha Gold", hex="e1b12c") 91 | skirret_green = Color(name="Skirret Green", hex="44bd32") 92 | naval = Color(name="Naval", hex="40739e") 93 | nasturcian_flower = Color(name="Nasturcian Flower", hex="e84118") 94 | lynx_white = Color(name="Lynx White", hex="f5f6fa") 95 | blueberry_soda = Color(name="Blueberry Soda", hex="7f8fa6") 96 | mazarine_blue = Color(name="Mazarine Blue", hex="273c75") 97 | blue_nights = Color(name="Blue Nights", hex="353b48") 98 | harley_davidson_orange = Color(name="Harley Davidson Orange", hex="c23616") 99 | hint_of_pensive = Color(name="Hint of Pensive", hex="dcdde1") 100 | chain_gang_grey = Color(name="Chain Gang Grey", hex="718093") 101 | pico_void = Color(name="Pico Void", hex="192a56") 102 | electromagnetic = Color(name="Electromagnetic", hex="2f3640") 103 | 104 | 105 | class CAColors(Colors): 106 | jigglypuff = Color(name="Jigglypuff", hex="ff9ff3") 107 | casandora_yellow = Color(name="Casandora Yellow", hex="feca57") 108 | pastel_red = Color(name="Pastel Red", hex="ff6b6b") 109 | megaman = Color(name="Megaman", hex="48dbfb") 110 | wild_caribbean_green = Color(name="Wild Caribbean Green", hex="1dd1a1") 111 | lian_hong_lotus_pink = Color(name="Lián Hóng Lotus Pink", hex="f368e0") 112 | double_dragon_skin = Color(name="Double Dragon Skin", hex="ff9f43") 113 | amour = Color(name="Amour", hex="ee5253") 114 | cyanite = Color(name="Cyanite", hex="0abde3") 115 | dark_mountain_meadow = Color(name="Dark Mountain Meadow", hex="10ac84") 116 | jade_dust = Color(name="Jade Dust", hex="00d2d3") 117 | joust_blue = Color(name="Joust Blue", hex="54a0ff") 118 | nasu_purple = Color(name="Nasu Purple", hex="5f27cd") 119 | light_blue_ballerina = Color(name="Light Blue Ballerina", hex="c8d6e5") 120 | fuel_town = Color(name="Fuel Town", hex="576574") 121 | aqua_velvet = Color(name="Aqua Velvet", hex="01a3a4") 122 | bleu_de_france = Color(name="Bleu De France", hex="2e86de") 123 | bluebell = Color(name="Bluebell", hex="341f97") 124 | storm_petrel = Color(name="Storm Petrel", hex="8395a7") 125 | imperial_primer = Color(name="Imperial Primer", hex="222f3e") 126 | 127 | 128 | class CNColors(Colors): 129 | golden_sand = Color(name="Golden Sand", hex="eccc68") 130 | coral = Color(name="Coral", hex="ff7f50") 131 | wild_watermelon = Color(name="Wild Watermelon", hex="ff6b81") 132 | peace = Color(name="Peace", hex="a4b0be") 133 | grisaille = Color(name="Grisaille", hex="57606f") 134 | orange = Color(name="Orange", hex="ffa502") 135 | bruschetta_tomato = Color(name="Bruschetta Tomato", hex="ff6348") 136 | watermelon = Color(name="Watermelon", hex="ff4757") 137 | bay_wharf = Color(name="Bay Wharf", hex="747d8c") 138 | prestige_blue = Color(name="Prestige Blue", hex="2f3542") 139 | lime_soap = Color(name="Lime Soap", hex="7bed9f") 140 | french_sky_blue = Color(name="French Sky Blue", hex="70a1ff") 141 | saturated_sky = Color(name="Saturated Sky", hex="5352ed") 142 | white = Color(name="White", hex="ffffff") 143 | city_lights = Color(name="City Lights", hex="dfe4ea") 144 | ufo_green = Color(name="UFO Green", hex="2ed573") 145 | clear_chill = Color(name="Clear Chill", hex="1e90ff") 146 | bright_greek = Color(name="Bright Greek", hex="3742fa") 147 | anti_flash_white = Color(name="Anti-Flash White", hex="f1f2f6") 148 | twinkle_blue = Color(name="Twinkle Blue", hex="ced6e0") 149 | 150 | 151 | class NLColors(Colors): 152 | sunflower = Color(name="Sunflower", hex="FFC312") 153 | energos = Color(name="Energos", hex="C4E538") 154 | blue_martina = Color(name="Blue Martina", hex="12CBC4") 155 | lavender_rose = Color(name="Lavender Rose", hex="FDA7DF") 156 | bara_red = Color(name="Bara Red", hex="ED4C67") 157 | radiant_yellow = Color(name="Radiant Yellow", hex="F79F1F") 158 | android_green = Color(name="Android Green", hex="A3CB38") 159 | mediterranean_sea = Color(name="Mediterranean Sea", hex="1289A7") 160 | lavender_tea = Color(name="Lavender Tea", hex="D980FA") 161 | very_berry = Color(name="Very Berry", hex="B53471") 162 | puffins_bill = Color(name="Puffins Bill", hex="EE5A24") 163 | pixelated_grass = Color(name="Pixelated Grass", hex="009432") 164 | merchant_marine_blue = Color(name="Merchant Marine Blue", hex="0652DD") 165 | forgotten_purple = Color(name="Forgotten Purple", hex="9980FA") 166 | hollyhock = Color(name="Hollyhock", hex="833471") 167 | red_pigment = Color(name="Red Pigment", hex="EA2027") 168 | turkish_aqua = Color(name="Turkish Aqua", hex="006266") 169 | two_thousand_leagues_under_the_sea = Color(name="20000 Leagues Under the Sea", hex="1B1464") 170 | circumorbital_ring = Color(name="Circumorbital Ring", hex="5758BB") 171 | magenta_purple = Color(name="Magenta Purple", hex="6F1E51") 172 | 173 | 174 | class FRColors(Colors): 175 | flat_flesh = Color(name="Flat Flesh", hex="fad390") 176 | melon_melody = Color(name="Melon Melody", hex="f8c291") 177 | livid = Color(name="Livid", hex="6a89cc") 178 | spray = Color(name="Spray", hex="82ccdd") 179 | paradise_green = Color(name="Paradise Green", hex="b8e994") 180 | squash_blossom = Color(name="Squash Blossom", hex="f6b93b") 181 | mandarin_red = Color(name="Mandarin Red", hex="e55039") 182 | azraq_blue = Color(name="Azraq Blue", hex="4a69bd") 183 | dupain = Color(name="Dupain", hex="60a3bc") 184 | aurora_green = Color(name="Aurora Green", hex="78e08f") 185 | iceland_poppy = Color(name="Iceland Poppy", hex="fa983a") 186 | tomato_red = Color(name="Tomato Red", hex="eb2f06") 187 | yue_guang_lan_blue = Color(name="Yuè Guāng Lán Blue", hex="1e3799") 188 | good_samaritan = Color(name="Good Samaritan", hex="3c6382") 189 | waterfall = Color(name="Waterfall", hex="38ada9") 190 | carrot_orange = Color(name="Carrot Orange", hex="e58e26") 191 | jalapeno_red = Color(name="Jalapeno Red", hex="b71540") 192 | dark_sapphire = Color(name="Dark Sapphire", hex="0c2461") 193 | forest_blues = Color(name="Forest Blues", hex="0a3d62") 194 | reef_encounter = Color(name="Reef Encounter", hex="079992") 195 | 196 | 197 | class DEColors(Colors): 198 | fusion_red = Color(name="Fusion Red", hex="fc5c65") 199 | orange_hibiscus = Color(name="Orange Hibiscus", hex="fd9644") 200 | flirtatious = Color(name="Flirtatious", hex="fed330") 201 | reptile_green = Color(name="Reptile Green", hex="26de81") 202 | maximum_blue_green = Color(name="Maximum Blue Green", hex="2bcbba") 203 | desire = Color(name="Desire", hex="eb3b5a") 204 | beniukon_bronze = Color(name="Beniukon Bronze", hex="fa8231") 205 | nyc_taxi = Color(name="NYC Taxi", hex="f7b731") 206 | algal_fuel = Color(name="Algal Fuel", hex="20bf6b") 207 | turquoise_topaz = Color(name="Turquoise Topaz", hex="0fb9b1") 208 | high_blue = Color(name="High Blue", hex="45aaf2") 209 | c64_ntsc = Color(name="C64 NTSC", hex="4b7bec") 210 | lighter_purple = Color(name="Lighter Purple", hex="a55eea") 211 | twinkle_blue = Color(name="Twinkle Blue", hex="d1d8e0") 212 | blue_grey = Color(name="Blue Grey", hex="778ca3") 213 | boyzone = Color(name="Boyzone", hex="2d98da") 214 | royal_blue = Color(name="Royal Blue", hex="3867d6") 215 | gloomy_purple = Color(name="Gloomy Purple", hex="8854d0") 216 | innuendo = Color(name="Innuendo", hex="a5b1c2") 217 | blue_horizon = Color(name="Blue Horizon", hex="4b6584") 218 | 219 | 220 | class INColors(Colors): 221 | orchid_orange = Color(name="Orchid Orange", hex="FEA47F") 222 | spiro_disco_ball = Color(name="Spiro Disco Ball", hex="25CCF7") 223 | honey_glow = Color(name="Honey Glow", hex="EAB543") 224 | sweet_garden = Color(name="Sweet Garden", hex="55E6C1") 225 | falling_star = Color(name="Falling Star", hex="CAD3C8") 226 | rich_gardenia = Color(name="Rich Gardenia", hex="F97F51") 227 | clear_chill = Color(name="Clear Chill", hex="1B9CFC") 228 | sarawak_white_pepper = Color(name="Sarawak White Pepper", hex="F8EFBA") 229 | keppel = Color(name="Keppel", hex="58B19F") 230 | ship_s_officer = Color(name="Ship's Officer", hex="2C3A47") 231 | fiery_fuchsia = Color(name="Fiery Fuchsia", hex="B33771") 232 | bluebell = Color(name="Bluebell", hex="3B3B98") 233 | georgia_peach = Color(name="Georgia Peach", hex="FD7272") 234 | oasis_stream = Color(name="Oasis Stream", hex="9AECDB") 235 | bright_ube = Color(name="Bright Ube", hex="D6A2E8") 236 | magenta_purple = Color(name="Magenta Purple", hex="6D214F") 237 | ending_navy_blue = Color(name="Ending Navy Blue", hex="182C61") 238 | sasquatch_socks = Color(name="Sasquatch Socks", hex="FC427B") 239 | pine_glade = Color(name="Pine Glade", hex="BDC581") 240 | highlighter_lavender = Color(name="Highlighter Lavender", hex="82589F") 241 | 242 | 243 | class RUColors(Colors): 244 | creamy_peach = Color(name="Creamy Peach", hex="f3a683") 245 | rosy_highlight = Color(name="Rosy Highlight", hex="f7d794") 246 | soft_blue = Color(name="Soft Blue", hex="778beb") 247 | brewed_mustard = Color(name="Brewed Mustard", hex="e77f67") 248 | old_geranium = Color(name="Old Geranium", hex="cf6a87") 249 | sawtooth_aak = Color(name="Sawtooth Aak", hex="f19066") 250 | summertime = Color(name="Summertime", hex="f5cd79") 251 | cornflower = Color(name="Cornflower", hex="546de5") 252 | tigerlily = Color(name="Tigerlily", hex="e15f41") 253 | deep_rose = Color(name="Deep Rose", hex="c44569") 254 | purple_mountain_majesty = Color(name="Purple Mountain Majesty", hex="786fa6") 255 | rogue_pink = Color(name="Rogue Pink", hex="f8a5c2") 256 | squeaky = Color(name="Squeaky", hex="63cdda") 257 | apple_valley = Color(name="Apple Valley", hex="ea8685") 258 | pencil_lead = Color(name="Pencil Lead", hex="596275") 259 | purple_corallite = Color(name="Purple Corallite", hex="574b90") 260 | flamingo_pink = Color(name="Flamingo Pink", hex="f78fb3") 261 | blue_curacao = Color(name="Blue Curacao", hex="3dc1d3") 262 | porcelain_rose = Color(name="Porcelain Rose", hex="e66767") 263 | biscay = Color(name="Biscay", hex="303952") 264 | 265 | 266 | class ESColors(Colors): 267 | jacksons_purple = Color(name="Jacksons Purple", hex="40407a") 268 | c64_purple = Color(name="C64 Purple", hex="706fd3") 269 | swan_white = Color(name="Swan White", hex="f7f1e3") 270 | summer_sky = Color(name="Summer Sky", hex="34ace0") 271 | celestial_green = Color(name="Celestial Green", hex="33d9b2") 272 | lucky_point = Color(name="Lucky Point", hex="2c2c54") 273 | liberty = Color(name="Liberty", hex="474787") 274 | hot_stone = Color(name="Hot Stone", hex="aaa69d") 275 | devil_blue = Color(name="Devil Blue", hex="227093") 276 | palm_springs_splash = Color(name="Palm Springs Splash", hex="218c74") 277 | fluorescent_red = Color(name="Fluorescent Red", hex="ff5252") 278 | synthetic_pumpkin = Color(name="Synthetic Pumpkin", hex="ff793f") 279 | crocodile_tooth = Color(name="Crocodile Tooth", hex="d1ccc0") 280 | mandarin_sorbet = Color(name="Mandarin Sorbet", hex="ffb142") 281 | spiced_butternut = Color(name="Spiced Butternut", hex="ffda79") 282 | eye_of_newt = Color(name="Eye Of Newt", hex="b33939") 283 | chilean_fire = Color(name="Chilean Fire", hex="cd6133") 284 | grey_porcelain = Color(name="Grey Porcelain", hex="84817a") 285 | alameda_ochre = Color(name="Alameda Ochre", hex="cc8e35") 286 | desert = Color(name="Desert", hex="ccae62") 287 | 288 | 289 | class SEColors(Colors): 290 | highlighter_pink = Color(name="Highlighter Pink", hex="ef5777") 291 | dark_periwinkle = Color(name="Dark Periwinkle", hex="575fcf") 292 | megaman = Color(name="Megaman", hex="4bcffa") 293 | fresh_turquoise = Color(name="Fresh Turquoise", hex="34e7e4") 294 | minty_green = Color(name="Minty Green", hex="0be881") 295 | sizzling_red = Color(name="Sizzling Red", hex="f53b57") 296 | free_speech_blue = Color(name="Free Speech Blue", hex="3c40c6") 297 | spiro_disco_ball = Color(name="Spiro Disco Ball", hex="0fbcf9") 298 | jade_dust = Color(name="Jade Dust", hex="00d8d6") 299 | green_teal = Color(name="Green Teal", hex="05c46b") 300 | nârenji_orange = Color(name="Nârenji Orange", hex="ffc048") 301 | yriel_yellow = Color(name="Yriel Yellow", hex="ffdd59") 302 | sunset_orange = Color(name="Sunset Orange", hex="ff5e57") 303 | hint_of_elusive_blue = Color(name="Hint of Elusive Blue", hex="d2dae2") 304 | good_night = Color(name="Good Night!", hex="485460") 305 | chrome_yellow = Color(name="Chrome Yellow", hex="ffa801") 306 | vibrant_yellow = Color(name="Vibrant Yellow", hex="ffd32a") 307 | red_orange = Color(name="Red Orange", hex="ff3f34") 308 | london_square = Color(name="London Square", hex="808e9b") 309 | black_pearl = Color(name="Black Pearl", hex="1e272e") 310 | 311 | 312 | class TRColors(Colors): 313 | bright_lilac = Color(name="Bright Lilac", hex="cd84f1") 314 | pretty_please = Color(name="Pretty Please", hex="ffcccc") 315 | light_red = Color(name="Light Red", hex="ff4d4d") 316 | mandarin_sorbet = Color(name="Mandarin Sorbet", hex="ffaf40") 317 | unmellow_yellow = Color(name="Unmellow Yellow", hex="fffa65") 318 | light_purple = Color(name="Light Purple", hex="c56cf0") 319 | young_salmon = Color(name="Young Salmon", hex="ffb8b8") 320 | red_orange = Color(name="Red Orange", hex="ff3838") 321 | radiant_yellow = Color(name="Radiant Yellow", hex="ff9f1a") 322 | dorn_yellow = Color(name="Dorn Yellow", hex="fff200") 323 | wintergreen = Color(name="Wintergreen", hex="32ff7e") 324 | electric_blue = Color(name="Electric Blue", hex="7efff5") 325 | neon_blue = Color(name="Neon Blue", hex="18dcff") 326 | light_slate_blue = Color(name="Light Slate Blue", hex="7d5fff") 327 | shadowed_steel = Color(name="Shadowed Steel", hex="4b4b4b") 328 | weird_green = Color(name="Weird Green", hex="3ae374") 329 | hammam_blue = Color(name="Hammam Blue", hex="67e6dc") 330 | spiro_disco_ball = Color(name="Spiro Disco Ball", hex="17c0eb") 331 | light_indigo = Color(name="Light Indigo", hex="7158e2") 332 | baltic_sea = Color(name="Baltic Sea", hex="3d3d3d") 333 | 334 | 335 | class SocialColors(Colors): 336 | facebook = Color(name="Facebook", hex="1877f2") 337 | messenger = Color(name="Messenger", hex="0099ff") 338 | twitter = Color(name="Twitter", hex="1da1f2") 339 | linkedin = Color(name="LinkedIn", hex="0a66c2") 340 | skype = Color(name="Skype", hex="00aff0") 341 | dropbox = Color(name="Dropbox", hex="0061ff") 342 | wordpress = Color(name="Wordpress", hex="21759b") 343 | vimeo = Color(name="Vimeo", hex="1ab7ea") 344 | slideshare = Color(name="SlideShare", hex="0077b5") 345 | vk = Color(name="VK", hex="4c75a3") 346 | tumblr = Color(name="Tumblr", hex="34465d") 347 | yahoo = Color(name="Yahoo", hex="410093") 348 | pinterest = Color(name="Pinterest", hex="bd081c") 349 | youtube = Color(name="Youtube", hex="cd201f") 350 | reddit = Color(name="Reddit", hex="ff5700") 351 | quora = Color(name="Quora", hex="b92b27") 352 | yelp = Color(name="Yelp", hex="af0606") 353 | weibo = Color(name="Weibo", hex="df2029") 354 | producthunt = Color(name="ProductHunt", hex="da552f") 355 | hackernews = Color(name="HackerNews", hex="ff6600") 356 | soundcloud = Color(name="Soundcloud", hex="ff3300") 357 | blogger = Color(name="Blogger", hex="f57d00") 358 | snapchat = Color(name="SnapChat", hex="fffc00") 359 | whatsapp = Color(name="WhatsApp", hex="25d366") 360 | wechat = Color(name="WeChat", hex="09b83e") 361 | line = Color(name="Line", hex="00c300") 362 | medium = Color(name="Medium", hex="02b875") 363 | vine = Color(name="Vine", hex="00b489") 364 | slack = Color(name="Slack", hex="3aaf85") 365 | instagram = Color(name="Instagram", hex="e4405f") 366 | dribbble = Color(name="Dribbble", hex="ea4c89") 367 | flickr = Color(name="Flickr", hex="ff0084") 368 | foursquare = Color(name="FourSquare", hex="f94877") 369 | tiktok = Color(name="TikTok", hex="ee1d51") 370 | behance = Color(name="Behance", hex="131418") 371 | 372 | 373 | class MetroColors(Colors): 374 | lime = Color(name="Lime", hex="A4C400") 375 | green = Color(name="Green", hex="60A917") 376 | emerald = Color(name="Emerald", hex="008A00") 377 | teal = Color(name="Teal", hex="00ABA9") 378 | cyan = Color(name="Cyan", hex="1BA1E2") 379 | cobalt = Color(name="Cobalt", hex="0050EF") 380 | indigo = Color(name="Indigo", hex="6A00FF") 381 | violet = Color(name="Violet", hex="AA00FF") 382 | pink = Color(name="Pink", hex="F472D0") 383 | magenta = Color(name="Magenta", hex="D80073") 384 | crimson = Color(name="Crimson", hex="A20025") 385 | red = Color(name="Red", hex="E51400") 386 | orange = Color(name="Orange", hex="FA6800") 387 | amber = Color(name="Amber", hex="F0A30A") 388 | yellow = Color(name="Yellow", hex="E3C800") 389 | brown = Color(name="Brown", hex="825A2C") 390 | olive = Color(name="Olive", hex="6D8764") 391 | steel = Color(name="Steel", hex="647687") 392 | mauve = Color(name="Mauve", hex="76608A") 393 | sienna = Color(name="Sienna", hex="A0522D") 394 | 395 | 396 | class CSSColors(Colors): 397 | aliceblue = Color(name="aliceblue", hex="f0f8ff") 398 | antiquewhite = Color(name="antiquewhite", hex="faebd7") 399 | aqua = Color(name="aqua", hex="00ffff") 400 | aquamarine = Color(name="aquamarine", hex="7fffd4") 401 | azure = Color(name="azure", hex="f0ffff") 402 | beige = Color(name="beige", hex="f5f5dc") 403 | bisque = Color(name="bisque", hex="ffe4c4") 404 | black = Color(name="black", hex="000000") 405 | blanchedalmond = Color(name="blanchedalmond", hex="ffebcd") 406 | blue = Color(name="blue", hex="0000ff") 407 | blueviolet = Color(name="blueviolet", hex="8a2be2") 408 | brown = Color(name="brown", hex="a52a2a") 409 | burlywood = Color(name="burlywood", hex="deb887") 410 | cadetblue = Color(name="cadetblue", hex="5f9ea0") 411 | chartreuse = Color(name="chartreuse", hex="7fff00") 412 | chocolate = Color(name="chocolate", hex="d2691e") 413 | coral = Color(name="coral", hex="ff7f50") 414 | cornflowerblue = Color(name="cornflowerblue", hex="6495ed") 415 | cornsilk = Color(name="cornsilk", hex="fff8dc") 416 | crimson = Color(name="crimson", hex="dc143c") 417 | cyan = Color(name="cyan", hex="00ffff") 418 | darkblue = Color(name="darkblue", hex="00008b") 419 | darkcyan = Color(name="darkcyan", hex="008b8b") 420 | darkgoldenrod = Color(name="darkgoldenrod", hex="b8860b") 421 | darkgray = Color(name="darkgray", hex="a9a9a9") 422 | darkgreen = Color(name="darkgreen", hex="006400") 423 | darkgrey = Color(name="darkgrey", hex="a9a9a9") 424 | darkkhaki = Color(name="darkkhaki", hex="bdb76b") 425 | darkmagenta = Color(name="darkmagenta", hex="8b008b") 426 | darkolivegreen = Color(name="darkolivegreen", hex="556b2f") 427 | darkorange = Color(name="darkorange", hex="ff8c00") 428 | darkorchid = Color(name="darkorchid", hex="9932cc") 429 | darkred = Color(name="darkred", hex="8b0000") 430 | darksalmon = Color(name="darksalmon", hex="e9967a") 431 | darkseagreen = Color(name="darkseagreen", hex="8fbc8f") 432 | darkslateblue = Color(name="darkslateblue", hex="483d8b") 433 | darkslategray = Color(name="darkslategray", hex="2f4f4f") 434 | darkslategrey = Color(name="darkslategrey", hex="2f4f4f") 435 | darkturquoise = Color(name="darkturquoise", hex="00ced1") 436 | darkviolet = Color(name="darkviolet", hex="9400d3") 437 | deeppink = Color(name="deeppink", hex="ff1493") 438 | deepskyblue = Color(name="deepskyblue", hex="00bfff") 439 | dimgray = Color(name="dimgray", hex="696969") 440 | dimgrey = Color(name="dimgrey", hex="696969") 441 | dodgerblue = Color(name="dodgerblue", hex="1e90ff") 442 | firebrick = Color(name="firebrick", hex="b22222") 443 | floralwhite = Color(name="floralwhite", hex="fffaf0") 444 | forestgreen = Color(name="forestgreen", hex="228b22") 445 | fuchsia = Color(name="fuchsia", hex="ff00ff") 446 | gainsboro = Color(name="gainsboro", hex="dcdcdc") 447 | ghostwhite = Color(name="ghostwhite", hex="f8f8ff") 448 | goldenrod = Color(name="goldenrod", hex="daa520") 449 | gold = Color(name="gold", hex="ffd700") 450 | gray = Color(name="gray", hex="808080") 451 | green = Color(name="green", hex="008000") 452 | greenyellow = Color(name="greenyellow", hex="adff2f") 453 | grey = Color(name="grey", hex="808080") 454 | honeydew = Color(name="honeydew", hex="f0fff0") 455 | hotpink = Color(name="hotpink", hex="ff69b4") 456 | indianred = Color(name="indianred", hex="cd5c5c") 457 | indigo = Color(name="indigo", hex="4b0082") 458 | ivory = Color(name="ivory", hex="fffff0") 459 | khaki = Color(name="khaki", hex="f0e68c") 460 | lavenderblush = Color(name="lavenderblush", hex="fff0f5") 461 | lavender = Color(name="lavender", hex="e6e6fa") 462 | lawngreen = Color(name="lawngreen", hex="7cfc00") 463 | lemonchiffon = Color(name="lemonchiffon", hex="fffacd") 464 | lightblue = Color(name="lightblue", hex="add8e6") 465 | lightcoral = Color(name="lightcoral", hex="f08080") 466 | lightcyan = Color(name="lightcyan", hex="e0ffff") 467 | lightgoldenrodyellow = Color(name="lightgoldenrodyellow", hex="fafad2") 468 | lightgray = Color(name="lightgray", hex="d3d3d3") 469 | lightgreen = Color(name="lightgreen", hex="90ee90") 470 | lightgrey = Color(name="lightgrey", hex="d3d3d3") 471 | lightpink = Color(name="lightpink", hex="ffb6c1") 472 | lightsalmon = Color(name="lightsalmon", hex="ffa07a") 473 | lightseagreen = Color(name="lightseagreen", hex="20b2aa") 474 | lightskyblue = Color(name="lightskyblue", hex="87cefa") 475 | lightslategray = Color(name="lightslategray", hex="778899") 476 | lightslategrey = Color(name="lightslategrey", hex="778899") 477 | lightsteelblue = Color(name="lightsteelblue", hex="b0c4de") 478 | lightyellow = Color(name="lightyellow", hex="ffffe0") 479 | lime = Color(name="lime", hex="00ff00") 480 | limegreen = Color(name="limegreen", hex="32cd32") 481 | linen = Color(name="linen", hex="faf0e6") 482 | magenta = Color(name="magenta", hex="ff00ff") 483 | maroon = Color(name="maroon", hex="800000") 484 | mediumaquamarine = Color(name="mediumaquamarine", hex="66cdaa") 485 | mediumblue = Color(name="mediumblue", hex="0000cd") 486 | mediumorchid = Color(name="mediumorchid", hex="ba55d3") 487 | mediumpurple = Color(name="mediumpurple", hex="9370db") 488 | mediumseagreen = Color(name="mediumseagreen", hex="3cb371") 489 | mediumslateblue = Color(name="mediumslateblue", hex="7b68ee") 490 | mediumspringgreen = Color(name="mediumspringgreen", hex="00fa9a") 491 | mediumturquoise = Color(name="mediumturquoise", hex="48d1cc") 492 | mediumvioletred = Color(name="mediumvioletred", hex="c71585") 493 | midnightblue = Color(name="midnightblue", hex="191970") 494 | mintcream = Color(name="mintcream", hex="f5fffa") 495 | mistyrose = Color(name="mistyrose", hex="ffe4e1") 496 | moccasin = Color(name="moccasin", hex="ffe4b5") 497 | navajowhite = Color(name="navajowhite", hex="ffdead") 498 | navy = Color(name="navy", hex="000080") 499 | oldlace = Color(name="oldlace", hex="fdf5e6") 500 | olive = Color(name="olive", hex="808000") 501 | olivedrab = Color(name="olivedrab", hex="6b8e23") 502 | orange = Color(name="orange", hex="ffa500") 503 | orangered = Color(name="orangered", hex="ff4500") 504 | orchid = Color(name="orchid", hex="da70d6") 505 | palegoldenrod = Color(name="palegoldenrod", hex="eee8aa") 506 | palegreen = Color(name="palegreen", hex="98fb98") 507 | paleturquoise = Color(name="paleturquoise", hex="afeeee") 508 | palevioletred = Color(name="palevioletred", hex="db7093") 509 | papayawhip = Color(name="papayawhip", hex="ffefd5") 510 | peachpuff = Color(name="peachpuff", hex="ffdab9") 511 | peru = Color(name="peru", hex="cd853f") 512 | pink = Color(name="pink", hex="ffc0cb") 513 | plum = Color(name="plum", hex="dda0dd") 514 | powderblue = Color(name="powderblue", hex="b0e0e6") 515 | purple = Color(name="purple", hex="800080") 516 | rebeccapurple = Color(name="rebeccapurple", hex="663399") 517 | red = Color(name="red", hex="ff0000") 518 | rosybrown = Color(name="rosybrown", hex="bc8f8f") 519 | royalblue = Color(name="royalblue", hex="4169e1") 520 | saddlebrown = Color(name="saddlebrown", hex="8b4513") 521 | salmon = Color(name="salmon", hex="fa8072") 522 | sandybrown = Color(name="sandybrown", hex="f4a460") 523 | seagreen = Color(name="seagreen", hex="2e8b57") 524 | seashell = Color(name="seashell", hex="fff5ee") 525 | sienna = Color(name="sienna", hex="a0522d") 526 | silver = Color(name="silver", hex="c0c0c0") 527 | skyblue = Color(name="skyblue", hex="87ceeb") 528 | slateblue = Color(name="slateblue", hex="6a5acd") 529 | slategray = Color(name="slategray", hex="708090") 530 | slategrey = Color(name="slategrey", hex="708090") 531 | snow = Color(name="snow", hex="fffafa") 532 | springgreen = Color(name="springgreen", hex="00ff7f") 533 | steelblue = Color(name="steelblue", hex="4682b4") 534 | tan = Color(name="tan", hex="d2b48c") 535 | teal = Color(name="teal", hex="008080") 536 | thistle = Color(name="thistle", hex="d8bfd8") 537 | tomato = Color(name="tomato", hex="ff6347") 538 | turquoise = Color(name="turquoise", hex="40e0d0") 539 | violet = Color(name="violet", hex="ee82ee") 540 | wheat = Color(name="wheat", hex="f5deb3") 541 | white = Color(name="white", hex="ffffff") 542 | whitesmoke = Color(name="whitesmoke", hex="f5f5f5") 543 | yellow = Color(name="yellow", hex="ffff00") 544 | yellowgreen = Color(name="yellowgreen", hex="9acd32") 545 | 546 | 547 | class TailwindColors(Colors): 548 | red = Color(name="Red", hex="ef4444") 549 | orange = Color(name="Orange", hex="f97316") 550 | amber = Color(name="Amber", hex="f59e0b") 551 | yellow = Color(name="Yellow", hex="eab308") 552 | lime = Color(name="Lime", hex="84cc16") 553 | green = Color(name="Green", hex="22c55e") 554 | emerald = Color(name="Emerald", hex="10b981") 555 | teal = Color(name="Teal", hex="14b8a6") 556 | cyan = Color(name="Cyan", hex="06b6d4") 557 | light_blue = Color(name="Light Blue", hex="0ea5e9") 558 | blue = Color(name="Blue", hex="3b82f6") 559 | indigo = Color(name="Indigo", hex="6366f1") 560 | violet = Color(name="Violet", hex="8b5cf6") 561 | purple = Color(name="Purple", hex="a855f7") 562 | fuchsia = Color(name="Fuchsia", hex="d946ef") 563 | pink = Color(name="Pink", hex="ec4899") 564 | rose = Color(name="Rose", hex="f43f5e") 565 | warm_gray = Color(name="Warm Gray", hex="78716c") 566 | true_gray = Color(name="True Gray", hex="737373") 567 | gray = Color(name="Gray", hex="71717a") 568 | cool_gray = Color(name="Cool Gray", hex="6b7280") 569 | blue_gray = Color(name="Blue Gray", hex="64748b") 570 | 571 | 572 | class BootstrapColors(Colors): 573 | blue = Color(name="blue", hex="0d6efd") 574 | indigo = Color(name="indigo", hex="6610f2") 575 | purple = Color(name="purple", hex="6f42c1") 576 | pink = Color(name="pink", hex="d63384") 577 | red = Color(name="red", hex="dc3545") 578 | orange = Color(name="orange", hex="fd7e14") 579 | yellow = Color(name="yellow", hex="ffc107") 580 | green = Color(name="green", hex="198754") 581 | teal = Color(name="teal", hex="20c997") 582 | cyan = Color(name="cyan", hex="0dcaf0") 583 | 584 | white = Color(name="white", hex="ffffff") 585 | gray100 = Color(name="gray-100", hex="f8f9fa") 586 | gray200 = Color(name="gray-200", hex="e9ecef") 587 | gray300 = Color(name="gray-300", hex="dee2e6") 588 | gray400 = Color(name="gray-400", hex="ced4da") 589 | gray500 = Color(name="gray-500", hex="adb5bd") 590 | gray600 = Color(name="gray-600", hex="6c757d") 591 | gray700 = Color(name="gray-700", hex="495057") 592 | gray800 = Color(name="gray-800", hex="343a40") 593 | gray900 = Color(name="gray-900", hex="212529") 594 | black = Color(name="black", hex="000000") 595 | 596 | primary = blue 597 | secondary = gray600 598 | success = green 599 | info = cyan 600 | warning = yellow 601 | danger = red 602 | light = gray100 603 | dark = gray900 604 | -------------------------------------------------------------------------------- /pencils/_hsl.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from colorsys import hls_to_rgb 3 | from typing import TYPE_CHECKING 4 | 5 | from dataclasses import dataclass, replace 6 | 7 | if TYPE_CHECKING: 8 | from ._rgb import RGB 9 | 10 | 11 | @dataclass 12 | class HSL: 13 | """ 14 | https://en.wikipedia.org/wiki/HSL_and_HSV 15 | """ 16 | hue: float 17 | saturation: float 18 | lightness: float 19 | 20 | @property 21 | def h(self) -> float: 22 | return self.hue 23 | 24 | @property 25 | def s(self) -> float: 26 | return self.saturation 27 | 28 | @property 29 | def l(self) -> float: # noqa: E74 30 | return self.lightness 31 | 32 | @property 33 | def rgb(self) -> RGB: 34 | from ._rgb import RGB 35 | r, g, b = hls_to_rgb(self.hue, self.lightness, self.saturation) 36 | return RGB(round(r * 255), round(g * 255), round(b * 255)) 37 | 38 | @property 39 | def hex(self) -> str: 40 | return self.rgb.hex 41 | 42 | def make_darker(self, by: float = .2) -> HSL: 43 | lightness = max(self.lightness - by, 0.0) 44 | return replace(self, lightness=lightness) 45 | 46 | def make_lighter(self, by: float = .2) -> HSL: 47 | lightness = min(self.lightness + by, 1.0) 48 | return replace(self, lightness=lightness) 49 | -------------------------------------------------------------------------------- /pencils/_palette.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from typing import TYPE_CHECKING, Generic, TypeVar 3 | 4 | from dataclasses import dataclass, field 5 | 6 | if TYPE_CHECKING: 7 | from ._color import Color 8 | from ._colors import Colors 9 | 10 | C = TypeVar('C', bound='type[Colors]') 11 | 12 | 13 | @dataclass 14 | class Palette(Generic[C]): 15 | id: str 16 | name: str 17 | colors: C 18 | 19 | emoji: str = "" 20 | emojis: list[str] = field(default_factory=list) 21 | author: str = "" 22 | url: str = "" 23 | dribbble: str = "" 24 | 25 | def random_color(self) -> Color: 26 | return self.colors.random_color() 27 | -------------------------------------------------------------------------------- /pencils/_palettes.py: -------------------------------------------------------------------------------- 1 | from ._palette import Palette 2 | from . import _colors 3 | 4 | 5 | DefoPalette = Palette( 6 | id="defo", 7 | author="Flat UI Colors", 8 | name="Flat UI Palette v1", 9 | emoji="🎨", 10 | emojis=["🤙", "🤘", "✌️", "👊"], 11 | colors=_colors.DefoColors, 12 | ) 13 | 14 | 15 | NLPalette = Palette( 16 | id="nl", 17 | author="Jeroen Van Eerden", 18 | name="Dutch Palette", 19 | dribbble="jeroenvaneerden", 20 | url="https://bit.ly/33DmmPQ", 21 | emoji="🇳🇱", 22 | emojis=["🍟", "🚄", "🚲", "🧀"], 23 | colors=_colors.NLColors, 24 | ) 25 | 26 | TRPalette = Palette( 27 | id="tr", 28 | author="Tamer Köseli", 29 | name="Turkish Palette", 30 | emoji="🇹🇷", 31 | dribbble="tamerkoseli", 32 | url="https://bit.ly/2SCIS5m", 33 | emojis=["🌰", "🥛", "🌷", "👨🏻"], 34 | colors=_colors.TRColors, 35 | ) 36 | 37 | INPalette = Palette( 38 | id="in", 39 | author="Ranganath Krishnamani", 40 | name="Indian Palette", 41 | emoji="🇮🇳", 42 | dribbble="rkrishnamani", 43 | url="https://bit.ly/36WesU3", 44 | emojis=["🕉", "🐄", "🙏", "🍛"], 45 | colors=_colors.INColors, 46 | ) 47 | 48 | SEPalette = Palette( 49 | id="se", 50 | author="Jesper Dahlqvist", 51 | name="Swedish Palette", 52 | emoji="🇸🇪", 53 | dribbble="yehsper", 54 | url="https://bit.ly/2GOcLwA", 55 | emojis=["🛡", "🌲", "🛳", "🥂"], 56 | colors=_colors.SEColors, 57 | ) 58 | 59 | CAPalette = Palette( 60 | id="ca", 61 | author="Dmitri Litvinov", 62 | name="Canadian Palette", 63 | emoji="🇨🇦", 64 | dribbble="dmitrilitvinov", 65 | url="https://bit.ly/36I9aet", 66 | emojis=["🍁", "🏒", "🎿", "🏳️‍🌈"], 67 | colors=_colors.CAColors, 68 | ) 69 | 70 | AUPalette = Palette( 71 | id="au", 72 | author="Kate Hoolahan", 73 | name="Aussie Palette", 74 | emoji="🇦🇺", 75 | dribbble="hoolah", 76 | url="https://bit.ly/36Hcy9p", 77 | emojis=["🕷", "🐨", "🍌", "🐊"], 78 | colors=_colors.AUColors, 79 | ) 80 | 81 | RUPalette = Palette( 82 | id="ru", 83 | author="Alexander Zaytsev", 84 | name="Russian Palette", 85 | emoji="🇷🇺", 86 | dribbble="anwaltzzz", 87 | url="https://bit.ly/2SIvDzL", 88 | emojis=["❄️", "⛸", "🐻", "💂🏻‍♀️"], 89 | colors=_colors.RUColors, 90 | ) 91 | 92 | FRPalette = Palette( 93 | id="fr", 94 | author="Léa Poisson", 95 | name="French Palette", 96 | emoji="🇫🇷", 97 | dribbble="goldfishlife", 98 | url="https://bit.ly/3iEo73B", 99 | emojis=["🍷", "💋", "🥖", "🏰"], 100 | colors=_colors.FRColors, 101 | ) 102 | 103 | ESPalette = Palette( 104 | id="es", 105 | author="Miguel Camacho", 106 | name="Spanish Palette", 107 | emoji="🇪🇸", 108 | dribbble="miguelcm", 109 | url="https://bit.ly/2Ic3kYR", 110 | emojis=["💤", "🌞", "🏖", "💃🏻"], 111 | colors=_colors.ESColors, 112 | ) 113 | 114 | DEPalette = Palette( 115 | id="de", 116 | author="Martin David", 117 | name="German Palette", 118 | emoji="🇩🇪", 119 | dribbble="srioz", 120 | url="https://bit.ly/3jUgAzj", 121 | emojis=["🍻", "🚘", "🎶", "⏱"], 122 | colors=_colors.DEColors, 123 | ) 124 | 125 | CNPalette = Palette( 126 | id="cn", 127 | author="Wenjun", 128 | name="Chinese Palette", 129 | emoji="🇨🇳", 130 | dribbble="wenjunliao", 131 | url="https://bit.ly/3jGkAmB", 132 | emojis=["⛩", "🎆", "🏮", "🐼"], 133 | colors=_colors.CNColors, 134 | ) 135 | 136 | USPalette = Palette( 137 | id="us", 138 | author="Kevin Yang", 139 | name="American Palette", 140 | emoji="🇺🇸", 141 | dribbble="eatsleepvector", 142 | url="https://bit.ly/2GOdjTa", 143 | emojis=["🏈", "🎷", "🗽", "🍅"], 144 | colors=_colors.USColors, 145 | ) 146 | 147 | GBPalette = Palette( 148 | id="gb", 149 | author="Jan Losert", 150 | name="British Palette", 151 | emoji="🇬🇧", 152 | dribbble="janlosert", 153 | url="https://bit.ly/30HOqQ8", 154 | emojis=["☕️", "👨🏻‍🎤", "🌂", "💂🏼"], 155 | colors=_colors.GBColors, 156 | ) 157 | 158 | SocialPalette = Palette( 159 | id="social", 160 | author="7Span", 161 | name="Social", 162 | url="https://materialui.co/socialcolors/", 163 | colors=_colors.SocialColors, 164 | ) 165 | 166 | MetroPalette = Palette( 167 | id="metro", 168 | author="7Span", 169 | name="Metro", 170 | url="https://materialui.co/metrocolors", 171 | colors=_colors.MetroColors, 172 | ) 173 | 174 | CSSPalette = Palette( 175 | id="css", 176 | author="bahamas10", 177 | name="CSS", 178 | url="https://github.com/bahamas10/css-color-names", 179 | colors=_colors.CSSColors, 180 | ) 181 | 182 | TailwindPalette = Palette( 183 | id="tailwind", 184 | author="Steve Schoger", 185 | name="Tailwind", 186 | url="https://tailwindcolor.com/", 187 | colors=_colors.TailwindColors, 188 | ) 189 | 190 | BootstrapPalette = Palette( 191 | id="bootstrap", 192 | author="Bootstrap team", 193 | name="Bootstrap", 194 | url="https://getbootstrap.com/docs/5.0/customize/color/", 195 | colors=_colors.BootstrapColors, 196 | ) 197 | -------------------------------------------------------------------------------- /pencils/_registry.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from random import choice 3 | from typing import TYPE_CHECKING 4 | from . import _palettes 5 | 6 | if TYPE_CHECKING: 7 | from ._palette import Palette 8 | 9 | 10 | PALETTES: tuple[Palette, ...] = ( 11 | _palettes.DefoPalette, 12 | _palettes.NLPalette, 13 | _palettes.TRPalette, 14 | _palettes.INPalette, 15 | _palettes.SEPalette, 16 | _palettes.CAPalette, 17 | _palettes.AUPalette, 18 | _palettes.RUPalette, 19 | _palettes.FRPalette, 20 | _palettes.ESPalette, 21 | _palettes.DEPalette, 22 | _palettes.CNPalette, 23 | _palettes.USPalette, 24 | _palettes.GBPalette, 25 | _palettes.SocialPalette, 26 | _palettes.MetroPalette, 27 | _palettes.CSSPalette, 28 | _palettes.TailwindPalette, 29 | _palettes.BootstrapPalette, 30 | ) 31 | 32 | 33 | def random_palette() -> Palette: 34 | return choice(PALETTES) 35 | -------------------------------------------------------------------------------- /pencils/_rgb.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | from dataclasses import dataclass 3 | 4 | 5 | @dataclass 6 | class RGB: 7 | red: int 8 | green: int 9 | blue: int 10 | 11 | @property 12 | def r(self) -> int: 13 | return self.red 14 | 15 | @property 16 | def g(self) -> int: 17 | return self.green 18 | 19 | @property 20 | def b(self) -> int: 21 | return self.blue 22 | 23 | @property 24 | def red_hex(self) -> str: 25 | return f'{self.red:02x}' 26 | 27 | @property 28 | def green_hex(self) -> str: 29 | return f'{self.green:02x}' 30 | 31 | @property 32 | def blue_hex(self) -> str: 33 | return f'{self.blue:02x}' 34 | 35 | @property 36 | def red_float(self) -> float: 37 | return self.red / 255 38 | 39 | @property 40 | def green_float(self) -> float: 41 | return self.green / 255 42 | 43 | @property 44 | def blue_float(self) -> float: 45 | return self.blue / 255 46 | 47 | @property 48 | def hex(self) -> str: 49 | return f'{self.red:02x}{self.green:02x}{self.blue:02x}' 50 | 51 | @property 52 | def hash(self) -> str: 53 | return f'#{self.hex}' 54 | 55 | @property 56 | def ints(self) -> tuple[int, int, int]: 57 | return (self.red, self.green, self.blue) 58 | 59 | @property 60 | def floats(self) -> tuple[float, float, float]: 61 | return (self.red / 255, self.green / 255, self.blue / 255) 62 | 63 | @property 64 | def css(self) -> str: 65 | return f'rgb({self.red}, {self.green}, {self.blue})' 66 | -------------------------------------------------------------------------------- /pencils/py.typed: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/orsinium-labs/pencils/4cbb23a46369cef640ebfe12c670fe2c85a6a0e2/pencils/py.typed -------------------------------------------------------------------------------- /pyproject.toml: -------------------------------------------------------------------------------- 1 | [build-system] 2 | requires = ["flit_core >=3.2,<4"] 3 | build-backend = "flit_core.buildapi" 4 | 5 | [project] 6 | name = "pencils" 7 | authors = [ 8 | {name = "Gram", email = "gram@orsinium.dev"}, 9 | ] 10 | license = {file = "LICENSE"} 11 | readme = "README.md" 12 | requires-python = ">=3.7" 13 | dynamic = ["version", "description"] 14 | classifiers = [ 15 | "Development Status :: 5 - Production/Stable", 16 | "Intended Audience :: Developers", 17 | "License :: OSI Approved :: MIT License", 18 | "Programming Language :: Python", 19 | "Topic :: Software Development", 20 | ] 21 | keywords = [ 22 | "colors", 23 | "palettes", 24 | "art", 25 | "design", 26 | "color", 27 | ] 28 | dependencies = [] 29 | 30 | [project.optional-dependencies] 31 | test = ["pytest"] 32 | lint = [ 33 | "flake8", 34 | "mypy", 35 | "isort", 36 | ] 37 | 38 | [project.urls] 39 | Source = "https://github.com/orsinium-labs/pencils" 40 | --------------------------------------------------------------------------------