Skip to content

Add Color class#94

Open
tychedelia wants to merge 5 commits intoprocessing:mainfrom
tychedelia:color
Open

Add Color class#94
tychedelia wants to merge 5 commits intoprocessing:mainfrom
tychedelia:color

Conversation

@tychedelia
Copy link
Member

@tychedelia tychedelia commented Mar 23, 2026

Closes #21

Adds a new Python Color class that wraps bevy_color.

A Color is an opaque wrapper around a given color space representation. Bevy's color APIs will handle conversions internally as needed and users are expected to know which color space they're working in. Note, everything eventually gets reduces to linear rgba in the shader, but this allows us to be maximally flexible in terms of our high level API.

This is similar to the work done for #91 in that we accept a variety of ways to construct a color:

  • Position args: color(1.0, 1.0, 1.0) or color(1.0, 1.0, 1.0, 1.0). This will produce a sRGBA color
  • Hex string: "#FFFFFFFF which will also produce a sRGBA color.
  • Specific color space ctors: oklch(1.0, 1.0, 1.0, 1.0);
  • Vec3/Vec4: color(vec4(1.0, 1.0, 1.0, 1.0)). Will also produce a sRGBA color. Less useful but potential helpful for doing weird things like position to color.

We also expose a variety of helpful methods from bevy like lerp and mix.

N.B.: #[pyo3(signature = (r, g, b, a=1.0))] allows for omitting the alpha positional arg in Python, so users can use either the 3 arg or 4 arg versions.

@tychedelia tychedelia requested a review from catilac March 23, 2026 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Build out Color API

2 participants