|
NexusForce 1.0.0
A rigorously engineered full-stack C++ backend library.
|
RGB颜色类 更多...
#include <color.hpp>
Public 成员函数 | |
| constexpr | color () noexcept=default |
| 默认构造函数,创建黑色(0,0,0,255) | |
| constexpr | color (const int gray) noexcept |
| 从灰度值构造 | |
| constexpr | color (const int gray, const int alpha) noexcept |
| 从灰度值和透明度构造 | |
| constexpr | color (const int red, const int green, const int blue) noexcept |
| 从RGB分量构造 | |
| constexpr | color (const int red, const int green, const int blue, const int alpha) noexcept |
| 从RGBA分量构造 | |
| constexpr | color (const string_view str) |
| 从十六进制字符串构造 | |
| constexpr | color (const string &str) |
| 从字符串对象构造 | |
| constexpr | color (const char *str) |
| 从C风格字符串构造 | |
| constexpr | color (color &&other) noexcept |
| 移动构造函数 | |
| constexpr color & | operator= (color &&other) noexcept |
| 移动赋值运算符 | |
| constexpr int | R () const noexcept |
| 获取红色分量 | |
| constexpr int | G () const noexcept |
| 获取绿色分量 | |
| constexpr int | B () const noexcept |
| 获取蓝色分量 | |
| constexpr int | A () const noexcept |
| 获取透明度 | |
| constexpr void | setR (const int red) noexcept |
| 设置红色分量 | |
| constexpr void | setG (const int green) noexcept |
| 设置绿色分量 | |
| constexpr void | setB (const int blue) noexcept |
| 设置蓝色分量 | |
| constexpr void | setA (const int alpha) noexcept |
| 设置透明度 | |
| constexpr void | set_color (const int red, const int green, const int blue) noexcept |
| 设置RGB颜色 | |
| constexpr void | set_color (const int red, const int green, const int blue, const int alpha) noexcept |
| 设置RGBA颜色 | |
| constexpr void | set_gray (const int gray) noexcept |
| 设置灰度值 | |
| constexpr void | set_gray (const int gray, const int alpha) noexcept |
| 设置灰度值和透明度 | |
| constexpr bool | is_transparent () const noexcept |
| 检查是否完全透明 | |
| constexpr bool | is_opaque () const noexcept |
| 检查是否完全不透明 | |
| constexpr double | opacity () const noexcept |
| 获取不透明度(0.0-1.0) | |
| constexpr void | set_opacity (double opacity) noexcept |
| 设置不透明度 | |
| constexpr color | operator+ (const color &other) const noexcept |
| 颜色加法 | |
| constexpr color | operator- (const color &other) const noexcept |
| 颜色减法 | |
| constexpr color | operator* (const double scalar) const noexcept |
| 颜色乘以标量 | |
| constexpr color | operator* (const int scalar) const noexcept |
| 颜色乘以整数标量 | |
| constexpr color & | operator+= (const color &other) noexcept |
| 颜色加等赋值 | |
| constexpr color & | operator-= (const color &other) noexcept |
| 颜色减等赋值 | |
| constexpr color & | operator*= (const double scalar) noexcept |
| 颜色乘等赋值 | |
| constexpr bool | equal_to (const color &other) const noexcept |
| 相等比较 | |
| constexpr bool | less_than (const color &other) const noexcept |
| 小于比较 | |
| constexpr color | blend (const color &background) const noexcept |
| 将当前颜色与背景色混合 | |
| constexpr double | gray_value () const noexcept |
| 计算灰度值 | |
| constexpr string | to_string () const |
| 转换为十六进制字符串 | |
| constexpr int | to_ansi_256 () const noexcept |
| 转换为256色ANSI颜色索引 | |
| constexpr int | to_ansi_basic (const bool is_background=false) const noexcept |
| 转换为基本ANSI颜色代码 | |
| constexpr integer32 | to_ansi_foreground (const bool use_256_color=true) const noexcept |
| 转换为ANSI前景色代码 | |
| constexpr integer32 | to_ansi_background (const bool use_256_color=true) const noexcept |
| 转换为ANSI背景色代码 | |
| constexpr color | to_premultiplied () const noexcept |
| 转换为标准预乘 Alpha 表示 | |
| constexpr color | from_premultiplied () const noexcept |
| 从预乘 Alpha 转换回直通 Alpha(Straight Alpha) | |
| constexpr integer32 | to_integer32 (const bool use_256_color=true) const noexcept |
| 转换为整数表示 | |
| constexpr size_t | to_hash () const noexcept |
| 计算哈希值 | |
| constexpr void | swap (color &other) noexcept |
| 交换两个颜色对象 | |
| Public 成员函数 继承自 neforce::iobject< color > | |
| constexpr bool | try_parse (const string_view str) noexcept |
| 尝试从字符串解析对象 | |
| Public 成员函数 继承自 neforce::istringify< color > | |
| constexpr string | to_string () const |
| 转换为字符串 | |
| Public 成员函数 继承自 neforce::icomparable< color > | |
| constexpr bool | operator== (const color &rhs) const noexcept(noexcept(derived().equal_to(rhs))) |
| 相等比较运算符 | |
| constexpr bool | operator!= (const color &rhs) const noexcept(noexcept(!(derived().equal_to(rhs)))) |
| 不等比较运算符 | |
| constexpr bool | operator< (const color &rhs) const noexcept(noexcept(derived().less_than(rhs))) |
| 小于比较运算符 | |
| constexpr bool | operator> (const color &rhs) const noexcept(noexcept(rhs.less_than(derived()))) |
| 大于比较运算符 | |
| constexpr bool | operator<= (const color &rhs) const noexcept(noexcept(!(rhs.less_than(derived())))) |
| 小于等于比较运算符 | |
| constexpr bool | operator>= (const color &rhs) const noexcept(noexcept(!(derived().less_than(rhs)))) |
| 大于等于比较运算符 | |
| Public 成员函数 继承自 neforce::ihashable< color > | |
| constexpr size_t | to_ihash () const noexcept(noexcept(derived().to_hash())) |
| 获取对象的哈希值 | |
静态 Public 成员函数 | |
| static constexpr color | lerp (const color &from, const color &to, double t) noexcept |
| 线性插值两个颜色 | |
| static constexpr color | parse (const string_view hex) |
| 从十六进制字符串解析颜色 | |
| static constexpr color | black () noexcept |
| 黑色 | |
| static constexpr color | white () noexcept |
| 白色 | |
| static constexpr color | gray () noexcept |
| 灰色 | |
| static constexpr color | red () noexcept |
| 红色 | |
| static constexpr color | green () noexcept |
| 绿色 | |
| static constexpr color | blue () noexcept |
| 蓝色 | |
| static constexpr color | yellow () noexcept |
| 黄色 | |
| static constexpr color | magenta () noexcept |
| 品红 | |
| static constexpr color | cyan () noexcept |
| 青色 | |
| static constexpr color | purple () noexcept |
| 紫色 | |
| static constexpr color | transparent () noexcept |
| 完全透明 | |
| 静态 Public 成员函数 继承自 neforce::iobject< color > | |
| static constexpr color | parse (const string_view str) |
| 从字符串解析对象 | |
RGB颜色类
表示一个RGB颜色,包含红、绿、蓝和透明度四个分量。 每个分量的取值范围为0-255,透明度255表示不透明。 支持颜色混合、线性插值、ANSI终端颜色转换等操作。
|
inlineexplicitconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineexplicitconstexpr |
|
inlineexplicitconstexpr |
从字符串对象构造
| str | 十六进制字符串 |
| value_exception | 格式无效时抛出 |
引用了 parse() , 以及 neforce::basic_string< CharT, Traits, Alloc >::view().
|
inlineexplicitconstexpr |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
将当前颜色与背景色混合
| background | 背景色 |
符合 W3C Compositing and Blending Level 1 规范。
引用了 color(), neforce::round() , 以及 transparent().
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
从预乘 Alpha 转换回直通 Alpha(Straight Alpha)
引用了 color(), neforce::round() , 以及 transparent().
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlinestaticconstexprnoexcept |
线性插值两个颜色
| from | 起始颜色 |
| to | 目标颜色 |
| t | 插值因子(0.0-1.0) |
引用了 color().
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlinestaticconstexpr |
从十六进制字符串解析颜色
| hex | 十六进制字符串(支持#RRGGBB或#RRGGBBAA格式) |
| value_exception | 格式无效时抛出 |
引用了 color(), neforce::basic_string_view< CharT, Traits >::length(), neforce::hexadecimal::parse(), neforce::basic_string_view< CharT, Traits >::substr(), neforce::basic_string_view< CharT, Traits >::tail() , 以及 neforce::unreachable().
|
inlinenodiscardconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlineconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
转换为256色ANSI颜色索引
符合 XTerm 256-Color Cube 规范。 彩色部分使用标准区间: 0, 95, 135, 175, 215, 255
被这些函数引用 to_ansi_background(), to_ansi_foreground() , 以及 to_integer32().
|
inlinenodiscardconstexprnoexcept |
转换为ANSI背景色代码
| use_256_color | 是否使用256色模式 |
引用了 to_ansi_256() , 以及 to_ansi_basic().
|
inlinenodiscardconstexprnoexcept |
转换为基本ANSI颜色代码
| is_background | 是否为背景色 |
被这些函数引用 to_ansi_background(), to_ansi_foreground() , 以及 to_integer32().
|
inlinenodiscardconstexprnoexcept |
转换为ANSI前景色代码
| use_256_color | 是否使用256色模式 |
引用了 to_ansi_256() , 以及 to_ansi_basic().
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
|
inlinenodiscardconstexprnoexcept |
转换为标准预乘 Alpha 表示
引用了 color() , 以及 neforce::round().
|
inlinenodiscardconstexpr |