1#ifndef RAYLIB_CPP_INCLUDE_COLOR_HPP_
2#define RAYLIB_CPP_INCLUDE_COLOR_HPP_
8#include "./Vector4.hpp"
9#include "./RadiansDegrees.hpp"
10#include "./raylib-cpp-utils.hpp"
18 Color(const ::Color& color) :
::Color{color.r, color.g, color.b, color.a} {}
24 unsigned char alpha = 255) :
::Color{red, green, blue, alpha} {};
35 set(::ColorFromHSV(hsv.x, hsv.y, hsv.z));
41 static ::Color
FromHSV(
float hue,
float saturation,
float value) {
42 return ::ColorFromHSV(hue, saturation, value);
49 set(::GetColor(hexValue));
52 Color(
void *srcPtr,
int format) {
53 set(::GetPixelColor(srcPtr, format));
60 return ::ColorToInt(*
this);
66 operator int()
const {
67 return ::ColorToInt(*
this);
70 std::string ToString()
const {
71 return TextFormat(
"Color(%d, %d, %d, %d)", r, g, b, a);
74 operator std::string()
const {
82 return ::Fade(*
this, alpha);
89 return ::ColorNormalize(*
this);
96 set(::ColorFromNormalized(normalized));
103 return ::ColorToHSV(*
this);
106 GETTERSETTER(
unsigned char, R, r)
107 GETTERSETTER(
unsigned char, G, g)
108 GETTERSETTER(
unsigned char, B, b)
109 GETTERSETTER(
unsigned char, A, a)
124 void DrawPixel(
int x,
int y)
const {
125 ::DrawPixel(x, y, *
this);
132 ::DrawPixelV(pos, *
this);
138 void DrawLine(
int startPosX,
int startPosY,
int endPosX,
int endPosY)
const {
139 ::DrawLine(startPosX, startPosY, endPosX, endPosY, *
this);
145 void DrawLine(::Vector2 startPos, ::Vector2 endPos)
const {
146 ::DrawLineV(startPos, endPos, *
this);
152 void DrawLine(::Vector2 startPos, ::Vector2 endPos,
float thick)
const {
153 ::DrawLineEx(startPos, endPos, thick, *
this);
156 void DrawLineBezier(::Vector2 startPos, ::Vector2 endPos,
float thick = 1.0f)
const {
157 ::DrawLineBezier(startPos, endPos, thick, *
this);
160 void DrawLineStrip(::Vector2 *points,
int numPoints)
const {
161 ::DrawLineStrip(points, numPoints, *
this);
164 void DrawText(
const char* text,
int posX = 0,
int posY = 0,
int fontSize = 10.0f)
const {
165 ::DrawText(text, posX, posY, fontSize, *
this);
168 void DrawText(
const std::string_view text,
int posX = 0,
int posY = 0,
int fontSize = 10.0f)
const {
169 ::DrawText(text.data(), posX, posY, fontSize, *
this);
172 void DrawText(const ::Font& font,
const char* text, ::Vector2 position,
173 float fontSize,
float spacing)
const {
174 ::DrawTextEx(font, text, position, fontSize, spacing, *
this);
177 void DrawText(const ::Font& font,
const std::string_view text, ::Vector2 position,
178 float fontSize,
float spacing)
const {
179 ::DrawTextEx(font, text.data(), position, fontSize, spacing, *
this);
189 float spacing)
const {
190 ::DrawTextPro(font, text, position, origin, rotation, fontSize, spacing, *
this);
195 const std::string_view text,
200 float spacing)
const {
201 ::DrawTextPro(font, text.data(), position, origin, rotation, fontSize, spacing, *
this);
204 void DrawRectangle(
int posX,
int posY,
int width,
int height)
const {
205 ::DrawRectangle(posX, posY, width, height, *
this);
208 void DrawRectangle(::Vector2 position, ::Vector2 size)
const {
209 ::DrawRectangleV(position, size, *
this);
212 void DrawRectangle(::Rectangle rec)
const {
213 ::DrawRectangleRec(rec, *
this);
216 void DrawRectangle(::Rectangle rec, ::Vector2 origin, Degree rotation)
const {
217 ::DrawRectanglePro(rec, origin, rotation, *
this);
220 void DrawRectangleLines(
int posX,
int posY,
int width,
int height)
const {
221 ::DrawRectangleLines(posX, posY, width, height, *
this);
224 void DrawRectangleLines(::Rectangle rec,
float lineThick)
const {
225 ::DrawRectangleLinesEx(rec, lineThick, *
this);
232 return ::ColorTint(*
this, tint);
239 return ::ColorBrightness(*
this, factor);
246 return ::ColorContrast(*
this, contrast);
253 return ::ColorAlpha(*
this, alpha);
260 return ::ColorAlphaBlend(dst, *
this, tint);
263 static Color LightGray() {
return LIGHTGRAY; }
264 static Color Gray() {
return GRAY; }
265 static Color DarkGray() {
return DARKGRAY; }
266 static Color Yellow() {
return YELLOW; }
267 static Color Gold() {
return GOLD; }
268 static Color Orange() {
return ORANGE; }
269 static Color Pink() {
return PINK; }
270 static Color Red() {
return RED; }
271 static Color Maroon() {
return MAROON; }
272 static Color Green() {
return GREEN; }
273 static Color Lime() {
return LIME; }
274 static Color DarkGreen() {
return DARKGREEN; }
275 static Color SkyBlue() {
return SKYBLUE; }
276 static Color Blue() {
return BLUE; }
277 static Color DarkBlue() {
return DARKBLUE; }
278 static Color Purple() {
return PURPLE; }
279 static Color Violet() {
return VIOLET; }
280 static Color DarkPurple() {
return DARKPURPLE; }
281 static Color Beige() {
return BEIGE; }
282 static Color Brown() {
return BROWN; }
283 static Color DarkBrown() {
return DARKBROWN; }
284 static Color White() {
return WHITE; }
285 static Color Black() {
return BLACK; }
286 static Color Blank() {
return BLANK; }
287 static Color Magenta() {
return MAGENTA; }
288 static Color RayWhite() {
return RAYWHITE; }
291 void set(const ::Color& color) {
Color AlphaBlend(::Color dst, ::Color tint) const
Returns src alpha-blended into dst color with tint.
Color(::Vector3 hsv)
Returns a Color from HSV values.
Color Contrast(float contrast)
Get color with contrast correction, contrast values between -1.0f and 1.0f.
Color Tint(::Color tint)
Get color multiplied with another color.
void DrawLine(::Vector2 startPos, ::Vector2 endPos) const
Draw a line using Vector points.
void DrawPixel(::Vector2 pos) const
Draw a pixel.
::Color FromHSV(float hue, float saturation, float value)
Returns a Color from HSV values.
Vector4 Normalize() const
Returns Color normalized as float [0..1].
Color Fade(float alpha) const
Returns color with alpha applied, alpha goes from 0.0f to 1.0f.
int ToInt() const
Returns hexadecimal value for a Color.
Color(::Vector4 normalized)
Returns Color from normalized values [0..1].
void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY) const
Draw a line.
Vector3 ToHSV() const
Returns HSV values for a Color.
void DrawLine(::Vector2 startPos, ::Vector2 endPos, float thick) const
Draw a line using Vector points, with a given thickness.
Color Alpha(float alpha) const
Returns color with alpha applied, alpha goes from 0.0f to 1.0f.
Color & ClearBackground()
Set background color (framebuffer clear color)
Color(unsigned int hexValue)
Get Color structure from hexadecimal value.
Color Brightness(float factor)
Get color with brightness correction, brightness factor goes from -1.0f to 1.0f.