Metadata-Version: 2.4
Name: chromalib
Version: 0.1.0
Summary: 
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

[![Build](https://github.com/peterservices/ChromaLib/actions/workflows/build.yml/badge.svg)](https://github.com/peterservices/ChromaLib/actions/workflows/build.yml)
[![Ruff](https://github.com/peterservices/ChromaLib/actions/workflows/ruff.yml/badge.svg)](https://github.com/peterservices/ChromaLib/actions/workflows/ruff.yml)

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 creating effects.

> [!NOTE]
> This library is 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 looked into.

## **Installing**

**Python 3.11 to 3.15 is supported**

```
pip install git+https://github.com/peterservices/ChromaLib.git
```

## **Simple Example**

<details>

<summary>Example</summary>

```python
import asyncio

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

configuration = AppConfiguration(
    title="Red Integration",
    description="Sets all devices to red",
    author=AuthorConfiguration(
        name="YourName",
        contact="YourWebsite"
    ),
    supported_devices=[
        DeviceType.KEYBOARD
    ],
    category=AppCategory.APPLICATION,
    effect_id_hierarchy=[
        "background",
        "foreground"
    ] # Optional
)

app = ChromaApp(config=configuration)

async def main():
    await app.start()
    colors = [[Color(blue=1)] * 24] * 8 # 24 columns x 8 rows (Yes this is not optimal, will be improved later)
    app.add_effect(KeyboardEffect(
        colors=colors,
        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(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 device types
* Supports custom effect update functions
* Utilizes Pydantic models for easy type validation
* Fully typed with docstrings
* Asynchronous background loop

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