Skip to content

Commit

Permalink
BLUGA-GRAPHICS: Change all colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Saverio976 committed Nov 4, 2023
1 parent 0d4cc75 commit cdbe631
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,10 @@ namespace Types {
};

struct Color {
Color(Raylib::Color color) : color(color) {};
Color(Raylib::Color colorRay)
{
color = colorRay;
}
Raylib::Color color;
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ namespace Raylib {

class Drawing {
public:
static void clearBackground(Color color);
static void clearBackground(Raylib::Color color);

static void beginDrawing();

Expand Down Expand Up @@ -136,24 +136,24 @@ namespace Raylib {

class DrawShape {
public:
static void drawPixel(int posX, int posY, Color color);
static void drawPixel(int posX, int posY, Raylib::Color color);

static void drawCircle(int centerX, int centerY, float radius, Color color);
static void drawCircle(int centerX, int centerY, float radius, Raylib::Color color);

static void drawRectangle(int posX, int posY, int width, int height, Color color);
static void drawRectangle(int posX, int posY, int width, int height, Raylib::Color color);
};

class RayColor {
public:
static Color fade(Color color, float alpha);
static Raylib::Color fade(Raylib::Color color, float alpha);

static int colorToInt(Color color);
static int colorToInt(Raylib::Color color);

static Vector4 colorNormalize(Color color);
static Vector4 colorNormalize(Raylib::Color color);

static Color colorFromNormalized(Vector4 normalized);
static Raylib::Color colorFromNormalized(Vector4 normalized);

static Color getColor(unsigned int hexValue);
static Raylib::Color getColor(unsigned int hexValue);
};

class TextureManager {
Expand All @@ -165,7 +165,7 @@ namespace Raylib {
class RayImage {
public:
static std::unique_ptr<RayImage> fromFile(const std::string &fileName);
static std::unique_ptr<RayImage> fromColor(int width, int height, Color color);
static std::unique_ptr<RayImage> fromColor(int width, int height, Raylib::Color color);

virtual ~RayImage() = default;

Expand Down Expand Up @@ -207,13 +207,13 @@ namespace Raylib {

// draw texture functions

virtual void draw(int posX, int posY, Color tint) = 0;
virtual void draw(int posX, int posY, Raylib::Color tint) = 0;

virtual void drawV(Vector2 position, Color tint) = 0;
virtual void drawV(Vector2 position, Raylib::Color tint) = 0;

virtual void drawEx(Vector2 position, float rotation, float scale, Color tint) = 0;

virtual void drawRec(Rectangle source, Vector2 position, Color tint) = 0;
virtual void drawRec(Rectangle source, Vector2 position, Raylib::Color tint) = 0;

virtual void drawPro(Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint) = 0;
};
Expand Down Expand Up @@ -283,11 +283,11 @@ namespace Raylib {

class Text {
public:
static void drawText(std::string text, int posX, int posY, int fontSize, Color color);
static void drawText(std::string text, int posX, int posY, int fontSize, Raylib::Color color);

static int measureText(const std::string text, int fontSize);

static std::shared_ptr<Text> fromText(const std::string &text, Vector2 position = Vector2(0, 0), float fontSize = 20.0F, Color color = Color(255, 255, 255, 255));
static std::shared_ptr<Text> fromText(const std::string &text, Vector2 position = Vector2(0, 0), float fontSize = 20.0F, Raylib::Color color = Raylib::Color(Raylib::ColorDef::White));

virtual ~Text() = default;

Expand All @@ -309,9 +309,9 @@ namespace Raylib {

virtual void setPixelPosition(Vector2 position) = 0;

virtual void setColor(Color color) = 0;
virtual void setColor(Raylib::Color color) = 0;

[[nodiscard]] virtual Color getColor() const = 0;
[[nodiscard]] virtual Raylib::Color getColor() const = 0;

virtual void setCurrentFontSize(float fontSize) = 0;

Expand Down
18 changes: 9 additions & 9 deletions libs/B-luga-graphics/src/RaylibImpl/Graphics/Graphics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ namespace Raylib {
}
}

RayImageImpl::RayImageImpl(int width, int height, Color color)
RayImageImpl::RayImageImpl(int width, int height, Raylib::Color color)
: _image(GenImageColor(width, height, {color.r, color.g, color.b, color.a}))
{
}
Expand Down Expand Up @@ -143,30 +143,30 @@ namespace Raylib {

// draw texture functions

void SpriteImpl::draw(int posX, int posY, Color tint)
void SpriteImpl::draw(int posX, int posY, Raylib::Color tint)
{
::Color tnt = {tint.r, tint.g, tint.b, tint.a};

DrawTexture(_texture, posX, posY, tnt);
}

void SpriteImpl::drawV(Vector2 position, Color tint)
void SpriteImpl::drawV(Vector2 position, Raylib::Color tint)
{
::Vector2 pos = {position.x, position.y};
::Color tnt = {tint.r, tint.g, tint.b, tint.a};

DrawTextureV(_texture, pos, tnt);
}

void SpriteImpl::drawEx(Vector2 position, float rotation, float scale, Color tint)
void SpriteImpl::drawEx(Vector2 position, float rotation, float scale, Raylib::Color tint)
{
::Vector2 pos = {position.x, position.y};
::Color tnt = {tint.r, tint.g, tint.b, tint.a};

DrawTextureEx(_texture, pos, rotation, scale, tnt);
}

void SpriteImpl::drawRec(Rectangle source, Vector2 position, Color tint)
void SpriteImpl::drawRec(Rectangle source, Vector2 position, Raylib::Color tint)
{
::Rectangle src = {source.x, source.y, source.width, source.height};
::Vector2 pos = {position.x, position.y};
Expand All @@ -175,7 +175,7 @@ namespace Raylib {
DrawTextureRec(_texture, src, pos, tnt);
}

void SpriteImpl::drawPro(Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint)
void SpriteImpl::drawPro(Rectangle source, Rectangle dest, Vector2 origin, float rotation, Raylib::Color tint)
{
::Rectangle src = {source.x, source.y, source.width, source.height};
::Rectangle dst = {dest.x, dest.y, dest.width, dest.height};
Expand All @@ -200,7 +200,7 @@ namespace Raylib {

// Text functions and classes

TextImpl::TextImpl(std::string text, Vector2 position, float fontSize, Color color)
TextImpl::TextImpl(std::string text, Vector2 position, float fontSize, Raylib::Color color)
: _text(std::move(text)),
_fontSize(fontSize),
_currentFontSize(fontSize),
Expand Down Expand Up @@ -278,12 +278,12 @@ namespace Raylib {
_pixelPosition = position;
}

void TextImpl::setColor(Color color)
void TextImpl::setColor(Raylib::Color color)
{
_color = color;
}

Color TextImpl::getColor() const
Raylib::Color TextImpl::getColor() const
{
return _color;
}
Expand Down
18 changes: 9 additions & 9 deletions libs/B-luga-graphics/src/RaylibImpl/Graphics/Graphics.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,15 @@ namespace Raylib {

// draw texture functions

void draw(int posX, int posY, Color tint) override;
void draw(int posX, int posY, Raylib::Color tint) override;

void drawV(Vector2 position, Color tint) override;
void drawV(Vector2 position, Raylib::Color tint) override;

void drawEx(Vector2 position, float rotation, float scale, Color tint) override;
void drawEx(Vector2 position, float rotation, float scale, Raylib::Color tint) override;

void drawRec(Rectangle source, Vector2 position, Color tint) override;
void drawRec(Rectangle source, Vector2 position, Raylib::Color tint) override;

void drawPro(Rectangle source, Rectangle dest, Vector2 origin, float rotation, Color tint) override;
void drawPro(Rectangle source, Rectangle dest, Vector2 origin, float rotation, Raylib::Color tint) override;

private:
void loadTextureFromImage(std::unique_ptr<RayImage> image);
Expand All @@ -104,7 +104,7 @@ namespace Raylib {
class TextImpl : public Text {
public:

TextImpl(std::string text, Vector2 position, float fontSize, Color color);
TextImpl(std::string text, Vector2 position, float fontSize, Raylib::Color color);

void draw() override;

Expand All @@ -124,9 +124,9 @@ namespace Raylib {

void setPixelPosition(Vector2 position) override;

void setColor(Color color) override;
void setColor(Raylib::Color color) override;

[[nodiscard]] Color getColor() const override;
[[nodiscard]] Raylib::Color getColor() const override;

void setCurrentFontSize(float fontSize) override;

Expand All @@ -138,7 +138,7 @@ namespace Raylib {
std::string _text;
float _fontSize;
float _currentFontSize;
Color _color;
Raylib::Color _color;
Vector2 _position;
Vector2 _pixelPosition;
};
Expand Down

0 comments on commit cdbe631

Please sign in to comment.