#ifndef COLORADD_H
#define COLORADD_H
#include <SDL2/SDL.h>
#include <string>
class Color {
private:
SDL_Color color;
public:
// 构造函数
Color(Uint8 r = 0, Uint8 g = 0, Uint8 b = 0, Uint8 a = 255);
Color(const SDL_Color& sdlColor);
// 获取SDL_Color
SDL_Color get() const;
std::string gethex() const;
// 色相操作
Color& addhue(float step=1.0);
Color& coloradd(float step=1.0);
void fromhue(int hue); // RGB颜色从色相中来
void setcolor(int hue); //同上
// 饱和度操作
Color& addsaturation(float step);
Color& setsaturation(float sat);
Color& addsat(float step);
Color& setsat(float sat);
// 亮度操作
Color& addbrightness(float step);
Color& setbrightness(float bri);
Color& addbri(float step);
Color& setbri(float bri);
// 透明度操作
Color& addopacity(int step); //增加不透明度
Color& setopacity(int a); //设定不透明度
void rgbToHsv(Uint8 r, Uint8 g, Uint8 b, float& h, float& s, float& v) const;
void hsvToRgb(float h, float s, float v, Uint8& r, Uint8& g, Uint8& b) const;
};
#endif // COLORADD_H
-
- 2026 年 3 月
- 2026 年 2 月
- 2026 年 1 月
- 2025 年 12 月
- 2025 年 11 月
- 2025 年 10 月
- 2025 年 9 月
- 2025 年 6 月
- 2025 年 5 月
- 2025 年 3 月
- 2025 年 2 月
- 2025 年 1 月
- 2024 年 12 月
- 2024 年 8 月
- 2024 年 6 月
- 2024 年 5 月
- 2024 年 4 月
- 2024 年 3 月
- 2024 年 2 月
- 2023 年 11 月
- 2023 年 9 月
- 2023 年 6 月
- 2023 年 5 月
- 2023 年 4 月
- 2023 年 3 月
- 2023 年 2 月
- 2023 年 1 月
- 2022 年 12 月
- 2022 年 11 月
- 2022 年 10 月
- 2022 年 9 月
- 2022 年 8 月
- 2022 年 7 月
- 2022 年 6 月
- 2022 年 5 月
- 2022 年 4 月
- 2022 年 3 月
- 2022 年 2 月
- 2022 年 1 月
- 2021 年 12 月
- 2021 年 11 月
- 2021 年 10 月
- 2021 年 9 月
- 2021 年 8 月
- 2021 年 7 月
- 2021 年 6 月
- 2021 年 5 月
- 2021 年 4 月
- 2021 年 3 月
- 2021 年 2 月
- 2021 年 1 月
- 2020 年 12 月
- 2020 年 11 月
- 2020 年 10 月
- 2020 年 9 月
- 2020 年 8 月
- 2020 年 7 月
- 2020 年 6 月
- 2020 年 5 月
- 2020 年 4 月
- 2020 年 3 月
- 2020 年 2 月
- 2020 年 1 月
- 2019 年 12 月
- 2019 年 11 月
- 2019 年 10 月
- 2019 年 9 月
- 2019 年 8 月
- 2019 年 7 月
- 2019 年 6 月
- 2019 年 5 月
- 2019 年 4 月
- 2019 年 3 月
- 2019 年 2 月
- 2018 年 3 月
- 2018 年 1 月
- 2017 年 9 月
- 2017 年 5 月
- 2017 年 1 月
