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

 Color ()
 Black. More...
 
 Color (::Vector3 hsv)
 Returns a Color from HSV values. More...
 
 Color (::Vector4 normalized)
 Returns Color from normalized values [0..1]. More...
 
 Color (const ::Color &color)
 
 Color (unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha=255)
 
 Color (unsigned int hexValue)
 Get Color structure from hexadecimal value. More...
 
 Color (void *srcPtr, int format)
 
Color Alpha (float alpha) const
 Returns color with alpha applied, alpha goes from 0.0f to 1.0f. More...
 
Color AlphaBlend (::Color dst, ::Color tint) const
 Returns src alpha-blended into dst color with tint. More...
 
Color Brightness (float factor)
 Get color with brightness correction, brightness factor goes from -1.0f to 1.0f. More...
 
ColorClearBackground ()
 Set background color (framebuffer clear color) More...
 
Color Contrast (float contrast)
 Get color with contrast correction, contrast values between -1.0f and 1.0f. More...
 
void DrawLine (::Vector2 startPos, ::Vector2 endPos) const
 Draw a line using Vector points. More...
 
void DrawLine (::Vector2 startPos, ::Vector2 endPos, float thick) const
 Draw a line using Vector points, with a given thickness. More...
 
void DrawLine (int startPosX, int startPosY, int endPosX, int endPosY) const
 Draw a line. More...
 
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. More...
 
void DrawPixel (int x, int y) const
 
void DrawRectangle (::Rectangle rec) const
 
void DrawRectangle (::Rectangle rec, ::Vector2 origin, Degree 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, Degree 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_view text, ::Vector2 position, ::Vector2 origin, Degree rotation, float fontSize, float spacing) const
 
