Skip to content

Commit

Permalink
Moved __declspec(dllexport) in Color classes to apply to entire class
Browse files Browse the repository at this point in the history
  • Loading branch information
BhavyeMathur committed Feb 18, 2024
1 parent 2269ee4 commit 892b106
Show file tree
Hide file tree
Showing 7 changed files with 96 additions and 96 deletions.
86 changes: 43 additions & 43 deletions src/goopylib/color/Color.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -57,73 +57,73 @@ 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

/**
* @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
Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -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);
}
26 changes: 13 additions & 13 deletions src/goopylib/color/ColorCMYK.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down
24 changes: 12 additions & 12 deletions src/goopylib/color/ColorHSL.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
Expand Down
Loading

0 comments on commit 892b106

Please sign in to comment.