{"id":15015484,"url":"https://github.com/t-dynamos/materialyoucolor-python","last_synced_at":"2026-02-22T08:26:44.006Z","repository":{"id":157472809,"uuid":"628605050","full_name":"T-Dynamos/materialyoucolor-python","owner":"T-Dynamos","description":"Material You color generation algorithms in python.","archived":false,"fork":false,"pushed_at":"2024-08-18T03:20:51.000Z","size":232,"stargazers_count":40,"open_issues_count":2,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2024-12-09T13:49:44.721Z","etag":null,"topics":["color","color-palette","color-scheme","dynamic-color","dynamic-theme","dynamic-wallpaper","kivy","kivymd","material-you","palette","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/T-Dynamos.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-16T13:28:20.000Z","updated_at":"2024-11-24T04:32:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"234f1a18-c1f1-45ac-bd21-8215a3938982","html_url":"https://github.com/T-Dynamos/materialyoucolor-python","commit_stats":{"total_commits":53,"total_committers":3,"mean_commits":"17.666666666666668","dds":"0.037735849056603765","last_synced_commit":"85099ce9e6c2ef8dc32842b67390f43322a3bc65"},"previous_names":["t-dynamos/materialyoucolor-python","t-dynamos/materialyoucolor-pyhton"],"tags_count":14,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-Dynamos%2Fmaterialyoucolor-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-Dynamos%2Fmaterialyoucolor-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-Dynamos%2Fmaterialyoucolor-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/T-Dynamos%2Fmaterialyoucolor-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/T-Dynamos","download_url":"https://codeload.github.com/T-Dynamos/materialyoucolor-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":230532448,"owners_count":18240792,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["color","color-palette","color-scheme","dynamic-color","dynamic-theme","dynamic-wallpaper","kivy","kivymd","material-you","palette","python"],"created_at":"2024-09-24T19:47:31.921Z","updated_at":"2026-02-17T06:09:39.929Z","avatar_url":"https://github.com/T-Dynamos.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Material You color algorithms](https://m3.material.io/styles/color/overview) for python!\nIt is built in reference with offical [typescript implementation](https://github.com/material-foundation/material-color-utilities/tree/main/typescript) except it's color quantization part, which is based on [c++ implementation](https://github.com/material-foundation/material-color-utilities/tree/main/cpp) thanks to [pybind](https://github.com/pybind).\n\n## Features \n\n1. Up to date with `material-foundation/material-color-utilities`.\n2. Uses official c++ sources for quantization backend, which makes color generation fast!\n\n## Minimal running example:\n\nRun file `tests/test_all.py` as:\n\n```console\nusage: test_all.py [-h] [--tonal-spot] [--expressive] [--fidelity] [--fruit-salad] [--monochrome] [--neutral] [--rainbow] [--vibrant]\n                   [--content] [--all] [--image IMAGE] [--quality QUALITY] [--method {pillow,cpp}]\n\nMaterial You Color Scheme Test\n\noptions:\n  -h, --help            show this help message and exit\n  --tonal-spot          Print the tonal-spot dynamic scheme\n  --expressive          Print the expressive dynamic scheme\n  --fidelity            Print the fidelity dynamic scheme\n  --fruit-salad         Print the fruit-salad dynamic scheme\n  --monochrome          Print the monochrome dynamic scheme\n  --neutral             Print the neutral dynamic scheme\n  --rainbow             Print the rainbow dynamic scheme\n  --vibrant             Print the vibrant dynamic scheme\n  --content             Print the content dynamic scheme\n  --all                 Print all dynamic schemes (default)\n  --image IMAGE         Path to an image file for color extraction\n  --quality QUALITY     Quality for image quantization (default: 5)\n  --method {pillow,cpp}\n                        Method for color quantization (default: cpp)\n```\n\n\u003cdetails\u003e\n    \u003csummary\u003eClick to view result\u003c/summary\u003e\n\n[Image Used, size was 8MB](https://unsplash.com/photos/zFMbpChjZGg/)\n\n\u003cimg width=\"666\" height=\"516\" alt=\"image\" src=\"https://github.com/user-attachments/assets/68bc415b-3eb5-41d4-96e3-f36ced7411a8\" /\u003e\n\n\nIt is recommended to use the `cpp` backend, as the `pillow` backend is extremely memory-inefficient for large images.\nNewer Pillow APIs such as `Image.get_flattened_data()` eagerly materialize the entire image into a full list,\nso quality-based subsampling is applied only after full expansion and does not reduce memory usage.\nWhile `Image.getdata()` allows sampling during iteration, it is deprecated.\n\nThe `cpp` backend avoids these issues by operating directly on compact pixel buffers.\n\n\u003c/details\u003e\n\n\n## Usage\n\n### Install\n\nYou can easily install it from pip by executing:\n```console\npip3 install materialyoucolor --upgrade\n```\nPrebuilt binaries are avaliable for `linux`, `windows` and `macos`. If prebuilt binaries aren't available, then you should manually build and install.\n\n\n### Build and install\n\n```console\n# Install \npip3 install https://github.com/T-Dynamos/materialyoucolor-python/archive/master.zip\n\n```\n### OS Specific\n\n#### Arch Linux (OUTDATED)\n\n```console\nyay -S python-materialyoucolor\n```\n\nThanks :heart: to [@midn8hustlr](https://github.com/midn8hustlr) for this [AUR package](https://aur.archlinux.org/cgit/aur.git/?h=python-materialyoucolor-git).\n\n#### Android (using kivy's [`buildozer`](https://github.com/kivy/buildozer))\n\nEnsure these lines in `buildozer.spec`:\n```python\nrequirements = materialyoucolor==3.0.0\np4a.branch = develop\n```\n\n#### IOS (using kivy's [`kivy-ios`](https://github.com/kivy/kivy-ios))\n\nInstall latest version of kivy-ios and use as:\n```console\ntoolchain build materialyoucolor\n```\n\n## Usage examples\n\u003cdetails\u003e\n\u003csummary\u003e Click to show \u003c/summary\u003e\n    \n- Generate non dynamic colors\n\n```python\nfrom materialyoucolor.scheme import Scheme\nfrom materialyoucolor.scheme.scheme_android import SchemeAndroid\n\n# Color is a an int, which is made as:\n# 0xff + hex_code (without #)\n# Eg: 0xff + #4181EE = 0xff4181EE\n# To convert hex to this form, do `int(\"0xff\" + \"\u003chex code\u003e\", 16)`\ncolor = 0xff4181EE\n\nprint(Scheme.light(color).props)\nprint(Scheme.dark(color).props)\n# Props is a dict, key is color name and value is rgba format list\n# {'primary': [0, 90, 195, 255], 'onPrimary': ....\n\n# Same way for android\nprint(SchemeAndroid.light(color).props)\nprint(SchemeAndroid.dark(color).props)\n```\n\n- Generate dynamic colors\n```python\n# Color in hue, chroma, tone form\nfrom materialyoucolor.hct import Hct\nfrom materialyoucolor.dynamiccolor.color_spec import COLOR_NAMES\nfrom materialyoucolor.dynamiccolor.material_dynamic_colors import MaterialDynamicColors\n\n# There are 9 different variants of scheme.\nfrom materialyoucolor.scheme.scheme_tonal_spot import SchemeTonalSpot\n# Others you can import: SchemeExpressive, SchemeFruitSalad, SchemeMonochrome, SchemeRainbow, SchemeVibrant, SchemeNeutral, SchemeFidelity and SchemeContent\n\n# SchemeTonalSpot is android default\nscheme = SchemeTonalSpot( # choose any scheme here\n    Hct.from_int(0xff4181EE), # source color in hct form\n    True, # dark mode\n    0.0, # contrast\n    spec_version=\"2025\"\n)\n\nmdc = MaterialDynamicColors(spec=\"2025\")\n\nfor color in COLOR_NAMES:\n    _color = getattr(mdc, color)\n    print(color, _color.get_rgba(scheme), _color.get_hex(scheme))\n\n# background [13, 14, 18, 255] #0D0E12FF\n# onBackground [227, 229, 240, 255] #E3E5F0FF\n# surface [13, 14, 18, 255] #0D0E12FF\n# surfaceDim [13, 14, 18, 255] #0D0E12FF\n# surfaceBright [41, 44, 52, 255] #292C34FF\n# surfaceContainerLowest [0, 0, 0, 255] #000000FF\n# surfaceContainerLow [17, 19, 24, 255] #111318FF\n# surfaceContainer [23, 25, 31, 255] #17191FFF\n# surfaceContainerHigh [29, 31, 38, 255] #1D1F26FF\n# surfaceContainerHighest [35, 38, 45, 255] #23262DFF\n# onSurface [227, 229, 240, 255] #E3E5F0FF\n# surfaceVariant [35, 38, 45, 255] #23262DFF\n# onSurfaceVariant [196, 198, 208, 255] #C4C6D0FF\n# outline [142, 144, 154, 255] #8E909AFF\n...\n```\n\n- Generate and score colors from image\n\n```python\nfrom materialyoucolor.quantize import QuantizeCelebi, ImageQuantizeCelebi\nfrom materialyoucolor.score.score import Score\n\n# Pixel subsampling factor (quality = 1 processes all pixels)\nquality = 1\n\n# Run Celebi color quantization on an image.\n# Returns a dict: {ARGB_color_int: population}\nresult = ImageQuantizeCelebi(\n    \"example.jpg\",\n    quality,\n    128,  # maximum number of colors\n)\n\nprint(result)\n\n# Rank and select the best theme colors.\n# Returns a list of ARGB color integers.\nselected_colors = Score.score(result)\n\nprint(selected_colors)\n# {4278911493: 276721,\n# 4280550664: 164247, \n# 4280683034: 144830,\n# ...\n```\n\u003c/details\u003e\n\n\n## Gallery\n\nThese are some libraries which use this library for color generattion.\n\n* [`dots-hyprland`](https://github.com/end-4/dots-hyprland)\n\n\u003cimg width=\"480\" height=\"270\" alt=\"image\" src=\"https://github.com/user-attachments/assets/b08ca7ac-61a1-480f-852d-cad82590006b\" /\u003e\n\n* [`kde-material-you-colors`](https://github.com/luisbocanegra/kde-material-you-colors)\n\n\u003cimg width=\"480\" height=\"270\" alt=\"image\" src=\"https://images.pling.com/img/00/00/67/61/06/2136963/frame-51.png\" /\u003e\n\n* [`EarthFM CLONE`]\n\n  \n\u003cimg width=\"270\" height=\"480\" alt=\"516392752-7f8a2b2e-d81f-4c2c-8550-c55dea07c5bb\" src=\"https://github.com/user-attachments/assets/50d9b837-4b49-44b9-9e47-8efd593a4550\" /\u003e\n\n\n\u003e This is my private project where the theme colors change based on the album art.\n\n## FAQ\n    \n1. How it is different from `avanisubbiah/material-color-utilities`?\n\nThis library is up to date, fast, and uses a hybrid system for image generation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft-dynamos%2Fmaterialyoucolor-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ft-dynamos%2Fmaterialyoucolor-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ft-dynamos%2Fmaterialyoucolor-python/lists"}