#pragma once

#include <memory>
#include <vector>
#include <string>

class Color
{
public:

    Color(const std::string& hexString);
    Color(unsigned char r = 0, unsigned char g = 0, unsigned char b = 0, double a = 1.0);

    static std::unique_ptr<Color> Create(unsigned char r, unsigned char g, unsigned char b, double a = 1.0);
    static std::unique_ptr<Color> Create(const Color& color);

    unsigned char getR() const;
    unsigned char getG() const;
    unsigned char getB() const;
    double getAlpha() const;

    std::vector<double> getAsVectorDouble() const;

    uint32_t getAsUInt32() const;

    std::string toString() const;

    void setAlpha(float alpha)
    {
        mAlpha = static_cast<double>(alpha);
    }

    bool operator==(const Color& rhs) const
    {
       return (mR == rhs.mR)
       && (mG == rhs.mG)
       && (mB == rhs.mB)
       && (mAlpha == rhs.mAlpha);
    }

    bool operator!=(const Color& rhs) const
    {
      return !operator==(rhs);
    }

private:
    unsigned char toDecimal(const std::string& hex) const;

    unsigned char mR{0};
    unsigned char mG{0};
    unsigned char mB{0};
    double mAlpha{0.0};
};

using ColorPtr = std::shared_ptr<Color>;
using ColorUPtr = std::unique_ptr<Color>;
