GrooveStomp's 3D Software Renderer  0.1.0
Classes | Macros | Functions | Variables
color.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  color
 RGBA color quad. More...
 

Macros

#define COLOR_VERSION   "0.1.0"
 include guard
 

Functions

struct color ColorInitFloat (float r, float g, float b, float a)
 Initialize a new color with individual R, G, B, A components as floats. More...
 
unsigned int ColorGetInt (struct color color, char component)
 Get the color component. More...
 
float ColorGetFloat (struct color color, char component)
 Get the color component. More...
 
void ColorSetInt (struct color *color, char component, unsigned int value)
 Set the color component. More...
 
void ColorSetFloat (struct color *color, char component, float value)
 Set the color component. More...
 

Variables

struct color ColorWhite
 
struct color ColorBlack
 
struct color ColorRed
 
struct color ColorGreen
 
struct color ColorBlue
 
struct color ColorPurple
 
struct color ColorYellow
 
struct color ColorCyan
 
struct color ColorPink
 

Detailed Description

This interface attempts to provide an intuitive wrapper around "raw" unsigned integer colors.

An unsigned integer color is packed 32-bit value consisting of 4 pixel elements: RGBA. These elements are stored as written: RGBA, or, visually mapped as hex symbols: RRGGBBAA.

Function Documentation

◆ ColorGetFloat()

float ColorGetFloat ( struct color  color,
char  component 
)

Get the color component.

The component is returned as a float in the range [0.0,1.0]

Parameters
colorcolor object to read
component'r', 'g', 'b' or 'a' exclusively.
Returns
value of the color component

◆ ColorGetInt()

unsigned int ColorGetInt ( struct color  color,
char  component 
)

Get the color component.

The component is returned as the raw integer value, in the range [0,255]

Parameters
colorcolor object to read
component'r', 'g', 'b' or 'a' exclusively.
Returns
value of the color component

◆ ColorInitFloat()

struct color ColorInitFloat ( float  r,
float  g,
float  b,
float  a 
)

Initialize a new color with individual R, G, B, A components as floats.

Parameters
rRed component from 0 to 1
gGreen componenet from 0 to 1
bBlue component from 0 to 1
aAlpha component, from 0 to 1
Returns
resulting color object

◆ ColorSetFloat()

void ColorSetFloat ( struct color color,
char  component,
float  value 
)

Set the color component.

The value should be a float in the range [0.0,1.0]

Parameters
colorpointer to the color object to write
component'r', 'g', 'b' or 'a' exclusively.
valuevalue of the color component to set

◆ ColorSetInt()

void ColorSetInt ( struct color color,
char  component,
unsigned int  value 
)

Set the color component.

The value should be an integer in the range [0,255]

Parameters
colorpointer to the color object to write
component'r', 'g', 'b' or 'a' exclusively.
valuevalue of the color component to set