GraceFt v2.3
开源图形引擎 EGE(Easy Graphics Engine) 的高层封装库
 
载入中...
搜索中...
未找到
GFt::Color类 参考

颜色类 更多...

#include <Color.h>

Public 成员函数

constexpr Color (byte red=0, byte green=0, byte blue=0, byte alpha=255)
 构造函数
 
constexpr bytealpha ()
 
constexpr const bytealpha () const
 
Color blend (const Color &other) const
 混合颜色
 
constexpr byteblue ()
 
constexpr const byteblue () const
 
constexpr bytegreen ()
 
constexpr const bytegreen () const
 
constexpr bytered ()
 
constexpr const bytered () const
 
Color toGray () const
 转换为灰度颜色
 
std::tuple< float, float, float > toHSL () const
 转换为HSL颜色空间
 
std::tuple< float, float, float > toHSV () const
 转换为HSV颜色空间
 

静态 Public 成员函数

static Color fromHSL (float h, float s, float l)
 静态函数,从HSL颜色空间创建颜色
 
static Color fromHSV (float h, float s, float v)
 静态函数,从HSV颜色空间创建颜色
 

友元

std::ostream & operator<< (std::ostream &os, const Color &color)
 友元函数,输出颜色
 

详细描述

颜色类

颜色类,包含红绿蓝和透明度四个通道,支持HSL和HSV两种颜色空间,支持颜色的混合、转换等操作

构造及析构函数说明

◆ Color()

GFt::Color::Color ( byte red = 0,
byte green = 0,
byte blue = 0,
byte alpha = 255 )
inlineconstexpr

构造函数

若未指定任何参数,则默认构造为黑色

参数
red红色通道
green绿色通道
blue蓝色通道
alpha透明度通道,默认值为255

成员函数说明

◆ alpha() [1/2]

byte & GFt::Color::alpha ( )
inlineconstexpr
返回
透明度通道

◆ alpha() [2/2]

const byte & GFt::Color::alpha ( ) const
inlineconstexpr
返回
透明度通道 (const)

◆ blend()

Color GFt::Color::blend ( const Color & other) const

混合颜色

参数
other另一个颜色
返回
混合后的颜色

◆ blue() [1/2]

byte & GFt::Color::blue ( )
inlineconstexpr
返回
蓝色通道

◆ blue() [2/2]

const byte & GFt::Color::blue ( ) const
inlineconstexpr
返回
蓝色通道 (const)

◆ fromHSL()

Color GFt::Color::fromHSL ( float h,
float s,
float l )
static

静态函数,从HSL颜色空间创建颜色

参数
hHue(0~360)
sSaturation(0~1)
lLightness(0~1)
返回
颜色

◆ fromHSV()

Color GFt::Color::fromHSV ( float h,
float s,
float v )
static

静态函数,从HSV颜色空间创建颜色

参数
hHue(0~360)
sSaturation(0~1)
vValue(0~1)
返回
颜色

◆ green() [1/2]

byte & GFt::Color::green ( )
inlineconstexpr
返回
绿色通道

◆ green() [2/2]

const byte & GFt::Color::green ( ) const
inlineconstexpr
返回
绿色通道 (const)

◆ red() [1/2]

byte & GFt::Color::red ( )
inlineconstexpr
返回
红色通道

◆ red() [2/2]

const byte & GFt::Color::red ( ) const
inlineconstexpr
返回
红色通道 (const)

◆ toGray()

Color GFt::Color::toGray ( ) const

转换为灰度颜色

返回
灰度颜色

◆ toHSL()

std::tuple< float, float, float > GFt::Color::toHSL ( ) const

转换为HSL颜色空间

返回
以tuple形式返回HSL颜色空间的三个值,分别为Hue(0~360), Saturation(0~1), Lightness(0~1)

◆ toHSV()

std::tuple< float, float, float > GFt::Color::toHSV ( ) const

转换为HSV颜色空间

返回
以tuple形式返回HSV颜色空间的三个值,分别为Hue(0~360), Saturation(0~1), Value(0~1)

友元及相关符号说明

◆ operator<<

std::ostream & operator<< ( std::ostream & os,
const Color & color )
friend

友元函数,输出颜色

参数
os输出流
color颜色
返回
输出流 os