Show / Hide Table of Contents

Struct Color

Estructura universal que describe un color en sus componentes alfa, rojo, verde y azul.

Implements
IEquatable<Color>
IFormattable
IComparable<Color>
IColor
IScColor
ICastable<Color>
ICloneable<Color>
ICloneable
Inherited Members
object.Equals(object, object)
object.GetType()
object.ReferenceEquals(object, object)
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 Source

Color(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.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

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 Source

A

Obtiene o establece el valor RGB del canal alfa del color.

Declaration
public byte A { readonly get; set; }
Property Value
Type Description
byte
| Edit this page View Source

B

Obtiene o establece el valor RGB del canal azul del color.

Declaration
public byte B { readonly get; set; }
Property Value
Type Description
byte
| Edit this page View Source

G

Obtiene o establece el valor RGB del canal verde del color.

Declaration
public byte G { readonly get; set; }
Property Value
Type Description
byte
| Edit this page View Source

R

Obtiene o establece el valor RGB del canal rojo del color.

Declaration
public byte R { readonly get; set; }
Property Value
Type Description
byte
| Edit this page View Source

ScA

Obtiene o establece el valor ScRGB del canal alfa del color.

Declaration
public float ScA { readonly get; set; }
Property Value
Type Description
float
| Edit this page View Source

ScB

Obtiene o establece el valor ScRGB del canal azul del color.

Declaration
public float ScB { readonly get; set; }
Property Value
Type Description
float
| Edit this page View Source

ScG

Obtiene o establece el valor ScRGB del canal verde del color.

Declaration
public float ScG { readonly get; set; }
Property Value
Type Description
float
| Edit this page View Source

ScR

Obtiene o establece el valor ScRGB del canal rojo del color.

Declaration
public float ScR { readonly get; set; }
Property Value
Type Description
float
| Edit this page View Source

Transparent

Obtiene una referencia al color transparente.

Declaration
public static Color Transparent { get; }
Property Value
Type Description
Color

Methods

| Edit this page View Source

AreClose(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.

| Edit this page View Source

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.

| Edit this page View Source

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 colors no contiene elementos.

| Edit this page View Source

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 left y right.

| Edit this page View Source

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.

| Edit this page View Source

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.

| Edit this page View Source

Clone()

Creates a copy of this instance.

Declaration
public readonly Color Clone()
Returns
Type Description
Color

A copy of this instance of type Color.

| Edit this page View Source

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.

| Edit this page View Source

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
ValueType.Equals(object)
| Edit this page View Source

Equals(IColor)

Determina si el IColor especificado es igual al Color actual.

Declaration
public readonly bool Equals(IColor other)
Parameters
Type Name Description
IColor other

El Color a comparar contra este Color.

Returns
Type Description
bool

true si el Color especificado es igual al Color actual, false en caso contrario.

| Edit this page View Source

Equals(IScColor)

Determina si el IScColor especificado es igual al Color actual.

Declaration
public readonly bool Equals(IScColor other)
Parameters
Type Name Description
IScColor other

El Color a comparar contra este Color.

Returns
Type Description
bool

true si el Color especificado es igual al Color actual, false en caso contrario.

| Edit this page View Source

Equals(Color)

Determina si el Color especificado es igual al Color actual.

Declaration
public readonly bool Equals(Color other)
Parameters
Type Name Description
Color other

El Color a comparar contra este Color.

Returns
Type Description
bool

true si el Color especificado es igual al Color actual, false en caso contrario.

| Edit this page View Source

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.

| Edit this page View Source

GetHashCode()

Obtiene el código Hash pasa esta instancia.

Declaration
public override readonly int GetHashCode()
Returns
Type Description
int
Overrides
ValueType.GetHashCode()
| Edit this page View Source

Parse(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.

| Edit this page View Source

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.

| Edit this page View Source

ToString()

Returns a string that represents the current Color.

Declaration
public override readonly string ToString()
Returns
Type Description
string

A string that represents the current Color.

Overrides
ValueType.ToString()
| Edit this page View Source

ToString(string?)

Returns a string that represents the current Color.

Declaration
public readonly string ToString(string? format)
Parameters
Type Name Description
string format

Format.

Returns
Type Description
string

A string that represents the current Color.

| Edit this page View Source

ToString(string?, IFormatProvider?)

Returns a string that represents the current Color.

Declaration
public readonly string ToString(string? format, IFormatProvider? formatProvider)
Parameters
Type Name Description
string format

Format.

IFormatProvider formatProvider

Format provider.

Returns
Type Description
string

A string that represents the current Color.

| Edit this page View Source

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 T creado a partir de este Color.

Type Parameters
Name Description
T

Tipo de valor a obtener.

TParser

IColorParser<T> a utilizar.

| Edit this page View Source

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

true si la conversión fue exitosa, false en caso contrario.

Operators

| Edit this page View Source

operator +(in Color, in Color)

Adds a Color to a Color, yielding a new 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 left and right.

| Edit this page View Source

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 left y right.

| Edit this page View Source

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 left y right.

| Edit this page View Source

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.

| Edit this page View Source

implicit operator Color(in Color)

Convierte implícitamente un Color en un Color.

Declaration
public static implicit operator Color(in Color color)
Parameters
Type Name Description
Color color
Returns
Type Description
Color
| Edit this page View Source

implicit operator Color(in Color)

Convierte implícitamente un Color en un Color.

Declaration
public static implicit operator Color(in Color color)
Parameters
Type Name Description
Color color
Returns
Type Description
Color
| Edit this page View Source

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.

| Edit this page View Source

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 left * right.

| Edit this page View Source

operator -(in Color, in Color)

Sustrae un Color de un Color, dando como resultado un 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 left minus right.

Implements

IEquatable<T>
IFormattable
IComparable<T>
IColor
IScColor
ICastable<T>
ICloneable<T>
ICloneable

Extension Methods

Objects.ShallowCopyTo(object, object, Type)
ObjectExtensions.FieldsOf<T>(object)
ObjectExtensions.GetAttribute<T>(object)
ObjectExtensions.GetAttributes<T>(object)
ObjectExtensions.HasAttrValue<TAttribute, TValue>(object, out TValue)
ObjectExtensions.HasAttribute<T>(object)
ObjectExtensions.HasAttribute<T>(object, out T?)
ObjectExtensions.HasAttributes<T>(object, out IEnumerable<T>?)
ObjectExtensions.Is(object?, object?)
ObjectExtensions.IsEither(object, IEnumerable)
ObjectExtensions.IsEither(object, params object[])
ObjectExtensions.IsNeither(object, IEnumerable)
ObjectExtensions.IsNeither(object, params object[])
ObjectExtensions.IsNot(object?, object?)
ObjectExtensions.PropertiesOf<T>(object)
ObjectExtensions.WhichAre(object, IEnumerable<object>)
ObjectExtensions.WhichAre(object, params object[])
Common.IsBetween<T>(T, in T, in T)
Common.IsBetween<T>(T, in T, in T, in bool)
Common.IsBetween<T>(T, in T, in T, in bool, in bool)
Common.IsBetween<T>(T, in Range<T>)
Objects.Itself<T>(T)
Objects.ShallowClone<T>(T)
Objects.ShallowCopyTo<T>(T, T)
Common.Clamp<T>(T, in T)
Common.Clamp<T>(T, in T, in T)
AvaloniaColorExtensions.Color(Color)
CollectionExtensions.PushInto<TItem, TCollection>(TItem, ICollection<TCollection>)
ColorExtensions.Opaque(in Color)
ColorExtensions.Transparent(in Color)
ColorExtensions.WithAlpha(Color, in float)
DictionaryExtensions.PushInto<TKey, TValue>(TValue, TKey, IDictionary<TKey, TValue>)
  • Edit this page
  • View Source
In this article
Back to top Generated by DocFX