SimpleWindow
载入中...
搜索中...
未找到
Color.h
1#pragma once
2
3#include "IComparable.h"
4#include "IToString.h"
5#include "KnownColor.h"
6#include <cstdint>
7#include <string>
8#include <type_traits>
9
10namespace sw
11{
15 struct Color : public IToString<Color>,
16 public IEqualityComparable<Color> {
20 uint8_t r;
21
25 uint8_t g;
26
30 uint8_t b;
31
35 uint8_t _reserved;
36
40 Color() = default;
41
45 Color(uint8_t r, uint8_t g, uint8_t b);
46
50 Color(KnownColor knownColor);
51
55 Color(COLORREF color);
56
60 operator COLORREF() const;
61
65 bool Equals(const Color &other) const;
66
70 std::wstring ToString() const;
71 };
72
73 // Color应为POD类型
74 static_assert(
75 std::is_trivial<Color>::value && std::is_standard_layout<Color>::value,
76 "Color should be a POD type.");
77}
相等性比较接口
Definition IComparable.h:14
为支持ToString方法的类提供统一接口
Definition IToString.h:13
颜色
Definition Color.h:16
bool Equals(const Color &other) const
判断两个Color是否相等
Color(KnownColor knownColor)
通过KnownColor构造Color结构体
Color(uint8_t r, uint8_t g, uint8_t b)
通过rgb构造Color结构体
uint8_t g
G分量
Definition Color.h:25
std::wstring ToString() const
获取描述当前对象的字符串
Color()=default
默认构造函数
Color(COLORREF color)
通过COLORREF构造Color结构体
uint8_t r
R分量
Definition Color.h:20
uint8_t _reserved
保留字段
Definition Color.h:35
uint8_t b
B分量
Definition Color.h:30