Struct Color
- Namespace
- HeyBox
- Assembly
- HeyBox.Net.Core.dll
表示黑盒语音中使用的颜色。
public readonly struct Color
- Inherited Members
Constructors
Color(byte, byte, byte)
使用指定的 RGB 通道值初始化一个 Color 结构的新实例。
public Color(byte r, byte g, byte b)
Parameters
Examples
创建 #607D8B(http://www.color-hex.com/color/607d8b)所表示的颜色:
Color darkGrey = new Color((byte)0x60, (byte)0x7D, (byte)0x8B);
Exceptions
- ArgumentException
所提供的三个通道的强度值所组成的颜色的原始值超过了 MaxDecimalValue。
Color(int, int, int)
使用指定的 RGB 通道值初始化一个 Color 结构的新实例。
public Color(int r, int g, int b)
Parameters
Examples
创建 #607D8B(http://www.color-hex.com/color/607d8b)所表示的颜色:
Color darkGrey = new Color(96, 125, 139);
Exceptions
- ArgumentException
所提供的三个通道的强度值所组成的颜色的原始值超过了 MaxDecimalValue。
Color(float, float, float)
使用指定的 RGB 通道值初始化一个 Color 结构的新实例。
public Color(float r, float g, float b)
Parameters
Examples
创建 #607D8B(http://www.color-hex.com/color/607d8b)所表示的颜色:
Color darkGrey = new Color(0.38f, 0.49f, 0.55f);
Exceptions
- ArgumentException
所提供的三个通道的强度值所组成的颜色的原始值超过了 MaxDecimalValue。
Color(uint)
使用指定的 24 位无符号整型值初始化一个 Color 结构的新实例。
public Color(uint rawValue)
Parameters
rawValue
uint颜色的 24 位无符号整型原始值。
Examples
创建 #607D8B(http://www.color-hex.com/color/607d8b)所表示的颜色:
Color darkGrey = new Color(0x607D8B);
Exceptions
- ArgumentException
颜色原始值超过了 MaxDecimalValue。
Fields
Default
获取默认颜色。
public static readonly Color Default
Field Value
MaxDecimalValue
获取一个黑盒语音颜色的最大值的原始值。
public const uint MaxDecimalValue = 16777215
Field Value
Properties
B
获取此颜色的蓝色通道的强度。
public byte B { get; }
Property Value
G
获取此颜色的绿色通道的强度。
public byte G { get; }
Property Value
R
获取此颜色的红色通道的强度。
public byte R { get; }
Property Value
RawValue
获取此颜色的原始值。
public uint RawValue { get; }
Property Value
Remarks
颜色以 24 位无符号整型值 RGB 格式进行编码,由高至低的每 8 位分别表示红色、绿色和蓝色通道的强度。
Methods
Equals(object?)
Indicates whether this instance and a specified object are equal.
public override bool Equals(object? obj)
Parameters
obj
objectThe object to compare with the current instance.
Returns
- bool
true if
obj
and this instance are the same type and represent the same value; otherwise, false.
GetHashCode()
Returns the hash code for this instance.
public override int GetHashCode()
Returns
- int
A 32-bit signed integer that is the hash code for this instance.
Parse(string)
将颜色的字符串表示形式转换为颜色对象。
public static Color Parse(string rawValue)
Parameters
rawValue
string要解析为颜色的字符串。
Returns
- Color
颜色对象。
Exceptions
- ArgumentOutOfRangeException
值必须是有效长度的数字。
ToString()
获取此颜色带有 #
前缀的 RGB 十六进制字符串表示形式(例如 #000CCC
)。
public override string ToString()
Returns
- string
此颜色带有
#
前缀的 RGB 十六进制字符串表示形式(例如#000CCC
)。
TryParse(string, out Color)
将颜色的字符串表示形式转换为颜色对象。
public static bool TryParse(string rawValue, out Color color)
Parameters
Returns
- bool
如果转换成功,则为
true
;否则为false
。
Operators
operator ==(Color, Color)
判定两个 Color 是否相等。
public static bool operator ==(Color lhs, Color rhs)
Parameters
Returns
explicit operator Color(Color)
public static explicit operator Color(Color color)
Parameters
Returns
implicit operator Color(Color)
public static implicit operator Color(Color color)
Parameters
Returns
implicit operator uint(Color)
获取此颜色的原始值。
public static implicit operator uint(Color color)
Parameters
color
Color
Returns
Remarks
颜色以 24 位无符号整型值 RGB 格式进行编码,由高至低的每 8 位分别表示红色、绿色和蓝色通道的强度。
implicit operator Color(uint)
使用指定的 24 位无符号整型值初始化一个 Color 结构的新实例。
public static implicit operator Color(uint rawValue)
Parameters
rawValue
uint颜色的 24 位无符号整型原始值。
Returns
Examples
创建 #607D8B(http://www.color-hex.com/color/607d8b)所表示的颜色:
Color darkGrey = 0x607D8B;
Exceptions
- ArgumentException
颜色原始值超过了 MaxDecimalValue。
operator !=(Color, Color)
判定两个 Color 是否不相等。
public static bool operator !=(Color lhs, Color rhs)