#include "KColor.hpp" ➔ struct KColor

KColor

A struct that represents a color with R, G, B and A canals.

struct KColor {
    unsigned char r, g, b, a;
}

Constructor

KColor(unsigned char r, unsigned char g, unsigned char b, unsigned char a = 255);

Set all canals of the color.

Member

unsigned char r, g, b, a;

Four bytes for each color canals (red, green, blue and alpha).

Predefined

KColor Black, White, Transparent;
KColor Red, Green, Blue;
KColor Cyan, Magenta, Yellow;

Predefined colors.

Operator

std::ostream& operator<<(std::ostream& ostream, KColor color);
std::istream& operator>>(std::istream& istream, KColor color);

Provide conversion to iostream.

Example

KSurface surface(680, 420, KColor(40, 40, 40));

KColor color(255, 40, 40);

for (int i = 0; i < 100; i++) {
    surface.set_pixel(i, i, color);
    color.g += 2;
    color.r -= 1;
}

surface.save("example.bmp");