Metadata-Version: 2.4
Name: chromalib
Version: 0.2.0
Summary: Python open-source library to create color effects for Razer Chroma devices with effect layering, updates, and expiry.
Author: Ticataco
License-Expression: MIT
License-File: LICENSE
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Operating System :: Microsoft :: Windows
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Python :: 3.15
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Dist: pydantic>=2.12.1,<3.0.0
Requires-Dist: websockets>=17.0,<18.0
Requires-Python: >=3.11
Project-URL: Repository, https://github.com/peterservices/ChromaLib.git
Project-URL: Issues, https://github.com/peterservices/ChromaLib/issues
Description-Content-Type: text/markdown

# ChromaLib

[![license](https://img.shields.io/pypi/l/chromalib.svg)](https://pypi.python.org/pypi/chromalib)
[![version](https://img.shields.io/pypi/v/chromalib.svg)](https://pypi.python.org/pypi/chromalib)
[![pyversions](https://img.shields.io/pypi/pyversions/chromalib.svg)](https://pypi.python.org/pypi/chromalib)

A typed library for Razer Chroma that supports effect layering, updates, and expiry while managing the connection with the Chroma SDK over a websocket, allowing you to focus on designing effects.

> [!NOTE]
> ChromaLib is currently in alpha and there may be breaking API changes in minor versions!
>
> Currently, Windows is the only supported platform, but support for Linux and macOS will be explored.

## **Installing**

**Python 3.11 to 3.15 is supported**

```
pip install chromalib
```

## **Simple Example**

<details>

<summary>Example</summary>

```python
import asyncio

from chromalib import (
    AppCategory,
    AppConfiguration,
    AuthorConfiguration,
    ChromaApp,
    Color,
    DeviceType,
    EffectMethod,
    KeyboardEffect,
    create_explosion_colors,
    create_static_colors,
    generate_explosion_updater,
)

configuration = AppConfiguration(
    title="Red Integration",
    description="Keybopard effects on a red background",
    author=AuthorConfiguration(
        name="YourName",
        contact="YourWebsite"
    ),
    supported_devices=[
        DeviceType.KEYBOARD
    ],
    category=AppCategory.APPLICATION,

    # Optional
    effect_id_hierarchy=[
        "background",
        "foreground"
    ]
)

app = ChromaApp(config=configuration)

async def main():
    await app.start()

    color = Color(blue=1) # One way to specify color values
    app.add_effect(KeyboardEffect(
        colors=create_static_colors(DeviceType.KEYBOARD, color),
        method=EffectMethod.FILL,
        id="background"
    ))

    await asyncio.sleep(0.5)

    color = Color()
    color.RGB_int = (255, 0, 0) # Another way to specify color values
    app.add_effect(KeyboardEffect(
        colors=create_explosion_colors(DeviceType.KEYBOARD, color),
        method=EffectMethod.FILL_NON_ZERO,
        update=generate_explosion_updater(),
        update_rate_seconds=0.12,
        expires_after_updates=15,
        id="foreground"
    ))

    await asyncio.sleep(4)
    await app.stop()

asyncio.run(main())
```

</details>

## **Features**

- Supports all major Razer devices
- Supports custom effect update functions
- Utilizes Pydantic models for easy type validation
- Fully typed with docstrings
- Asynchronous background loop and functions
  - You must only modify active effects from the same event loop

> [!IMPORTANT]
> ChromaLib is not affiliated or endorsed in any way by Razer or any of its subsidaries