void DrawText (const ::Font &font, const std::string_view 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_view 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. More...
 
unsigned char GetA () const
 Retrieves the a value for the object. More...
 
unsigned char GetB () const
 Retrieves the b value for the object. More...
 
unsigned char GetG () const
 Retrieves the g value for the object. More...
 
unsigned char GetR () const
 Retrieves the r value for the object. More...
 
Vector4 Normalize () const
 Returns Color normalized as float [0..1]. More...
 
 operator int () const
 Returns hexadecimal value for a Color. More...
 
 operator std::string () const
 
Coloroperator= (const ::Color &color)
 
void SetA (unsigned char value)
 Sets the a value for the object. More...
 
void SetB (unsigned char value)
 Sets the b value for the object. More...
 
void SetG (unsigned char value)
 Sets the g value for the object. More...
 
void SetR (unsigned char value)
 Sets the r value for the object. More...
 
Color Tint (::Color tint)
 Get color multiplied with another color. More...
 
Vector3 ToHSV () const
 Returns HSV values for a Color. More...
 
int ToInt () const
 Returns hexadecimal value for a Color. More...
 
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. More...
 
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 16 of file Color.hpp.

Constructor & Destructor Documentation

◆ Color() [1/7]

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

Definition at line 18 of file Color.hpp.

◆ Color() [2/7]

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

Definition at line 20 of file Color.hpp.

◆ Color() [3/7]

raylib::Color::Color ( )
inline

Black.

Definition at line 29 of file Color.hpp.

◆ Color() [4/7]

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

Returns a Color from HSV values.

Definition at line 34 of file Color.hpp.

◆ Color() [5/7]

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

Get Color structure from hexadecimal value.

Definition at line 48 of file Color.hpp.

◆ Color() [6/7]

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

Definition at line 52 of file Color.hpp.

◆ Color() [7/7]

raylib::Color::Color ( ::Vector4  normalized)
inline

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

Definition at line 95 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 252 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 259 of file Color.hpp.

◆ Beige()

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

Definition at line 281 of file Color.hpp.

◆ Black()

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

Definition at line 285 of file Color.hpp.

◆ Blank()

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

Definition at line 286 of file Color.hpp.

◆ Blue()

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

Definition at line 276 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 238 of file Color.hpp.

◆ Brown()

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

Definition at line 282 of file Color.hpp.

◆ ClearBackground()

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

Set background color (framebuffer clear color)

Definition at line 119 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 245 of file Color.hpp.

◆ DarkBlue()

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

Definition at line 277 of file Color.hpp.

◆ DarkBrown()

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

Definition at line 283 of file Color.hpp.

◆ DarkGray()

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

Definition at line 265 of file Color.hpp.

◆ DarkGreen()

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

Definition at line 274 of file Color.hpp.

◆ DarkPurple()

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

Definition at line 280 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 145 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 152 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 138 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 156 of file Color.hpp.

◆ DrawLineStrip()

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

Definition at line 160 of file Color.hpp.

◆ DrawPixel() [1/2]

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

Draw a pixel.

Definition at line 131 of file Color.hpp.

◆ DrawPixel() [2/2]

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

Definition at line 124 of file Color.hpp.

◆ DrawRectangle() [1/4]

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

Definition at line 212 of file Color.hpp.

◆ DrawRectangle() [2/4]

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

Definition at line 216 of file Color.hpp.

◆ DrawRectangle() [3/4]

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

Definition at line 208 of file Color.hpp.

◆ DrawRectangle() [4/4]

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

Definition at line 204 of file Color.hpp.

◆ DrawRectangleLines() [1/2]

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

Definition at line 224 of file Color.hpp.

◆ DrawRectangleLines() [2/2]

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

Definition at line 220 of file Color.hpp.

◆ DrawText() [1/6]

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

Definition at line 182 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 172 of file Color.hpp.

◆ DrawText() [3/6]

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

Definition at line 193 of file Color.hpp.

◆ DrawText() [4/6]

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

Definition at line 177 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 164 of file Color.hpp.

◆ DrawText() [6/6]

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

Definition at line 168 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 81 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 41 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 109 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 108 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 107 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 106 of file Color.hpp.

◆ Gold()

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

Definition at line 267 of file Color.hpp.

◆ Gray()

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

Definition at line 264 of file Color.hpp.

◆ Green()

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

Definition at line 272 of file Color.hpp.

◆ LightGray()

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

Definition at line 263 of file Color.hpp.

◆ Lime()

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

Definition at line 273 of file Color.hpp.

◆ Magenta()

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

Definition at line 287 of file Color.hpp.

◆ Maroon()

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

Definition at line 271 of file Color.hpp.

◆ Normalize()

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

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

Definition at line 88 of file Color.hpp.

◆ operator int()

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

Returns hexadecimal value for a Color.

Definition at line 66 of file Color.hpp.

◆ operator std::string()

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

Definition at line 74 of file Color.hpp.

◆ operator=()

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

Definition at line 111 of file Color.hpp.

◆ Orange()

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

Definition at line 268 of file Color.hpp.

◆ Pink()

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

Definition at line 269 of file Color.hpp.

◆ Purple()

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

Definition at line 278 of file Color.hpp.

◆ RayWhite()

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

Definition at line 288 of file Color.hpp.

◆ Red()

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

Definition at line 270 of file Color.hpp.

◆ set()

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

Definition at line 291 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 109 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 108 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 107 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 106 of file Color.hpp.

◆ SkyBlue()

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

Definition at line 275 of file Color.hpp.

◆ Tint()

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

Get color multiplied with another color.

Definition at line 231 of file Color.hpp.

◆ ToHSV()

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

Returns HSV values for a Color.

Definition at line 102 of file Color.hpp.

◆ ToInt()

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

Returns hexadecimal value for a Color.

Definition at line 59 of file Color.hpp.

◆ ToString()

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

Definition at line 70 of file Color.hpp.

◆ Violet()

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

Definition at line 279 of file Color.hpp.

◆ White()

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

Definition at line 284 of file Color.hpp.

◆ Yellow()

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

Definition at line 266 of file Color.hpp.