Struct Color
Estructura universal que describe un color en sus componentes alfa, rojo, verde y azul.
Implements
Inherited Members
Namespace: TheXDS.MCART.Types
Assembly: MCART.Coloring.dll
Syntax
public struct Color : IEquatable<Color>, IFormattable, IComparable<Color>, IColor, IScColor, ICastable<Color>, ICloneable<Color>, ICloneable
Constructors
| Edit this page View SourceColor(in byte, in byte, in byte)
Inicializa una nueva instancia de la estructura Color.
Declaration
public Color(in byte r, in byte g, in byte b)
Parameters
Type | Name | Description |
---|---|---|
byte | r | Canal rojo. |
byte | g | Canal verde. |
byte | b | Canal azul. |
Color(in byte, in byte, in byte, in byte)
Inicializa una nueva instancia de la estructura Color.
Declaration
public Color(in byte r, in byte g, in byte b, in byte a)
Parameters
Type | Name | Description |
---|---|---|
byte | r | Canal rojo. |
byte | g | Canal verde. |
byte | b | Canal azul. |
byte | a | Canal alfa. |
Color(in float, in float, in float)
Inicializa una nueva instancia de la estructura Color.
Declaration
public Color(in float r, in float g, in float b)
Parameters
Type | Name | Description |
---|---|---|
float | r | Canal rojo. |
float | g | Canal verde. |
float | b | Canal azul. |
Color(in float, in float, in float, in float)
Inicializa una nueva instancia de la estructura Color.
Declaration
public Color(in float r, in float g, in float b, in float a)
Parameters
Type | Name | Description |
---|---|---|
float | r | Canal rojo. |
float | g | Canal verde. |
float | b | Canal azul. |
float | a | Canal alfa. |
Properties
| Edit this page View SourceA
Obtiene o establece el valor RGB del canal alfa del color.
Declaration
public byte A { readonly get; set; }
Property Value
Type | Description |
---|---|
byte |
B
Obtiene o establece el valor RGB del canal azul del color.
Declaration
public byte B { readonly get; set; }
Property Value
Type | Description |
---|---|
byte |
G
Obtiene o establece el valor RGB del canal verde del color.
Declaration
public byte G { readonly get; set; }
Property Value
Type | Description |
---|---|
byte |
R
Obtiene o establece el valor RGB del canal rojo del color.
Declaration
public byte R { readonly get; set; }
Property Value
Type | Description |
---|---|
byte |
ScA
Obtiene o establece el valor ScRGB del canal alfa del color.
Declaration
public float ScA { readonly get; set; }
Property Value
Type | Description |
---|---|
float |
ScB
Obtiene o establece el valor ScRGB del canal azul del color.
Declaration
public float ScB { readonly get; set; }
Property Value
Type | Description |
---|---|
float |
ScG
Obtiene o establece el valor ScRGB del canal verde del color.
Declaration
public float ScG { readonly get; set; }
Property Value
Type | Description |
---|---|
float |
ScR
Obtiene o establece el valor ScRGB del canal rojo del color.
Declaration
public float ScR { readonly get; set; }
Property Value
Type | Description |
---|---|
float |
Transparent
Obtiene una referencia al color transparente.
Declaration
public static Color Transparent { get; }
Property Value
Type | Description |
---|---|
Color |
Methods
| Edit this page View SourceAreClose(in Color, in Color)
Determina si los colores son lo suficientemente similares.
Declaration
public static bool AreClose(in Color color1, in Color color2)
Parameters
Type | Name | Description |
---|---|---|
Color | color1 | Primer Color a comparar. |
Color | color2 | Segundo Color a comparar. |
Returns
Type | Description |
---|---|
bool | true si los colores son similares al menos en un 95%, false en caso contrario. |
AreClose(in Color, in Color, in float)
Determina si los colores son lo suficientemente similares.
Declaration
public static bool AreClose(in Color color1, in Color color2, in float delta)
Parameters
Type | Name | Description |
---|---|---|
Color | color1 | Primer Color a comparar. |
Color | color2 | Segundo Color a comparar. |
float | delta | Porcentaje aceptable de similitud entre os colores. |
Returns
Type | Description |
---|---|
bool | true si los colores son suficientemente similares, false en caso contrario. |
Blend(in IEnumerable<Color>)
Realiza una mezcla entre los colores especificados.
Declaration
public static Color Blend(in IEnumerable<Color> colors)
Parameters
Type | Name | Description |
---|---|---|
IEnumerable<Color> | colors | colección de colores a mezclar. |
Returns
Type | Description |
---|---|
Color | Una mezcla entre los colores especificados. |
Exceptions
Type | Condition |
---|---|
InvalidOperationException | Se produce si |
Blend(in Color, in Color)
Realiza una mezcla entre los colores especificados.
Declaration
public static Color Blend(in Color left, in Color right)
Parameters
Type | Name | Description |
---|---|---|
Color | left | El primer Color a mezclar. |
Color | right | El segundo Color a mezclar. |
Returns
Type | Description |
---|---|
Color | Una mezcla entre los colores |
BlendHealth(in float)
Mezcla un color de salud basado en el porcentaje.
Declaration
public static Color BlendHealth(in float x)
Parameters
Type | Name | Description |
---|---|---|
float | x | The x coordinate. |
Returns
Type | Description |
---|---|
Color | El color que representa la salud del porcentaje. |
BlendHeat(in float)
Mezcla un color de temperatura basado en el porcentaje.
Declaration
public static Color BlendHeat(in float x)
Parameters
Type | Name | Description |
---|---|---|
float | x | Valor porcentual utilizado para calcular la temperatura. |
Returns
Type | Description |
---|---|
Color | El color que representa la temperatura del porcentaje. |
Clone()
Creates a copy of this instance.
Declaration
public readonly Color Clone()
Returns
Type | Description |
---|---|
Color | A copy of this instance of type Color. |
CompareTo(Color)
Compara este Color contra otro.
Declaration
public readonly int CompareTo(Color other)
Parameters
Type | Name | Description |
---|---|---|
Color | other | Color a comparar. |
Returns
Type | Description |
---|---|
int | Un valor que determina la posición ordinal de este color con respecto al otro. |
Equals(object?)
Indica si este objeto y el especificado son la misma instancia.
Declaration
public override readonly bool Equals(object? obj)
Parameters
Type | Name | Description |
---|---|---|
object | obj |
Returns
Type | Description |
---|---|
bool |
Overrides
| Edit this page View SourceEquals(IColor)
Declaration
public readonly bool Equals(IColor other)
Parameters
Type | Name | Description |
---|---|---|
IColor | other |
Returns
Type | Description |
---|---|
bool | true si el Color especificado es igual al Color actual, false en caso contrario. |
Equals(IScColor)
Declaration
public readonly bool Equals(IScColor other)
Parameters
Type | Name | Description |
---|---|---|
IScColor | other |
Returns
Type | Description |
---|---|
bool | true si el Color especificado es igual al Color actual, false en caso contrario. |
Equals(Color)
Declaration
public readonly bool Equals(Color other)
Parameters
Type | Name | Description |
---|---|---|
Color | other |
Returns
Type | Description |
---|---|
bool | true si el Color especificado es igual al Color actual, false en caso contrario. |
From<T, TParser>(in T)
Convierte una estructura compatible en un Color.
Declaration
public static Color From<T, TParser>(in T from) where T : struct where TParser : IColorParser<T>, new()
Parameters
Type | Name | Description |
---|---|---|
T | from | Valor a convertir. |
Returns
Type | Description |
---|---|
Color | Un Color creado a partir del valor especificado. |
Type Parameters
Name | Description |
---|---|
T | Tipo de valor a convertir. |
TParser | IColorParser<T> a utilizar. |
GetHashCode()
Obtiene el código Hash pasa esta instancia.
Declaration
public override readonly int GetHashCode()
Returns
Type | Description |
---|---|
int |
Overrides
| Edit this page View SourceParse(string)
Crea un nuevo Color a partir de la cadena especificada.
Declaration
public static Color Parse(string from)
Parameters
Type | Name | Description |
---|---|---|
string | from | Cadena a partir de la cual crear un Color. |
Returns
Type | Description |
---|---|
Color | El Colorque ha sido creado. |
Exceptions
Type | Condition |
---|---|
FormatException | Se produce si no es posible crear un nuevo Color a partir de la cadena especificada. |
Similarity(in Color, in Color)
Determina el porcentaje de similitud entre dos colores.
Declaration
public static float Similarity(in Color c1, in Color c2)
Parameters
Type | Name | Description |
---|---|---|
Color | c1 | Primer Color a comparar. |
Color | c2 | Segundo Color a comparar. |
Returns
Type | Description |
---|---|
float | Un float que representa el porcentaje de similitud entre ambos colores. |
ToString()
Declaration
public override readonly string ToString()
Returns
Type | Description |
---|---|
string |
Overrides
| Edit this page View SourceToString(string?)
Declaration
public readonly string ToString(string? format)
Parameters
Type | Name | Description |
---|---|---|
string | format | Format. |
Returns
Type | Description |
---|---|
string |
ToString(string?, IFormatProvider?)
Declaration
public readonly string ToString(string? format, IFormatProvider? formatProvider)
Parameters
Type | Name | Description |
---|---|---|
string | format | Format. |
IFormatProvider | formatProvider | Format provider. |
Returns
Type | Description |
---|---|
string |
To<T, TParser>(in Color)
Convierte un Color en un valor de tipo
T
, utilizando el
IColorParser<T> especificado.
Declaration
public static T To<T, TParser>(in Color from) where T : struct where TParser : IColorParser<T>, new()
Parameters
Type | Name | Description |
---|---|---|
Color | from | Color a convertir. |
Returns
Type | Description |
---|---|
T | Un valor de tipo |
Type Parameters
Name | Description |
---|---|
T | Tipo de valor a obtener. |
TParser | IColorParser<T> a utilizar. |
TryParse(string, out Color)
Intenta crear un Color a partir de la cadena especificada.
Declaration
public static bool TryParse(string from, out Color color)
Parameters
Type | Name | Description |
---|---|---|
string | from | Cadena a partir de la cual crear un Color. |
Color | color | Parámetro de salida. El Colorque ha sido creado. |
Returns
Type | Description |
---|---|
bool |
Operators
| Edit this page View Sourceoperator +(in Color, in Color)
Declaration
public static Color operator +(in Color left, in Color right)
Parameters
Type | Name | Description |
---|---|---|
Color | left | The first Color to add. |
Color | right | The second Color to add. |
Returns
Type | Description |
---|---|
Color | The Color that is the sum of the values of
|
operator /(in Color, in float)
Realiza una mezcla entre los colores especificados.
Declaration
public static Color operator /(in Color left, in float right)
Parameters
Type | Name | Description |
---|---|---|
Color | left | El primer Color a mezclar. |
float | right | El segundo Color a mezclar. |
Returns
Type | Description |
---|---|
Color | Una mezcla entre los colores |
operator /(in Color, in Color)
Realiza una mezcla entre los colores especificados.
Declaration
public static Color operator /(in Color left, in Color right)
Parameters
Type | Name | Description |
---|---|---|
Color | left | El primer Color a mezclar. |
Color | right | El segundo Color a mezclar. |
Returns
Type | Description |
---|---|
Color | Una mezcla entre los colores |
operator ==(in Color, in Color)
Determina si dos instancias de Color son iguales.
Declaration
public static bool operator ==(in Color left, in Color right)
Parameters
Type | Name | Description |
---|---|---|
Color | left | El primer Color a comprobar. |
Color | right | El segundo Color a comprobar. |
Returns
Type | Description |
---|---|
bool | true ambas instancias de Color son iguales, false en caso contrario. |
implicit operator Color(in Color)
Declaration
public static implicit operator Color(in Color color)
Parameters
Type | Name | Description |
---|---|---|
Color | color |
Returns
Type | Description |
---|---|
Color |
implicit operator Color(in Color)
Declaration
public static implicit operator Color(in Color color)
Parameters
Type | Name | Description |
---|---|---|
Color | color |
Returns
Type | Description |
---|---|
Color |
operator !=(in Color, in Color)
Determina si dos instancias de Color son distintas.
Declaration
public static bool operator !=(in Color left, in Color right)
Parameters
Type | Name | Description |
---|---|---|
Color | left | El primer Color a comprobar. |
Color | right | El segundo Color a comprobar. |
Returns
Type | Description |
---|---|
bool | true ambas instancias de Color son distintas, false en caso contrario. |
operator *(in Color, in float)
Computes the product of left
and
right
, yielding a new Color.
Declaration
public static Color operator *(in Color left, in float right)
Parameters
Type | Name | Description |
---|---|---|
Color | left | The Color to multiply. |
float | right | The float to multiply by. |
Returns
Type | Description |
---|---|
Color | The Color that is |
operator -(in Color, in Color)
Declaration
public static Color operator -(in Color left, in Color right)
Parameters
Type | Name | Description |
---|---|---|
Color | left | The Color to subtract from (the minuend). |
Color | right | The Color to subtract (the subtrahend). |
Returns
Type | Description |
---|---|
Color | The Color that is |