Class Color
Namespace: Aspose.Html.Drawing
Assembly: Aspose.HTML.dll (25.2.0)
The Color class lets you specify colors as Red-Green-Blue (RGB) values, Hue-Saturation-Luminosity (HSL) values, Hue-Saturation-Value (HSV) values, Hue-Whiteness-Blackness (HWB) values, lightness-A-B (LAB) values, Luminance-Chroma-Hue (LCH) values, Cyan-Magenta-Yellow-Key (CMYK) values, Natural colors (NCOL) values, or with a color name. An Alpha channel is also available to indicate transparency.
[ComVisible(true)]
public class Color
Inheritance
Inherited Members
object.GetType(), object.MemberwiseClone(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Constructors
Color()
Initializes a new instance of the Aspose.Html.Drawing.Color class. By default color is black.
public Color()
Color(float, float, float)
Initializes a new instance of the Aspose.Html.Drawing.Color class. All color components must be in the range 0-1.
public Color(float red, float green, float blue)
Parameters
red
float
The red component of the color.
green
float
The green component of the color.
blue
float
The blue component of the color.
Color(float, float, float, float)
Initializes a new instance of the Aspose.Html.Drawing.Color class. All color components must be in the range 0-1.
public Color(float red, float green, float blue, float alpha)
Parameters
red
float
The red component of the color.
green
float
The green component of the color.
blue
float
The blue component of the color.
alpha
float
The alpha component of the color.
Color(byte, byte, byte)
Initializes a new instance of the Aspose.Html.Drawing.Color class. All color components must be in the range 0-255.
public Color(byte red, byte green, byte blue)
Parameters
red
byte
The red component of the color.
green
byte
The green component of the color.
blue
byte
The blue component of the color.
Color(byte, byte, byte, byte)
Initializes a new instance of the Aspose.Html.Drawing.Color class. All color components must be in the range 0-255.
public Color(byte red, byte green, byte blue, byte alpha)
Parameters
red
byte
A byte that represents the red component of the color.
green
byte
A byte that represents the green component of the color.
blue
byte
A byte that represents the blue component of the color.
alpha
byte
A byte that represents the alpha component of the color.
Color(int, int, int)
Initializes a new instance of the Aspose.Html.Drawing.Color class. All color components must be in the range 0-255.
public Color(int red, int green, int blue)
Parameters
red
int
The red component of the color.
green
int
The green component of the color.
blue
int
The blue component of the color.
Color(int, int, int, int)
Initializes a new instance of the Aspose.Html.Drawing.Color class. All color components must be in the range 0-255.
public Color(int red, int green, int blue, int alpha)
Parameters
red
int
The red component of the color.
green
int
The green component of the color.
blue
int
The blue component of the color.
alpha
int
The alpha component of the color.
Properties
Alpha
Represents the alpha component of the color.
public float Alpha { get; }
Property Value
Blue
Represents the blue component of the color.
public float Blue { get; }
Property Value
Green
Represents the green component of the color.
public float Green { get; }
Property Value
Red
Represents the red component of the color
public float Red { get; }
Property Value
Methods
AddLuminosity(float)
Creates copy of the Color with Sum of its luminosity and the delta value.
public Color AddLuminosity(float delta)
Parameters
delta
float
Value of luminosity
Returns
A new instance of the Aspose.Html.Drawing.Color class
Convert(ColorModel)
Returns a color components in the format of the specified color model.
public IColorComponents Convert(ColorModel model)
Parameters
model
ColorModel
The color model.
Returns
A new instance of the Aspose.Html.Drawing.IColorComponents interface
Equals(object)
Determines whether the specified Aspose.Html.Drawing.Color is equal to this instance.
public override bool Equals(object obj)
Parameters
obj
object
The System.Object to compare with this instance.
Returns
true
if the specified System.Object is equal to this instance; otherwise, false
.
FromCmyk(float, float, float, float)
Returns a new Color with the requested cyan, magenta, yellow, key (black) values.
public static Color FromCmyk(float cyan, float magenta, float yellow, float key)
Parameters
cyan
float
A float that represents the cyan component of the color.
magenta
float
A float that represents the magenta component of the color.
yellow
float
A float that represents the yellow component of the color.
key
float
A float that represents the key component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromCmyka(float, float, float, float, float)
Returns a new Color with the requested cyan, magenta, yellow, key (black), alpha values.
public static Color FromCmyka(float cyan, float magenta, float yellow, float key, float alpha)
Parameters
cyan
float
A float that represents the cyan component of the color.
magenta
float
A float that represents the magenta component of the color.
yellow
float
A float that represents the yellow component of the color.
key
float
A float that represents the key component of the color.
alpha
float
A float that represents the alpha component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromGray(float)
Returns a new Color with the requested gray value.
public static Color FromGray(float gray)
Parameters
gray
float
A float that represents the gray value of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromHsl(float, float, float)
Returns a new Color with the requested hue, saturation, saturation values.
public static Color FromHsl(float hue, float saturation, float lightness)
Parameters
hue
float
A float that represents the hue component of the color.
saturation
float
A float that represents the saturation component of the color.
lightness
float
A float that represents the lightness component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromHsla(float, float, float, float)
Returns a new Color with the requested hue, saturation, saturation, alpha values.
public static Color FromHsla(float hue, float saturation, float lightness, float alpha)
Parameters
hue
float
A float that represents the hue component of the color.
saturation
float
A float that represents the saturation component of the color.
lightness
float
A float that represents the lightness component of the color.
alpha
float
A float that represents the alpha component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromHsv(float, float, float)
Returns a new Color with the requested hue, saturation, value.
public static Color FromHsv(float hue, float saturation, float value)
Parameters
hue
float
A float that represents the hue component of the color.
saturation
float
A float that represents the saturation component of the color.
value
float
A float that represents the value component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromHsva(float, float, float, float)
Returns a new Color with the requested hue, saturation, value, alpha.
public static Color FromHsva(float hue, float saturation, float value, float alpha)
Parameters
hue
float
A float that represents the hue component of the color.
saturation
float
A float that represents the saturation component of the color.
value
float
A float that represents the value component of the color.
alpha
float
A float that represents the alpha component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromHwb(float, float, float)
Returns a new Color with the requested hue, whiteness, blackness values.
public static Color FromHwb(float hue, float whiteness, float blackness)
Parameters
hue
float
A float that represents the hue component of the color.
whiteness
float
A float that represents the whiteness component of the color.
blackness
float
A float that represents the blackness component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromHwba(float, float, float, float)
Returns a new Color with the requested hue, whiteness, blackness values.
public static Color FromHwba(float hue, float whiteness, float blackness, float alpha)
Parameters
hue
float
A float that represents the hue component of the color.
whiteness
float
A float that represents the whiteness component of the color.
blackness
float
A float that represents the blackness component of the color.
alpha
float
A float that represents the alpha component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromInt(int)
Returns a new Color with the requested ARGB value.
public static Color FromInt(int argb)
Parameters
argb
int
A int that represents the ARGB value of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromLab(float, float, float)
Returns a new Color with the requested lightness, A, B values.
public static Color FromLab(float lightness, float a, float b)
Parameters
lightness
float
A float that represents the lightness component of the color.
a
float
A float that represents the A component of the color.
b
float
A float that represents the B component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromLaba(float, float, float, float)
Returns a new Color with the requested lightness, A, B, alpha values.
public static Color FromLaba(float lightness, float a, float b, float alpha)
Parameters
lightness
float
A float that represents the lightness component of the color.
a
float
A float that represents the A component of the color.
b
float
A float that represents the B component of the color.
alpha
float
A float that represents the alpha component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromLch(float, float, float)
Returns a new Color with the requested luminance, chroma, hue values.
public static Color FromLch(float luminance, float chroma, float hue)
Parameters
luminance
float
A float that represents the luminance component of the color.
chroma
float
A float that represents the chroma component of the color.
hue
float
A float that represents the hue component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromLcha(float, float, float, float)
Returns a new Color with the requested luminance, chroma, hue, alpha values.
public static Color FromLcha(float luminance, float chroma, float hue, float alpha)
Parameters
luminance
float
A float that represents the luminance component of the color.
chroma
float
A float that represents the chroma component of the color.
hue
float
A float that represents the hue component of the color.
alpha
float
A float that represents the alpha component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromOklab(float, float, float)
Returns a new Color with the requested lightness, A, B values for OKLAB model.
public static Color FromOklab(float lightness, float a, float b)
Parameters
lightness
float
A float that represents the lightness component of the color.
a
float
A float that represents the A component of the color.
b
float
A float that represents the B component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromOklaba(float, float, float, float)
Returns a new Color with the requested lightness, A, B, alpha values for OKLAB model.
public static Color FromOklaba(float lightness, float a, float b, float alpha)
Parameters
lightness
float
A float that represents the lightness component of the color.
a
float
A float that represents the A component of the color.
b
float
A float that represents the B component of the color.
alpha
float
A float that represents the alpha component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromOklch(float, float, float)
Returns a new Color with the requested luminance, chroma, hue values for OKLAB model.
public static Color FromOklch(float luminance, float chroma, float hue)
Parameters
luminance
float
A float that represents the luminance component of the color.
chroma
float
A float that represents the chroma component of the color.
hue
float
A float that represents the hue component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromOklcha(float, float, float, float)
Returns a new Color with the requested luminance, chroma, hue, alpha values for OKLAB model.
public static Color FromOklcha(float luminance, float chroma, float hue, float alpha)
Parameters
luminance
float
A float that represents the luminance component of the color.
chroma
float
A float that represents the chroma component of the color.
hue
float
A float that represents the hue component of the color.
alpha
float
A float that represents the alpha component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromRgb(byte, byte, byte)
Returns a new Color with the requested ged, green, blue values. All color components must be in the range 0-255.
public static Color FromRgb(byte red, byte green, byte blue)
Parameters
red
byte
A byte that represents the red component of the color.
green
byte
A byte that represents the green component of the color.
blue
byte
A byte that represents the blue component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromRgb(int, int, int)
Returns a new Color with the requested ged, green, blue values. All color components must be in the range 0-255.
public static Color FromRgb(int red, int green, int blue)
Parameters
red
int
A int that represents the red component of the color.
green
int
A int that represents the green component of the color.
blue
int
A int that represents the blue component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromRgb(float, float, float)
Returns a new Color with the requested ged, green, blue values. All color components must be in the range 0-1.
public static Color FromRgb(float red, float green, float blue)
Parameters
red
float
A float that represents the red component of the color.
green
float
A float that represents the green component of the color.
blue
float
A float that represents the blue component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromRgba(byte, byte, byte, byte)
Returns a new Color with the requested ged, green, blue, alpha values. All color components must be in the range 0-255.
public static Color FromRgba(byte red, byte green, byte blue, byte alpha)
Parameters
red
byte
A byte that represents the red component of the color.
green
byte
A byte that represents the green component of the color.
blue
byte
A byte that represents the blue component of the color.
alpha
byte
A byte that represents the alpha component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromRgba(int, int, int, int)
Returns a new Color with the requested ged, green, blue, alpha values. All color components must be in the range 0-255.
public static Color FromRgba(int red, int green, int blue, int alpha)
Parameters
red
int
A int that represents the red component of the color.
green
int
A int that represents the green component of the color.
blue
int
A int that represents the blue component of the color.
alpha
int
A int that represents the alpha component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromRgba(float, float, float, float)
Returns a new Color with the requested ged, green, blue, alpha values. All color components must be in the range 0-1.
public static Color FromRgba(float red, float green, float blue, float alpha)
Parameters
red
float
A float that represents the red component of the color.
green
float
A float that represents the green component of the color.
blue
float
A float that represents the blue component of the color.
alpha
float
A float that represents the alpha component of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromString(string)
Parses string containing the CSS color and returns a new Color.
public static Color FromString(string color)
Parameters
color
string
A string containing the color in the format RGB, HEX, HSL, HSV, HWB, CMYK, NCOL, LCH, OKLCH, LAB or OKLAB
Returns
A new instance of the Aspose.Html.Drawing.Color class
FromUint(uint)
Returns a new Color with the requested ARGB value.
public static Color FromUint(uint argb)
Parameters
argb
uint
A uint that represents the ARGB value of the color.
Returns
A new instance of the Aspose.Html.Drawing.Color class
GetComplementary()
Returns a new color that is on the opposite side of the color wheel from the original.
public Color GetComplementary()
Returns
A new instance of the Aspose.Html.Drawing.Color class.
GetHashCode()
Returns a hash code.
public override int GetHashCode()
Returns
A hash code.
GetHue()
Returns a Hue of the Color.
public float GetHue()
Returns
A Hue of the Color.
GetLuminosity()
Returns a luminosity of the Color.
public float GetLuminosity()
Returns
A luminosity of the Color.
GetSaturation()
Returns a saturation of the Color.
public float GetSaturation()
Returns
A saturation of the Color.
ToInt()
Encodes the Color ARGB components into int.
public int ToInt()
Returns
Encoded int.
ToName()
Returns the name of the color if it matches a color in the list of CSS named colors, or an empty string.
public string ToName()
Returns
A color name.
ToNaturalColorString(int)
Returns a Natural colors (NCol) specified color using a color letter with a number to specify the distance (in percent) from the color.
public string ToNaturalColorString(int digits)
Parameters
digits
int
Sets the rounding precision for color components.
Returns
A Natural colors (NCol) string
ToRgbHexString()
Returns a hexadecimal color is specified with: #RRGGBB.
public string ToRgbHexString()
Returns
A hexadecimal color string.
ToRgbString()
Returns a string containing the RGB color specified by: rgb(R, G, B).
public string ToRgbString()
Returns
A rgb string.
ToRgbaHexString()
Returns a Hexadecimal color is specified with: #RRGGBBAA.
public string ToRgbaHexString()
Returns
A Hexadecimal color string.
ToRgbaString()
Returns a string containing the RGBA color specified by: rgba(R, G, B, A).
public string ToRgbaString()
Returns
A rgba string.
ToString()
Returns a string that consists of the RGBA component values.
public override string ToString()
Returns
A human-readable string.
ToUint()
Encodes the Color ARGB components into unsigned int.
public uint ToUint()
Returns
Encoded unsigned int.
WithAlpha(float)
Creates copy of the Color with specified alpha component.
public Color WithAlpha(float alpha)
Parameters
alpha
float
Value of Alpha component
Returns
A new instance of the Aspose.Html.Drawing.Color class
WithHue(float)
Creates copy of the Color with specified Hue.
public Color WithHue(float hue)
Parameters
hue
float
Value of Hue.
Returns
>A new instance of the Aspose.Html.Drawing.Color class.
WithLuminosity(float)
Creates copy of the Color with specified luminosity.
public Color WithLuminosity(float luminosity)
Parameters
luminosity
float
Value of luminosity
Returns
A new instance of the Aspose.Html.Drawing.Color class.
WithSaturation(float)
Creates copy of the Color with specified saturation.
public Color WithSaturation(float saturation)
Parameters
saturation
float
Value of saturation.
Returns
>A new instance of the Aspose.Html.Drawing.Color class.