Content


NTL
Core
Color

Color



This union represents 4-component(RGBA) color value.

You can find more information in comments below.

union Color
{
    struct
    {
        unsigned char R; // Red channel
        unsigned char G; // Green channel
        unsigned char B; // Blue channel
        unsigned char A; // Alpha/transparency channel
    };
    struct
    {
        unsigned char Red;
        unsigned char Green;
        unsigned char Blue;
        unsigned char Alpha;
    };
    unsigned char Data[4]; // Channels

    unsigned char operator[](const int channel) const; // Get channel value
    unsigned char &operator[](const int channel); // Get channel value
    bool operator==(const Color &other) const; // Check if colors are equal
    bool operator!=(const Color &other) const; // Check if colors are not equal
    Color operator*(const Color &other) const; // Blend colors
    Color operator+(const Color &other) const; // Add(blCanvas mode) colors
    Color &operator*=(Color &other); // Blend colors in first one
    Color &operator+=(Color &other); // Add(blCanvas mode) colors and store result in first one

    unsigned char average() const; // Return average value over all channels except the last one(grayscale)
};

Following operator is also available.

std::wostream &operator<<(std::wostream &stream, const Color &a); // Output as source code
Namespace: nitisa
Include: Nitisa/Image/Color.h