{"id":9920,"library":"materialyoucolor","title":"Material You Color","description":"materialyoucolor is a pure Python library that implements the Material You color generation algorithms. It allows developers to extract dominant colors from images, generate custom color palettes, and apply Material You dynamic theming principles to their applications. As of version 3.0.2, it is actively developed with periodic updates, offering a robust solution for creating adaptive and personalized user interfaces.","status":"active","version":"3.0.2","language":"en","source_language":"en","source_url":"https://github.com/TGBinder/materialyoucolor","tags":["color","material-you","design","theming","palette","dynamic-color"],"install":[{"cmd":"pip install materialyoucolor","lang":"bash","label":"Install stable release"}],"dependencies":[],"imports":[{"symbol":"Hct","correct":"from materialyoucolor.hct.hct import Hct"},{"symbol":"QuantizerCelebi","correct":"from materialyoucolor.quantize.quantizer_celebi import QuantizerCelebi"},{"note":"Scheme classes are directly under `materialyoucolor.scheme.<scheme_name>` in v3.x, not directly under `materialyoucolor.scheme`.","wrong":"from materialyoucolor.scheme import SchemeFidelity","symbol":"SchemeFidelity","correct":"from materialyoucolor.scheme.scheme_fidelity import SchemeFidelity"},{"note":"The top-level module is `palettes` (plural), not `palette` (singular).","wrong":"from materialyoucolor.palette.tonal_palette import TonalPalette","symbol":"TonalPalette","correct":"from materialyoucolor.palettes.tonal_palette import TonalPalette"}],"quickstart":{"code":"from materialyoucolor.hct.hct import Hct\nfrom materialyoucolor.scheme.scheme_fidelity import SchemeFidelity\n\n# Define a seed color (e.g., from an image or a brand color)\nseed_hex = \"#FF00A3\" # A vibrant magenta\n\n# Convert hex string to integer for Hct\nseed_argb_int = int(seed_hex[1:], 16)\nseed_color_hct = Hct.from_int(seed_argb_int)\n\n# Generate a Material You color scheme\n# You can choose different schemes like SchemeVibrant, SchemeContent, etc.\n# Set is_dark=True for a dark theme\nscheme_light = SchemeFidelity(seed_color_hct, is_dark=False, contrast_level=0.0)\nscheme_dark = SchemeFidelity(seed_color_hct, is_dark=True, contrast_level=0.0)\n\nprint(\"--- Light Scheme ---\")\nprint(f\"Primary color: {scheme_light.primary.hex}\")\nprint(f\"On Primary color: {scheme_light.on_primary.hex}\")\nprint(f\"Background color: {scheme_light.background.hex}\")\nprint(f\"Surface color: {scheme_light.surface.hex}\")\nprint(f\"Error color: {scheme_light.error.hex}\")\n\nprint(\"\\n--- Dark Scheme ---\")\nprint(f\"Primary color: {scheme_dark.primary.hex}\")\nprint(f\"Background color: {scheme_dark.background.hex}\")\n","lang":"python","description":"This quickstart demonstrates how to generate a Material You color scheme using a seed color. It shows how to convert a hex string to the `Hct` format and then use a `SchemeFidelity` to create both light and dark themes, printing some of the key generated colors."},"warnings":[{"fix":"Review the official GitHub README and `material-color-utilities` documentation for the new module structure and API. Update all import statements and method calls accordingly.","message":"Version 3.0.0 introduced significant API changes, including module restructuring and class name alterations, to align with `material-color-utilities` 0.2.0. This impacts import paths and method calls.","severity":"breaking","affected_versions":">=3.0.0"},{"fix":"Always convert hex color strings (e.g., '#RRGGBB') to integers using `int(hex_string[1:], 16)` before passing them to `Hct.from_int()` or similar functions.","message":"The `Hct.from_int()` method and other core color functions expect an integer representation of an ARGB color, not a hexadecimal string directly. Passing a hex string will result in a `ValueError`.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Replace `hct_instance.get_argb()` with `hct_instance.argb`.","message":"The `get_argb()` method on `Hct` objects, common in earlier versions, has been replaced. Direct attribute access to `argb` is now the standard.","severity":"deprecated","affected_versions":">=3.0.0"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Verify the correct module path in the v3.x documentation. For example, `from materialyoucolor.palettes.tonal_palette import TonalPalette`.","cause":"Attempting to import from an incorrect or deprecated module path. Common when migrating from v2.x to v3.x where the module structure changed.","error":"ModuleNotFoundError: No module named 'materialyoucolor.palettes'"},{"fix":"Convert the hex string to an integer: `Hct.from_int(int(hex_string[1:], 16))`.","cause":"Passing a hex color string directly to a function that expects an integer (e.g., `Hct.from_int()`).","error":"ValueError: invalid literal for int() with base 10: '#FF00A3'"},{"fix":"Access the ARGB integer directly via the `argb` attribute: `hct_instance.argb`.","cause":"Using an outdated method call (`get_argb`) on an `Hct` object after upgrading to version 3.x.","error":"AttributeError: 'Hct' object has no attribute 'get_argb'"}]}