OldSchool Library
Colors

Color manipulation utilities. More...

Macros

#define RGB(r, v, b)
 Creates a 32-bit opaque color.
 
#define RGBA(r, v, b, a)
 Creates a 32-bit color with alpha (transparency).
 
#define RGB12(r, v, b)
 Creates a 12-bit opaque color.
 
#define RGBA12(r, v, b, a)
 Creates a 12-bit color with alpha.
 
#define RGB15(r, v, b)
 Creates a 15-bit opaque color.
 
#define RGBA15(r, v, b, a)
 Creates a 15-bit color with alpha.
 
#define RGB16(r, v, b)
 Creates a 16-bit color.
 

Typedefs

typedef unsigned long OSL_COLOR
 

Detailed Description

Color manipulation utilities.

This group contains macros for creating and manipulating colors in various bit formats.

Macro Definition Documentation

◆ RGB

#define RGB ( r,
v,
b )
Value:
((r) | ((v) << 8) | ((b) << 16) | (0xff << 24))

Creates a 32-bit opaque color.

This macro generates a 32-bit color value with full opacity (alpha = 255).

Parameters
rRed component (0-255)
vGreen component (0-255)
bBlue component (0-255)
Returns
32-bit color value with full opacity.

◆ RGBA

#define RGBA ( r,
v,
b,
a )
Value:
((r) | ((v) << 8) | ((b) << 16) | ((a) << 24))

Creates a 32-bit color with alpha (transparency).

This macro generates a 32-bit color value, allowing for semi-transparency.

Parameters
rRed component (0-255)
vGreen component (0-255)
bBlue component (0-255)
aAlpha component (0-255)
Returns
32-bit color value with specified transparency.

◆ RGB12

#define RGB12 ( r,
v,
b )
Value:
((((b) >> 4) << 8) | (((v) >> 4) << 4) | ((r) >> 4) | (0xf << 12))

Creates a 12-bit opaque color.

This macro generates a 12-bit color value with full opacity. The red, green, and blue components are scaled down to fit the 12-bit format (4 bits per channel).

Parameters
rRed component (0-255)
vGreen component (0-255)
bBlue component (0-255)
Returns
12-bit color value with full opacity.

◆ RGBA12

#define RGBA12 ( r,
v,
b,
a )
Value:
((((a) >> 4) << 12) | (((b) >> 4) << 8) | (((v) >> 4) << 4) | ((r) >> 4))

Creates a 12-bit color with alpha.

This macro generates a 12-bit color value, including an alpha component for transparency.

Parameters
rRed component (0-255)
vGreen component (0-255)
bBlue component (0-255)
aAlpha component (0-255)
Returns
12-bit color value with specified transparency.

◆ RGB15

#define RGB15 ( r,
v,
b )
Value:
((((b) >> 3) << 10) | (((v) >> 3) << 5) | ((r) >> 3) | (1 << 15))

Creates a 15-bit opaque color.

This macro generates a 15-bit color value with full opacity. The red, green, and blue components are scaled down to fit the 15-bit format (5 bits for red and blue, 5 or 6 bits for green).

Parameters
rRed component (0-255)
vGreen component (0-255)
bBlue component (0-255)
Returns
15-bit color value with full opacity.

◆ RGBA15

#define RGBA15 ( r,
v,
b,
a )
Value:
((((a) >> 7) << 15) | (((b) >> 3) << 10) | (((v) >> 3) << 5) | ((r) >> 3))

Creates a 15-bit color with alpha.

This macro generates a 15-bit color value, including an alpha component for transparency.

Parameters
rRed component (0-255)
vGreen component (0-255)
bBlue component (0-255)
aAlpha component (0-255)
Returns
15-bit color value with specified transparency.

◆ RGB16

#define RGB16 ( r,
v,
b )
Value:
((((b) >> 3) << 11) | (((v) >> 2) << 5) | ((r) >> 3))

Creates a 16-bit color.

This macro generates a 16-bit color value with no alpha channel. The red, green, and blue components are scaled down to fit the 16-bit format (5 bits for red, 6 bits for green, 5 bits for blue).

Parameters
rRed component (0-255)
vGreen component (0-255)
bBlue component (0-255)
Returns
16-bit color value.

Typedef Documentation

◆ OSL_COLOR

typedef unsigned long OSL_COLOR

Represents a true color value in OSLib.