Skip to content

Add support color mode.#96

Open
tychedelia wants to merge 3 commits intoprocessing:mainfrom
tychedelia:color-mode
Open

Add support color mode.#96
tychedelia wants to merge 3 commits intoprocessing:mainfrom
tychedelia:color-mode

Conversation

@tychedelia
Copy link
Member

Adds support for "color mode", see p5 and processing.

This is a bit weird and partly legacy cruft. The key contention here is about this question of scaling, i.e. the "max" positional args. It seems, historically, this was used to switch between 8bit and 0-1 normalized color values (despite the fact that everything in Processing is 8-bit internally). However, p5 also demonstrates using it just to set an arbitrary range. I cannot for the life of me understand why / when this latter use case would be helpful, but it exists.

Internally, everything in our core just uses Bevy color which is floats.

Here's basically our current logic as expressed in this PR for a given Python method foo which accepts a color:

  • foo(1.0, 1.0, 1.0, 1.0) uses the configured ColorMode , by default sRGB.
  • foo(1.0) or foo(1.0, 1.0) maps to grayscale and scales using ColorMode.
  • foo(vec4(...)) or foo(vec4(..)) same as above but using vec instances.
  • foo(255, 255, 255, 255) (i.e. ints) uses the configured ColorMode and is scaled to a normalized float internally.
  • foo(oklch(...)) uses the provided Color instance and is considered to be fully resolved, i.e. it does not observe the configured color mode.

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.

1 participant