 |
raylib-cpp
C++ object-oriented wrapper library for raylib.
|
25 #ifndef RAYLIB_CPP_INCLUDE_COLOR_HPP_
26 #define RAYLIB_CPP_INCLUDE_COLOR_HPP_
30 #include "./raylib.hpp"
31 #include "./Vector4.hpp"
32 #include "./raylib-cpp-utils.hpp"
41 Color(
unsigned char red,
unsigned char green,
unsigned char blue,
unsigned char alpha) :
42 ::
Color{red, green, blue, alpha} {};
44 Color(
unsigned char red,
unsigned char green,
unsigned char blue) :
45 ::
Color{red, green, blue, 255} {};
56 set(::ColorFromHSV(hsv.x, hsv.y, hsv.z));
62 static ::Color
FromHSV(
float hue,
float saturation,
float value) {
63 return ::ColorFromHSV(hue, saturation, value);
70 set(::GetColor(hexValue));
77 set(::ColorFromNormalized(normalized));
84 return ::ColorToInt(*
this);
90 operator int()
const {
91 return ::ColorToInt(*
this);
98 return ::Fade(*
this, alpha);
105 return ::ColorNormalize(*
this);
112 return ::ColorToHSV(*
this);
115 GETTERSETTER(
unsigned char, R, r)
116 GETTERSETTER(
unsigned char, G, g)
117 GETTERSETTER(
unsigned char, B, b)
118 GETTERSETTER(
unsigned char, A, a)
142 ::DrawPixelV(pos, *
this);
149 inline Color&
DrawLine(
int startPosX,
int startPosY,
int endPosX,
int endPosY) {
150 ::DrawLine(startPosX, startPosY, endPosX, endPosY, *
this);
155 ::DrawLineV(startPos, endPos, *
this);
160 ::DrawLineEx(startPos, endPos, thick, *
this);
174 inline Color&
DrawText(
const std::string& text,
int posX,
int posY,
int fontSize) {
175 ::DrawText(text.c_str(), posX, posY, fontSize, *
this);
180 float fontSize,
float spacing) {
181 ::DrawTextEx(font, text.c_str(), position, fontSize, spacing, *
this);
187 const std::string& text,
191 bool wordWrap =
false) {
192 ::DrawTextRec(font, text.c_str(), rec, fontSize, spacing, wordWrap, *
this);
202 ::DrawRectangleV(position, size, *
this);
207 ::DrawRectangleRec(rec, *
this);
212 ::DrawRectanglePro(rec, origin, rotation, *
this);
222 ::DrawRectangleLinesEx(rec, lineThick, *
this);
230 return ::ColorAlpha(*
this, alpha);
237 return ::ColorAlphaBlend(dst, *
this, tint);
268 inline void set(const ::Color& color) {
278 #endif // RAYLIB_CPP_INCLUDE_COLOR_HPP_
Provides all the classes associated with raylib-cpp.
Color & DrawRectangleLines(int posX, int posY, int width, int height)
Color & DrawLineStrip(::Vector2 *points, int numPoints)
Color & DrawRectangle(::Vector2 position, ::Vector2 size)
Color & DrawText(const ::Font &font, const std::string &text, ::Rectangle rec, float fontSize, float spacing, bool wordWrap=false)
Color & DrawRectangleLines(::Rectangle rec, int lineThick)
void set(const ::Color &color)
Color & ClearBackground()
Set background color (framebuffer clear color)
Color & DrawLine(::Vector2 startPos, ::Vector2 endPos)
static Color DarkPurple()
Color & DrawRectangle(::Rectangle rec, ::Vector2 origin, float rotation)
Color & DrawPixel(int x, int y)
int ToInt() const
Returns hexadecimal value for a Color.
Vector3 ToHSV() const
Returns HSV values for a Color.
Color & DrawLine(::Vector2 startPos, ::Vector2 endPos, float thick)
Color(unsigned char red, unsigned char green, unsigned char blue, unsigned char alpha)
Color & DrawText(const ::Font &font, const std::string &text, ::Vector2 position, float fontSize, float spacing)
Color(::Vector3 hsv)
Returns a Color from HSV values.
Color & DrawRectangle(::Rectangle rec)
Color(unsigned char red, unsigned char green, unsigned char blue)
Color & DrawPixel(::Vector2 pos)
Draw a pixel.
Color(::Vector4 normalized)
Returns Color from normalized values [0..1].
Color & DrawText(const std::string &text, int posX, int posY, int fontSize)
::Color FromHSV(float hue, float saturation, float value)
Returns a Color from HSV values.
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.
Vector4 Normalize() const
Returns Color normalized as float [0..1].
Color & DrawLine(int startPosX, int startPosY, int endPosX, int endPosY)
Draw a line.
Color Fade(float alpha) const
Returns color with alpha applied, alpha goes from 0.0f to 1.0f.
Color(const ::Color &color)
Color & DrawLineBezier(::Vector2 startPos, ::Vector2 endPos, float thick)
Color & DrawRectangle(int posX, int posY, int width, int height)
Color(int hexValue)
Get Color structure from hexadecimal value.