diff --git a/src/goopylib/color/Color.h b/src/goopylib/color/Color.h index f8bd490d..a98b1043 100644 --- a/src/goopylib/color/Color.h +++ b/src/goopylib/color/Color.h @@ -25,19 +25,19 @@ namespace gp { * @example * auto color = Color(60, 180, 90, 0.5); */ - class Color { + class GPAPI Color { public: /** - * Create colors by passing RGB arguments or a hexstring. - * Specify an alpha value by passing a float as the last parameter. - * - * @param hexstring color hexadecimal string. '#' is optional. - * @param alpha alpha component of the color between 0-1 - * - * @throws std::invalid_argument invalid hexstring - * @throws std::invalid_argument alpha must be between 0-1 - */ - Color(const std::string &hexstring, float alpha = 1); // NOLINT(*-explicit-conversions) + * Create colors by passing RGB arguments or a hexstring. + * Specify an alpha value by passing a float as the last parameter. + * + * @param hexstring color hexadecimal string. '#' is optional. + * @param alpha alpha component of the color between 0-1 + * + * @throws std::invalid_argument invalid hexstring + * @throws std::invalid_argument alpha must be between 0-1 + */ + Color(const std::string &hexstring, float alpha = 1); // NOLINT(*-explicit-conversions) /** * Create colors by passing RGB arguments or a hexstring. @@ -57,17 +57,17 @@ namespace gp { Color(Color &&other) = default; - GPAPI virtual ~Color() = default; + virtual ~Color() = default; /** * @return a string representation of the color */ - [[nodiscard]] GPAPI virtual std::string toString() const; + [[nodiscard]] virtual std::string toString() const; /** * @return the red component of the color */ - [[nodiscard]] GPAPI int getRed() const; + [[nodiscard]] int getRed() const; // TODO unittests for changing RGB components and effect on HSV/HSL/CMYK/Hexstring @@ -75,55 +75,55 @@ namespace gp { * @param value between 0-255 * @throws std::invalid_argument value must be in the range specified */ - GPAPI void setRed(int value); + void setRed(int value); /** * @return the green component of the color */ - [[nodiscard]] GPAPI int getGreen() const; + [[nodiscard]] int getGreen() const; /** * @param value between 0-255 * @throws std::invalid_argument value must be in the range specified */ - GPAPI void setGreen(int value); + void setGreen(int value); /** * @return the blue component of the color */ - [[nodiscard]] GPAPI int getBlue() const; + [[nodiscard]] int getBlue() const; /** * @param value between 0-255 * @throws std::invalid_argument value must be in the range specified */ - GPAPI void setBlue(int value); + void setBlue(int value); /** * @return the alpha component of the color */ - [[nodiscard]] GPAPI float getAlpha() const; + [[nodiscard]] float getAlpha() const; /** * @param value between 0-1 * @throws std::invalid_argument value must be in the range specified */ - GPAPI void setAlpha(float value); + void setAlpha(float value); /** * @return the red component of the color between 0-1 */ - [[nodiscard]] GPAPI float getRedf() const; + [[nodiscard]] float getRedf() const; /** * @return the green component of the color between 0-1 */ - [[nodiscard]] GPAPI float getGreenf() const; + [[nodiscard]] float getGreenf() const; /** * @return the blue component of the color between 0-1 */ - [[nodiscard]] GPAPI float getBluef() const; + [[nodiscard]] float getBluef() const; /** * @return a struct with RGBA between 0-1 @@ -133,49 +133,49 @@ namespace gp { /** * Converts the Color to the RGB format */ - [[nodiscard]] GPAPI virtual ColorRGB toRGB() const; + [[nodiscard]] virtual ColorRGB toRGB() const; /** * Converts the Color to the Hexadecimal format */ - [[nodiscard]] GPAPI ColorHex toHex() const; + [[nodiscard]] ColorHex toHex() const; /** * Converts the Color to the CMYK format */ - [[nodiscard]] GPAPI ColorCMYK toCMYK() const; + [[nodiscard]] ColorCMYK toCMYK() const; /** * Converts the Color to the HSV format */ - [[nodiscard]] GPAPI virtual ColorHSV toHSV() const; + [[nodiscard]] virtual ColorHSV toHSV() const; /** * Converts the Color to the HSL format */ - [[nodiscard]] GPAPI virtual ColorHSL toHSL() const; + [[nodiscard]] virtual ColorHSL toHSL() const; // Operator Overloads - GPAPI Color operator+(int value) const; + Color operator+(int value) const; - GPAPI Color operator+(const Color &value) const; + Color operator+(const Color &value) const; - GPAPI Color operator-(int value) const; + Color operator-(int value) const; - GPAPI Color operator-(const Color &value) const; + Color operator-(const Color &value) const; - GPAPI Color &operator+=(int value); + Color &operator+=(int value); - GPAPI Color &operator+=(const Color &value); + Color &operator+=(const Color &value); - GPAPI Color &operator-=(int value); + Color &operator-=(int value); - GPAPI Color &operator-=(const Color &value); + Color &operator-=(const Color &value); - GPAPI bool operator==(const Color &) const = default; + bool operator==(const Color &) const = default; - GPAPI bool operator==(const std::string &other) const; + bool operator==(const std::string &other) const; Color &operator=(const Color &other) = default; @@ -201,12 +201,12 @@ namespace gp { int m_Blue; float m_Alpha; - GPAPI void _updateOnlyRGB(const ColorRGB &color); + void _updateOnlyRGB(const ColorRGB &color); - GPAPI virtual void _updateDerivedClass() { + virtual void _updateDerivedClass() { } - GPAPI void _clampValues(); + void _clampValues(); private: float m_Redf; @@ -216,5 +216,5 @@ namespace gp { } namespace gp { - GPAPI std::ostream &operator<<(std::ostream &os, const Color &color); + std::ostream &operator<<(std::ostream &os, const Color &color); } diff --git a/src/goopylib/color/ColorCMYK.h b/src/goopylib/color/ColorCMYK.h index 566fd3ef..0de30977 100644 --- a/src/goopylib/color/ColorCMYK.h +++ b/src/goopylib/color/ColorCMYK.h @@ -15,7 +15,7 @@ namespace gp { * @example * auto color = ColorCMYK(otherColor); */ - class ColorCMYK final : public Color { + class GPAPI ColorCMYK final : public Color { public: /** * Create a ColorCMYK from another color object. @@ -37,58 +37,58 @@ namespace gp { */ ColorCMYK(float cyan, float magenta, float yellow, float key, float alpha = 1.0f); - [[nodiscard]] GPAPI std::string toString() const override; + [[nodiscard]] std::string toString() const override; /** * @return the cyan component of the color between 0-1 */ - [[nodiscard]] GPAPI float getCyan() const; + [[nodiscard]] float getCyan() const; /** * @param value between 0-1 * @throws std::invalid_argument value must be in the range specified */ - GPAPI void setCyan(float value); + void setCyan(float value); /** * @return the magenta component of the color between 0-1 */ - [[nodiscard]] GPAPI float getMagenta() const; + [[nodiscard]] float getMagenta() const; /** * @param value between 0-1 * @throws std::invalid_argument value must be in the range specified */ - GPAPI void setMagenta(float value); + void setMagenta(float value); /** * @return the yellow component of the color between 0-1 */ - [[nodiscard]] GPAPI float getYellow() const; + [[nodiscard]] float getYellow() const; /** * @param value between 0-1 * @throws std::invalid_argument value must be in the range specified */ - GPAPI void setYellow(float value); + void setYellow(float value); /** * @return the key component of the color between 0-1 */ - [[nodiscard]] GPAPI float getKey() const; + [[nodiscard]] float getKey() const; /** * @param value between 0-1 * @throws std::invalid_argument value must be in the range specified */ - GPAPI void setKey(float value); + void setKey(float value); - [[nodiscard]] GPAPI ColorRGB toRGB() const override; + [[nodiscard]] ColorRGB toRGB() const override; - [[nodiscard]] GPAPI static ColorRGB toRGB(float cyan, float magenta, float yellow, float key, float alpha = 1); + [[nodiscard]] static ColorRGB toRGB(float cyan, float magenta, float yellow, float key, float alpha = 1); protected: - GPAPI void _updateDerivedClass() override; + void _updateDerivedClass() override; private: float m_Cyan; diff --git a/src/goopylib/color/ColorHSL.h b/src/goopylib/color/ColorHSL.h index 49fb53b9..28663b40 100644 --- a/src/goopylib/color/ColorHSL.h +++ b/src/goopylib/color/ColorHSL.h @@ -15,7 +15,7 @@ namespace gp { * @example * auto color = ColorHSL(otherColor); */ - class ColorHSL final : public Color { + class GPAPI ColorHSL final : public Color { public: /** * Create a ColorHSL from another color object. @@ -37,49 +37,49 @@ namespace gp { */ ColorHSL(int hue, float saturation, float luminance, float alpha = 1.0f); - [[nodiscard]] GPAPI std::string toString() const override; + [[nodiscard]] std::string toString() const override; /** * @return the hue component of the color between 0-360 */ - [[nodiscard]] GPAPI int getHue() const; + [[nodiscard]] int getHue() const; /** * @param value between 0-360 * @throws std::invalid_argument value must be in the range specified */ - GPAPI void setHue(int value); + void setHue(int value); /** * @return the saturation component of the color between 0-1 */ - [[nodiscard]] GPAPI float getSaturation() const; + [[nodiscard]] float getSaturation() const; /** * @param value between 0-1 * @throws std::invalid_argument value must be in the range specified */ - GPAPI void setSaturation(float value); + void setSaturation(float value); /** * @return the luminance component of the color between 0-1 */ - [[nodiscard]] GPAPI float getLuminance() const; + [[nodiscard]] float getLuminance() const; /** * @param value between 0-1 * @throws std::invalid_argument value must be in the range specified */ - GPAPI void setLuminance(float value); + void setLuminance(float value); - [[nodiscard]] GPAPI ColorRGB toRGB() const override; + [[nodiscard]] ColorRGB toRGB() const override; - [[nodiscard]] GPAPI ColorHSV toHSV() const override; + [[nodiscard]] ColorHSV toHSV() const override; - [[nodiscard]] GPAPI static ColorRGB toRGB(int hue, float saturation, float luminance, float alpha = 1); + [[nodiscard]] static ColorRGB toRGB(int hue, float saturation, float luminance, float alpha = 1); protected: - GPAPI void _updateDerivedClass() override; + void _updateDerivedClass() override; private: int m_Hue; diff --git a/src/goopylib/color/ColorHSV.h b/src/goopylib/color/ColorHSV.h index 65702724..3bd6ce2f 100644 --- a/src/goopylib/color/ColorHSV.h +++ b/src/goopylib/color/ColorHSV.h @@ -15,7 +15,7 @@ namespace gp { * @example * auto color = ColorHSV(otherColor); */ - class ColorHSV final : public Color { + class GPAPI ColorHSV final : public Color { public: /** * Create a ColorHSV from another color object. @@ -37,49 +37,49 @@ namespace gp { */ ColorHSV(int hue, float saturation, float value, float alpha = 1.0f); - [[nodiscard]] GPAPI std::string toString() const override; + [[nodiscard]] std::string toString() const override; /** * @return the hue component of the color between 0-360 */ - [[nodiscard]] GPAPI int getHue() const; + [[nodiscard]] int getHue() const; /** * @param value between 0-360 * @throws std::invalid_argument value must be in the range specified */ - GPAPI void setHue(int value); + void setHue(int value); /** * @return the saturation component of the color between 0-1 */ - [[nodiscard]] GPAPI float getSaturation() const; + [[nodiscard]] float getSaturation() const; /** * @param value between 0-1 * @throws std::invalid_argument value must be in the range specified */ - GPAPI void setSaturation(float value); + void setSaturation(float value); /** * @return the value component of the color between 0-1 */ - [[nodiscard]] GPAPI float getValue() const; + [[nodiscard]] float getValue() const; /** * @param value between 0-1 * @throws std::invalid_argument value must be in the range specified */ - GPAPI void setValue(float value); + void setValue(float value); - [[nodiscard]] GPAPI ColorRGB toRGB() const override; + [[nodiscard]] ColorRGB toRGB() const override; - [[nodiscard]] GPAPI ColorHSL toHSL() const override; + [[nodiscard]] ColorHSL toHSL() const override; - [[nodiscard]] GPAPI static ColorRGB toRGB(int hue, float saturation, float value, float alpha = 1); + [[nodiscard]] static ColorRGB toRGB(int hue, float saturation, float value, float alpha = 1); protected: - GPAPI void _updateDerivedClass() override; + void _updateDerivedClass() override; private: int m_Hue; diff --git a/src/goopylib/color/ColorHex.h b/src/goopylib/color/ColorHex.h index 04251556..331e2a39 100644 --- a/src/goopylib/color/ColorHex.h +++ b/src/goopylib/color/ColorHex.h @@ -15,7 +15,7 @@ namespace gp { * @example * auto color = ColorHex(otherColor); */ - class ColorHex final : public Color { + class GPAPI ColorHex final : public Color { public: /** * Create a ColorHex from another color object. @@ -34,21 +34,21 @@ namespace gp { */ ColorHex(const std::string& hexstring, float alpha = 1.0f); // NOLINT(*-explicit-conversions) - [[nodiscard]] GPAPI std::string toString() const override; + [[nodiscard]] std::string toString() const override; - [[nodiscard]] GPAPI ColorRGB toRGB() const override; + [[nodiscard]] ColorRGB toRGB() const override; - [[nodiscard]] static GPAPI ColorRGB toRGB(const std::string& hexstring, float alpha = 1); + [[nodiscard]] static ColorRGB toRGB(const std::string& hexstring, float alpha = 1); private: - GPAPI static ColorRGB _3toRGB(const std::string &hexstring, float alpha); + static ColorRGB _3toRGB(const std::string &hexstring, float alpha); - GPAPI static ColorRGB _4toRGB(const std::string &hexstring, float alpha); + static ColorRGB _4toRGB(const std::string &hexstring, float alpha); - GPAPI static ColorRGB _6toRGB(const std::string &hexstring, float alpha); + static ColorRGB _6toRGB(const std::string &hexstring, float alpha); - GPAPI static ColorRGB _7toRGB(const std::string &hexstring, float alpha); + static ColorRGB _7toRGB(const std::string &hexstring, float alpha); - GPAPI static int _digitToInt(char digit); + static int _digitToInt(char digit); }; } diff --git a/src/goopylib/color/ColorRGB.h b/src/goopylib/color/ColorRGB.h index 7540711e..7224921d 100644 --- a/src/goopylib/color/ColorRGB.h +++ b/src/goopylib/color/ColorRGB.h @@ -14,12 +14,12 @@ namespace gp { * @example * auto color = ColorRGB(otherColor); */ - class ColorRGB final : public Color { + class GPAPI ColorRGB final : public Color { public: /** * Create a ColorRGB from another color object. */ - GPAPI ColorRGB(const Color &color); // NOLINT(*-explicit-conversions) + ColorRGB(const Color &color); // NOLINT(*-explicit-conversions) /** * Create an RGB color by passing RGB arguments with an optional alpha parameter. @@ -33,6 +33,6 @@ namespace gp { * @throws std::invalid_argument RGB must be between 0-255 * @throws std::invalid_argument alpha must be between 0-1 */ - GPAPI ColorRGB(int red, int green, int blue, float alpha = 1.0f); + ColorRGB(int red, int green, int blue, float alpha = 1.0f); }; } diff --git a/src/goopylib/color/ColorStructs.h b/src/goopylib/color/ColorStructs.h index 58477e96..a55a392d 100644 --- a/src/goopylib/color/ColorStructs.h +++ b/src/goopylib/color/ColorStructs.h @@ -1,7 +1,7 @@ #pragma once namespace gp { - struct RGBAf final { + struct GPAPI RGBAf final { float red = 0; float green = 0; float blue = 0; @@ -14,12 +14,12 @@ namespace gp { alpha(alpha) { } - [[nodiscard]] GPAPI std::string toString() const; + [[nodiscard]] std::string toString() const; bool operator==(const RGBAf &) const = default; }; - struct RGBf final { + struct GPAPI RGBf final { float red = 0; float green = 0; float blue = 0; @@ -30,7 +30,7 @@ namespace gp { blue(blue) { } - [[nodiscard]] GPAPI std::string toString() const; + [[nodiscard]] std::string toString() const; bool operator==(const RGBf &) const = default; };