Skip to content

Add color operations in OKLab space #3707

@kadir014

Description

@kadir014

Description

pygame.Color has very useful and wide range of functionality. One more addition which I think would make sense in game development space is adding color operations & conversions in OKLab space.

It's already being adopted in many similar engines and libraries because of it's strengths. You can read the blog post by OKLab's creator.

It most likely would have an API similar to this, I'd like to hear your opinions.

# OKLab -> Linear RGB
# L: lightness
# a: green <-> red
# b: blue <-> yellow
pygame.Color.from_oklab(L: float, a: float, b: float)

# Polar OKLab -> Linear RGB
# L: lightness
# c: chroma
# h: hue
pygame.Color.from_oklch(L: float, c: float, h: float)

# Properties similar to pygame.Color.hsv
pygame.Color.oklab
pygame.Color.oklch

It makes it possible to have perceptually much better gradients and calculating similarity between colors more accurately.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions