Skip to content

color-mod adjusters #2

@p0nce

Description

@p0nce

Take inspiration for other API to make it pleasant.

raylib: (only sRGB)

    Color Fade(Color color, float alpha);                                 // Get color with alpha applied, alpha goes from 0.0f to 1.0f
    int ColorToInt(Color color);                                          // Get hexadecimal value for a Color
    Vector4 ColorNormalize(Color color);                                  // Get Color normalized as float [0..1]
    Color ColorFromNormalized(Vector4 normalized);                        // Get Color from normalized values [0..1]
    Vector3 ColorToHSV(Color color);                                      // Get HSV values for a Color, hue [0..360], saturation/value [0..1]
    Color ColorFromHSV(float hue, float saturation, float value);         // Get a Color from HSV values, hue [0..360], saturation/value [0..1]
    Color ColorTint(Color color, Color tint);                             // Get color multiplied with another color
    Color ColorBrightness(Color color, float factor);                     // Get color with brightness correction, brightness factor goes from -1.0f to 1.0f
    Color ColorContrast(Color color, float contrast);                     // Get color with contrast correction, contrast values between -1.0f and 1.0f
    Color ColorAlpha(Color color, float alpha);                           // Get color with alpha applied, alpha goes from 0.0f to 1.0f
    Color ColorAlphaBlend(Color dst, Color src, Color tint);              // Get src alpha-blended into dst color with tint
    Color GetColor(unsigned int hexValue);                                // Get Color structure from hexadecimal value
    Color GetPixelColor(void *srcPtr, int format);                        // Get Color from a source pixel pointer of certain format
    void SetPixelColor(void *dstPtr, Color color, int format);            // Set color formatted into destination pixel pointer
    int GetPixelDataSize(int width, int height, int format);              // Get pixel data size in bytes for certain format

CSS color-mod
CSS defines and allows all kinds of colorspaces, such as sRGB, Lch, oklab, Rec2020...

.box {
  color: color-mod(purple lightness(62%) red(218) blue(202) whiteness(25%));
  color: color-mod(hotpink blend(yellow 59%));
}

Here’s a list of available color adjusters:

alpha: A value for the alpha-transparency between 0% and 100%.
red, green & blue: A value between 0 and 255. Given a starting color of rgb(140, 254, 255), the starting red value would be 140, so anything higher than 140 increases the amount of red in the color and anything lower than 140 decreases the amount of red in color. Green and blue work the same way, with affecting their respective color.
blackness & whiteness: A value between 0% and 100%.
contrast: A value between 0% and 100%.
saturation: A value between 0% and 100%. 0% is gray.
lightness: A value between 0% and 100%. 0% is black, and 100% is white.
tint: A value between 0% and 100%.
hue: A value between 0 and 360.
shade: A value between 0% and 100%. 100% is black.
blend: Blend makes it easy to blend a color with another color. Here’s an example if it’s usage:

In part 1, do not allow color-mod in parse, just as methods

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions