raylib-cpp
C++ object-oriented wrapper library for raylib.
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Protected Member Functions | List of all members
raylib::Color Class Reference

Color type, RGBA (32bit) More...

#include <Color.hpp>

Public Member Functions

constexpr Color ()
 Black.
 
 Color (::Vector3 hsv)
 Returns a Color from HSV values.
 
 Color (::Vector4 normalized)
 Returns Color from normalized values [0..1].
 
constexpr Color (const ::Color &color)
 
constexpr Color (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
 
 Color (unsigned int hexValue)
 Get Color structure from hexadecimal value.
 
 Color (void *srcPtr, int format)
 
Color Alpha (float alpha) const
 Returns color with alpha applied, alpha goes from 0.0f to 1.0f.
 
Color AlphaBlend (::Color dst, ::Color tint) const
 Returns src alpha-blended into dst color with tint.
 
Color Brightness (float factor)
 Get color with brightness correction, brightness factor goes from -1.0f to 1.0f.
 
ColorClearBackground ()
 Set background color (framebuffer clear color)
 
Color Contrast (float contrast)
 Get color with contrast correction, contrast values between -1.0f and 1.0f.
 
void DrawLine (::Vector2 startPos, ::Vector2 endPos) const
 Draw a line using Vector points.
 
void DrawLine (::Vector2 startPos, ::Vector2 endPos, float thick) const
 Draw a line using Vector points, with a given thickness.
 
void DrawLine (int startPosX, int startPosY, int endPosX, int endPosY) const
 Draw a line.
 
void DrawLineBezier (::Vector2 startPos, ::Vector2 endPos, float thick=1.0f) const
 
void DrawLineStrip (::Vector2 *points, int numPoints) const
 
void DrawPixel (::Vector2 pos) const
 Draw a pixel.
 
void DrawPixel (int x, int y) const
 
void DrawRectangle (::Rectangle rec) const
 
void DrawRectangle (::Rectangle rec, ::Vector2 origin, float rotation) const
 
void DrawRectangle (::Vector2 position, ::Vector2 size) const
 
void DrawRectangle (int posX, int posY, int width, int height) const
 
void DrawRectangleLines (::Rectangle rec, float lineThick) const
 
void DrawRectangleLines (int posX, int posY, int width, int height) const
 
void DrawText (const ::Font &font, const char *text, ::Vector2 position, ::Vector2 origin, float rotation, float fontSize, float spacing) const
 
void DrawText (const ::Font &font, const char *text, ::Vector2 position, float fontSize, float spacing) const
 
void DrawText (const ::Font &font, const std::string &text, ::Vector2 position, ::Vector2 origin, float rotation, float fontSize, float spacing) const
 
void DrawText (const ::Font &font, const std::string &text, ::Vector2 position, float fontSize, float spacing) const
 
void DrawText (const char *text, int posX=0, int posY=0, int fontSize=10.0f) const
 
void DrawText (const std::string &text, int posX=0, int posY=0, int fontSize=10.0f) const
 
Color Fade (float alpha) const
 Returns color with alpha applied, alpha goes from 0.0f to 1.0f.
 
unsigned char GetA () const
 Retrieves the a value for the object.
 
unsigned char GetB () const
 Retrieves the b value for the object.
 
unsigned char GetG () const
 Retrieves the g value for the object.
 
unsigned char GetR () const
 Retrieves the r value for the object.
 
bool IsEqual (::Color color)
 
Color Lerp (::Color color2, float factor)
 
Vector4 Normalize () const
 Returns Color normalized as float [0..1].
 
 operator int () const
 Returns hexadecimal value for a Color.
 
 operator std::string () const
 
bool operator!= (const ::Color &other) const
 
Coloroperator= (const ::Color &color)
 
bool operator== (const ::Color &other) const
 
void SetA (unsigned char value)
 Sets the a value for the object.
 
void SetB (unsigned char value)
 Sets the b value for the object.
 
void SetG (unsigned char value)
 Sets the g value for the object.
 
void SetR (unsigned char value)
 Sets the r value for the object.
 
Color Tint (::Color tint)
 Get color multiplied with another color.
 
Vector3 ToHSV () const
 Returns HSV values for a Color.
 
int ToInt () const
 Returns hexadecimal value for a Color.
 
std::string ToString () const
 

Static Public Member Functions

static Color Beige ()
 
static Color Black ()
 
static Color Blank ()
 
static Color Blue ()
 
static Color Brown ()
 
static Color DarkBlue ()
 
static Color DarkBrown ()
 
static Color DarkGray ()
 
static Color DarkGreen ()
 
static Color DarkPurple ()
 
::Color FromHSV (float hue, float saturation, float value)
 Returns a Color from HSV values.
 
static Color Gold ()
 
static Color Gray ()
 
static Color Green ()
 
static Color LightGray ()
 
static Color Lime ()
 
static Color Magenta ()
 
static Color Maroon ()
 
static Color Orange ()
 
static Color Pink ()
 
static Color Purple ()
 
static Color RayWhite ()
 
static Color Red ()
 
static Color SkyBlue ()
 
static Color Violet ()
 
static Color White ()
 
static Color Yellow ()
 

Protected Member Functions

void set (const ::Color &color)
 

Detailed Description

Color type, RGBA (32bit)

Definition at line 14 of file Color.hpp.

Constructor & Destructor Documentation

◆ Color() [1/7]

constexpr raylib::Color::Color ( const ::Color &  color)
inlineconstexpr

Definition at line 16 of file Color.hpp.

◆ Color() [2/7]

constexpr raylib::Color::Color ( unsigned char  red,
unsigned char  green,
unsigned char  blue,
unsigned char  alpha = 255 
)
inlineconstexpr

Definition at line 18 of file Color.hpp.

◆ Color() [3/7]

constexpr raylib::Color::Color ( )
inlineconstexpr

Black.

Definition at line 24 of file Color.hpp.

◆ Color() [4/7]

raylib::Color::Color ( ::Vector3  hsv)
inline

Returns a Color from HSV values.

Definition at line 29 of file Color.hpp.

◆ Color() [5/7]

raylib::Color::Color ( unsigned int  hexValue)
inlineexplicit

Get Color structure from hexadecimal value.

Definition at line 39 of file Color.hpp.

◆ Color() [6/7]

raylib::Color::Color ( void *  srcPtr,
int  format 
)
inline

Definition at line 41 of file Color.hpp.

◆ Color() [7/7]

raylib::Color::Color ( ::Vector4  normalized)
inlineexplicit

Returns Color from normalized values [0..1].

Definition at line 70 of file Color.hpp.

Member Function Documentation

◆ Alpha()

Color raylib::Color::Alpha ( float  alpha) const
inline

Returns color with alpha applied, alpha goes from 0.0f to 1.0f.

Definition at line 209 of file Color.hpp.

◆ AlphaBlend()

Color raylib::Color::AlphaBlend ( ::Color  dst,
::Color  tint 
) const
inline

Returns src alpha-blended into dst color with tint.

Definition at line 218 of file Color.hpp.

◆ Beige()

static Color raylib::Color::Beige ( )
inlinestatic

Definition at line 238 of file Color.hpp.

◆ Black()

static Color raylib::Color::Black ( )
inlinestatic

Definition at line 242 of file Color.hpp.

◆ Blank()

static Color raylib::Color::Blank ( )
inlinestatic

Definition at line 243 of file Color.hpp.

◆ Blue()

static Color raylib::Color::Blue ( )
inlinestatic

Definition at line 233 of file Color.hpp.

◆ Brightness()

Color raylib::Color::Brightness ( float  factor)
inline

Get color with brightness correction, brightness factor goes from -1.0f to 1.0f.

Definition at line 199 of file Color.hpp.

◆ Brown()

static Color raylib::Color::Brown ( )
inlinestatic

Definition at line 239 of file Color.hpp.

◆ ClearBackground()

Color & raylib::Color::ClearBackground ( )
inline

Set background color (framebuffer clear color)

Definition at line 90 of file Color.hpp.

References ClearBackground().

Referenced by ClearBackground().

◆ Contrast()

Color raylib::Color::Contrast ( float  contrast)
inline

Get color with contrast correction, contrast values between -1.0f and 1.0f.

Definition at line 204 of file Color.hpp.

◆ DarkBlue()

static Color raylib::Color::DarkBlue ( )
inlinestatic

Definition at line 234 of file Color.hpp.

◆ DarkBrown()

static Color raylib::Color::DarkBrown ( )
inlinestatic

Definition at line 240 of file Color.hpp.

◆ DarkGray()

static Color raylib::Color::DarkGray ( )
inlinestatic

Definition at line 222 of file Color.hpp.

◆ DarkGreen()

static Color raylib::Color::DarkGreen ( )
inlinestatic

Definition at line 231 of file Color.hpp.

◆ DarkPurple()

static Color raylib::Color::DarkPurple ( )
inlinestatic

Definition at line 237 of file Color.hpp.

◆ DrawLine() [1/3]

void raylib::Color::DrawLine ( ::Vector2  startPos,
::Vector2  endPos 
) const
inline

Draw a line using Vector points.

Definition at line 112 of file Color.hpp.

◆ DrawLine() [2/3]

void raylib::Color::DrawLine ( ::Vector2  startPos,
::Vector2  endPos,
float  thick 
) const
inline

Draw a line using Vector points, with a given thickness.

Definition at line 117 of file Color.hpp.

◆ DrawLine() [3/3]

void raylib::Color::DrawLine ( int  startPosX,
int  startPosY,
int  endPosX,
int  endPosY 
) const
inline

Draw a line.

Definition at line 105 of file Color.hpp.

References DrawLine().

Referenced by DrawLine().

◆ DrawLineBezier()

void raylib::Color::DrawLineBezier ( ::Vector2  startPos,
::Vector2  endPos,
float  thick = 1.0f 
) const
inline

Definition at line 121 of file Color.hpp.

◆ DrawLineStrip()

void raylib::Color::DrawLineStrip ( ::Vector2 *  points,
int  numPoints 
) const
inline

Definition at line 125 of file Color.hpp.

◆ DrawPixel() [1/2]

void raylib::Color::DrawPixel ( ::Vector2  pos) const
inline

Draw a pixel.

Definition at line 100 of file Color.hpp.

◆ DrawPixel() [2/2]

void raylib::Color::DrawPixel ( int  x,
int  y 
) const
inline

Definition at line 95 of file Color.hpp.

◆ DrawRectangle() [1/4]

void raylib::Color::DrawRectangle ( ::Rectangle  rec) const
inline

Definition at line 172 of file Color.hpp.

◆ DrawRectangle() [2/4]

void raylib::Color::DrawRectangle ( ::Rectangle  rec,
::Vector2  origin,
float  rotation 
) const
inline

Definition at line 174 of file Color.hpp.

◆ DrawRectangle() [3/4]

void raylib::Color::DrawRectangle ( ::Vector2  position,
::Vector2  size 
) const
inline

Definition at line 170 of file Color.hpp.

◆ DrawRectangle() [4/4]

void raylib::Color::DrawRectangle ( int  posX,
int  posY,
int  width,
int  height 
) const
inline

Definition at line 166 of file Color.hpp.

◆ DrawRectangleLines() [1/2]

void raylib::Color::DrawRectangleLines ( ::Rectangle  rec,
float  lineThick 
) const
inline

Definition at line 182 of file Color.hpp.

◆ DrawRectangleLines() [2/2]

void raylib::Color::DrawRectangleLines ( int  posX,
int  posY,
int  width,
int  height 
) const
inline

Definition at line 178 of file Color.hpp.

◆ DrawText() [1/6]

void raylib::Color::DrawText ( const ::Font &  font,
const char *  text,
::Vector2  position,
::Vector2  origin,
float  rotation,
float  fontSize,
float  spacing 
) const
inline

Definition at line 144 of file Color.hpp.

◆ DrawText() [2/6]

void raylib::Color::DrawText ( const ::Font &  font,
const char *  text,
::Vector2  position,
float  fontSize,
float  spacing 
) const
inline

Definition at line 135 of file Color.hpp.

◆ DrawText() [3/6]

void raylib::Color::DrawText ( const ::Font &  font,
const std::string &  text,
::Vector2  position,
::Vector2  origin,
float  rotation,
float  fontSize,
float  spacing 
) const
inline

Definition at line 155 of file Color.hpp.

◆ DrawText() [4/6]

void raylib::Color::DrawText ( const ::Font &  font,
const std::string &  text,
::Vector2  position,
float  fontSize,
float  spacing 
) const
inline

Definition at line 140 of file Color.hpp.

◆ DrawText() [5/6]

void raylib::Color::DrawText ( const char *  text,
int  posX = 0,
int  posY = 0,
int  fontSize = 10.0f 
) const
inline

Definition at line 127 of file Color.hpp.

◆ DrawText() [6/6]

void raylib::Color::DrawText ( const std::string &  text,
int  posX = 0,
int  posY = 0,
int  fontSize = 10.0f 
) const
inline

Definition at line 131 of file Color.hpp.

◆ Fade()

Color raylib::Color::Fade ( float  alpha) const
inline

Returns color with alpha applied, alpha goes from 0.0f to 1.0f.

Definition at line 60 of file Color.hpp.

◆ FromHSV()

::Color raylib::Color::FromHSV ( float  hue,
float  saturation,
float  value 
)
inlinestatic

Returns a Color from HSV values.

Definition at line 34 of file Color.hpp.

◆ GetA()

unsigned char raylib::Color::GetA ( ) const
inline

Retrieves the a value for the object.

Returns
The a value of the object.

Definition at line 80 of file Color.hpp.

◆ GetB()

unsigned char raylib::Color::GetB ( ) const
inline

Retrieves the b value for the object.

Returns
The b value of the object.

Definition at line 79 of file Color.hpp.

◆ GetG()

unsigned char raylib::Color::GetG ( ) const
inline

Retrieves the g value for the object.

Returns
The g value of the object.

Definition at line 78 of file Color.hpp.

◆ GetR()

unsigned char raylib::Color::GetR ( ) const
inline

Retrieves the r value for the object.

Returns
The r value of the object.

Definition at line 77 of file Color.hpp.

◆ Gold()

static Color raylib::Color::Gold ( )
inlinestatic

Definition at line 224 of file Color.hpp.

◆ Gray()

static Color raylib::Color::Gray ( )
inlinestatic

Definition at line 221 of file Color.hpp.

◆ Green()

static Color raylib::Color::Green ( )
inlinestatic

Definition at line 229 of file Color.hpp.

◆ IsEqual()

bool raylib::Color::IsEqual ( ::Color  color)
inline

Definition at line 184 of file Color.hpp.

◆ Lerp()

Color raylib::Color::Lerp ( ::Color  color2,
float  factor 
)
inline

Definition at line 211 of file Color.hpp.

◆ LightGray()

static Color raylib::Color::LightGray ( )
inlinestatic

Definition at line 220 of file Color.hpp.

◆ Lime()

static Color raylib::Color::Lime ( )
inlinestatic

Definition at line 230 of file Color.hpp.

◆ Magenta()

static Color raylib::Color::Magenta ( )
inlinestatic

Definition at line 244 of file Color.hpp.

◆ Maroon()

static Color raylib::Color::Maroon ( )
inlinestatic

Definition at line 228 of file Color.hpp.

◆ Normalize()

Vector4 raylib::Color::Normalize ( ) const
inline

Returns Color normalized as float [0..1].

Definition at line 65 of file Color.hpp.

◆ operator int()

raylib::Color::operator int ( ) const
inlineexplicit

Returns hexadecimal value for a Color.

Definition at line 51 of file Color.hpp.

◆ operator std::string()

raylib::Color::operator std::string ( ) const
inlineexplicit

Definition at line 55 of file Color.hpp.

◆ operator!=()

bool raylib::Color::operator!= ( const ::Color &  other) const
inline

Definition at line 189 of file Color.hpp.

◆ operator=()

Color & raylib::Color::operator= ( const ::Color &  color)
inline

Definition at line 82 of file Color.hpp.

◆ operator==()

bool raylib::Color::operator== ( const ::Color &  other) const
inline

Definition at line 188 of file Color.hpp.

◆ Orange()

static Color raylib::Color::Orange ( )
inlinestatic

Definition at line 225 of file Color.hpp.

◆ Pink()

static Color raylib::Color::Pink ( )
inlinestatic

Definition at line 226 of file Color.hpp.

◆ Purple()

static Color raylib::Color::Purple ( )
inlinestatic

Definition at line 235 of file Color.hpp.

◆ RayWhite()

static Color raylib::Color::RayWhite ( )
inlinestatic

Definition at line 245 of file Color.hpp.

◆ Red()

static Color raylib::Color::Red ( )
inlinestatic

Definition at line 227 of file Color.hpp.

◆ set()

void raylib::Color::set ( const ::Color &  color)
inlineprotected

Definition at line 247 of file Color.hpp.

◆ SetA()

void raylib::Color::SetA ( unsigned char  value)
inline

Sets the a value for the object.

Parameters
valueThe value of which to set a to.

Definition at line 80 of file Color.hpp.

◆ SetB()

void raylib::Color::SetB ( unsigned char  value)
inline

Sets the b value for the object.

Parameters
valueThe value of which to set b to.

Definition at line 79 of file Color.hpp.

◆ SetG()

void raylib::Color::SetG ( unsigned char  value)
inline

Sets the g value for the object.

Parameters
valueThe value of which to set g to.

Definition at line 78 of file Color.hpp.

◆ SetR()

void raylib::Color::SetR ( unsigned char  value)
inline

Sets the r value for the object.

Parameters
valueThe value of which to set r to.

Definition at line 77 of file Color.hpp.

◆ SkyBlue()

static Color raylib::Color::SkyBlue ( )
inlinestatic

Definition at line 232 of file Color.hpp.

◆ Tint()

Color raylib::Color::Tint ( ::Color  tint)
inline

Get color multiplied with another color.

Definition at line 194 of file Color.hpp.

◆ ToHSV()

Vector3 raylib::Color::ToHSV ( ) const
inline

Returns HSV values for a Color.

Definition at line 75 of file Color.hpp.

◆ ToInt()

int raylib::Color::ToInt ( ) const
inline

Returns hexadecimal value for a Color.

Definition at line 46 of file Color.hpp.

◆ ToString()

std::string raylib::Color::ToString ( ) const
inline

Definition at line 53 of file Color.hpp.

◆ Violet()

static Color raylib::Color::Violet ( )
inlinestatic

Definition at line 236 of file Color.hpp.

◆ White()

static Color raylib::Color::White ( )
inlinestatic

Definition at line 241 of file Color.hpp.

◆ Yellow()

static Color raylib::Color::Yellow ( )
inlinestatic

Definition at line 223 of file Color.hpp.