Gamedev Framework (gf)  0.3.0
A C++11 framework for 2D games
Public Member Functions | Static Public Member Functions | Static Public Attributes | List of all members
gf::Color Struct Reference

Predefined colors. More...

#include <gf/Color.h>

Public Member Functions

 Color ()=delete
 Deleted constructor. More...
 

Static Public Member Functions

static constexpr Color4f Opaque (float value=0.5f)
 Opaque predefined color. More...
 
static constexpr Color4f Gray (float value=0.5f)
 Gray predefined color. More...
 
static Color4f lighter (Color4f color, float percent=0.5f)
 Compute a lighter color. More...
 
static Color4f darker (Color4f color, float percent=0.5f)
 Compute a darker color. More...
 
static Color4f fromRgba32 (uint8_t r, uint8_t g, uint8_t b, uint8_t a=255)
 Get a color from 4 8-bit channels. More...
 
static Color4f fromRgba32 (uint32_t color)
 Get a color from 32-bit value. More...
 
static Color4f fromRgba32 (Color4u color)
 Get a color from a 32-bit color. More...
 
static Color4u toRgba32 (Color4f color)
 Convert a color to a 32-bit color. More...
 

Static Public Attributes

static constexpr Color4f Black {0.0f, 0.0f, 0.0f, 1.0f}
 Black predefined color. More...
 
static constexpr Color4f White {1.0f, 1.0f, 1.0f, 1.0f}
 White predefined color. More...
 
static constexpr Color4f Red {1.0f, 0.0f, 0.0f, 1.0f}
 Red predefined color. More...
 
static constexpr Color4f Green {0.0f, 1.0f, 0.0f, 1.0f}
 Green predefined color. More...
 
static constexpr Color4f Blue {0.0f, 0.0f, 1.0f, 1.0f}
 Blue predefined color. More...
 
static constexpr Color4f Cyan {0.0f, 1.0f, 1.0f, 1.0f}
 Cyan predefined color. More...
 
static constexpr Color4f Magenta {1.0f, 0.0f, 1.0f, 1.0f}
 Magenta predefined color. More...
 
static constexpr Color4f Yellow {1.0f, 1.0f, 0.0f, 1.0f}
 Yellow predefined color. More...
 
static constexpr Color4f Transparent {0.0f, 0.0f, 0.0f, 0.0f}
 Transparent (black) predefined color. More...
 
static constexpr Color4f Orange {1.0f, 0.5f, 0.0f, 1.0f}
 Orange predefined color. More...
 
static constexpr Color4f Rose {1.0f, 0.0f, 0.5f, 1.0f}
 Rose predefined color. More...
 
static constexpr Color4f Chartreuse {0.5f, 1.0f, 0.0f, 1.0f}
 Chartreuse predefined color. More...
 
static constexpr Color4f Spring {0.0f, 1.0f, 0.5f, 1.0f}
 Spring (green) predefined color. More...
 
static constexpr Color4f Violet {0.5f, 0.0f, 1.0f, 1.0f}
 Violet predefined color. More...
 
static constexpr Color4f Azure {0.0f, 0.5f, 1.0f, 1.0f}
 Azure predefined color. More...
 

Detailed Description

Predefined colors.

This class does not contain anything but predefined colors. All the primary, secondary and tertiary colors are defined by their usual names.

If you want to define a color, you should use gf::Color4f.

See also
gf::Color4f

Constructor & Destructor Documentation

gf::Color::Color ( )
delete

Deleted constructor.

Member Function Documentation

static Color4f gf::Color::darker ( Color4f  color,
float  percent = 0.5f 
)
static

Compute a darker color.

This function takes a color and gives a darker color based on a percentage. If this percentage is 0, the same color is returned. If this percentage is 1, the black color is returned.

Parameters
colorThe color
percentThe percentage, must be in \( [0, 1] \)
static Color4f gf::Color::fromRgba32 ( uint8_t  r,
uint8_t  g,
uint8_t  b,
uint8_t  a = 255 
)
static

Get a color from 4 8-bit channels.

Parameters
rThe red channel
gThe green channel
bThe blue channel
aThe alpha channel
Returns
The corresponding color
static Color4f gf::Color::fromRgba32 ( uint32_t  color)
static

Get a color from 32-bit value.

Parameters
colorThe 32-bit color
Returns
The corresponding color
static Color4f gf::Color::fromRgba32 ( Color4u  color)
static

Get a color from a 32-bit color.

Parameters
colorA 32-bit color
Returns
The corresponding color
static constexpr Color4f gf::Color::Gray ( float  value = 0.5f)
inlinestatic

Gray predefined color.

Parameters
valueThe gray value
static Color4f gf::Color::lighter ( Color4f  color,
float  percent = 0.5f 
)
static

Compute a lighter color.

This function takes a color and gives a lighter color based on a percentage. If this percentage is 0, the same color is returned. If this percentage is 1, the white color is returned.

Parameters
colorThe color
percentThe percentage, must be in \( [0, 1] \)
static constexpr Color4f gf::Color::Opaque ( float  value = 0.5f)
inlinestatic

Opaque predefined color.

Parameters
valueThe opacity value
static Color4u gf::Color::toRgba32 ( Color4f  color)
static

Convert a color to a 32-bit color.

Parameters
colorA color
Returns
The corresponding 32-bit color

Member Data Documentation

constexpr Color4f gf::Color::Azure {0.0f, 0.5f, 1.0f, 1.0f}
static

Azure predefined color.

constexpr Color4f gf::Color::Black {0.0f, 0.0f, 0.0f, 1.0f}
static

Black predefined color.

constexpr Color4f gf::Color::Blue {0.0f, 0.0f, 1.0f, 1.0f}
static

Blue predefined color.

constexpr Color4f gf::Color::Chartreuse {0.5f, 1.0f, 0.0f, 1.0f}
static

Chartreuse predefined color.

constexpr Color4f gf::Color::Cyan {0.0f, 1.0f, 1.0f, 1.0f}
static

Cyan predefined color.

constexpr Color4f gf::Color::Green {0.0f, 1.0f, 0.0f, 1.0f}
static

Green predefined color.

constexpr Color4f gf::Color::Magenta {1.0f, 0.0f, 1.0f, 1.0f}
static

Magenta predefined color.

constexpr Color4f gf::Color::Orange {1.0f, 0.5f, 0.0f, 1.0f}
static

Orange predefined color.

constexpr Color4f gf::Color::Red {1.0f, 0.0f, 0.0f, 1.0f}
static

Red predefined color.

constexpr Color4f gf::Color::Rose {1.0f, 0.0f, 0.5f, 1.0f}
static

Rose predefined color.

constexpr Color4f gf::Color::Spring {0.0f, 1.0f, 0.5f, 1.0f}
static

Spring (green) predefined color.

constexpr Color4f gf::Color::Transparent {0.0f, 0.0f, 0.0f, 0.0f}
static

Transparent (black) predefined color.

constexpr Color4f gf::Color::Violet {0.5f, 0.0f, 1.0f, 1.0f}
static

Violet predefined color.

constexpr Color4f gf::Color::White {1.0f, 1.0f, 1.0f, 1.0f}
static

White predefined color.

constexpr Color4f gf::Color::Yellow {1.0f, 1.0f, 0.0f, 1.0f}
static

Yellow predefined color.