Class Color
- Namespace
- Dynamicweb.Imaging.Colors
- Assembly
- Dynamicweb.Core.dll
Class Color. Use the constructor or one of the fromRgb, fromHex or fromHsv to create a new instance.
public class Color
- Inheritance
-
Color
- Inherited Members
Constructors
Color(Color)
Initializes a new instance of the Color class.
public Color(Color color)
Parameters
colorColorThe color.
Properties
BaseColor
Gets the base color - defined when object was initialized.
public Color BaseColor { get; }
Property Value
- Color
The original color
Brightness
Gets the brightness from 1-255, where 255 is white and 1 is black.
public double Brightness { get; }
Property Value
- double
The brightness.
CleanColor
Gets the clean color based on original color. Hue not changed, saturation and value set to 100.
public Color CleanColor { get; }
Property Value
- Color
The color of the clean.
Hsl
Gets a HSL instance of this color.
public Hsl Hsl { get; }
Property Value
- Hsl
The HSL.
Hsv
Gets a HSV instance of this color.
public Hsv Hsv { get; }
Property Value
- Hsv
The HSV.
Methods
Darken(int)
Darkens the color with the specified percent (1-100).
public Color Darken(int percent)
Parameters
percentintThe percent (1-100).
Returns
- Color
Color.
Exceptions
- IndexOutOfRangeException
Percent must be between 1-100
Darken(string, int)
Darkens the specified color.
public static string Darken(string hex, int percent)
Parameters
Returns
- string
System.String.
FromHex(string?)
Creates a new instance of the Color class from hex value - with or withouth the #.
public static Color FromHex(string? hex)
Parameters
hexstringThe color hex. '#FFFFFF' or 'FFFFFF'
Returns
- Color
Color.
FromHsl(double, double, double)
Creates a new instance of the Color class from HSL values.
public static Color FromHsl(double hue, double saturation, double lightness)
Parameters
huedoubleThe hue. (0-360)
saturationdoubleThe saturation. (0-1)
lightnessdoubleThe lightness. (0-1)
Returns
- Color
Color.
Exceptions
- IndexOutOfRangeException
Hue must be between 0-360, Saturation must be between 0-1, Value must be between 0-1
FromHsv(double, double, double)
Creates a new instance of the Color class from HSV values.
public static Color FromHsv(double hue, double saturation, double value)
Parameters
Returns
- Color
Color.
Exceptions
- IndexOutOfRangeException
Hue must be between 0-360, Saturation must be between 0-1, Value must be between 0-1
FromRgb(int, int, int)
Creates a new instance of the Color class from RGB values.
public static Color FromRgb(int red, int green, int blue)
Parameters
redintThe red component value. Valid values are 0 through 255
greenintThe green component value. Valid values are 0 through 255
blueintThe blue component value. Valid values are 0 through 255
Returns
- Color
Color.
GenerateClearColors(int)
Generates clear colors based on the base color.
public ColorCollection GenerateClearColors(int count)
Parameters
countintThe count.
Returns
- ColorCollection
ColorCollection.
GenerateDarkGreyColors(int)
Generates dark grey colors.
public ColorCollection GenerateDarkGreyColors(int count)
Parameters
countintThe count.
Returns
- ColorCollection
ColorCollection.
GenerateGreyColors(int)
Generates grey colors.
public ColorCollection GenerateGreyColors(int count)
Parameters
countintThe count.
Returns
- ColorCollection
ColorCollection.
GenerateLightGreyColors(int)
Generates light grey colors.
public ColorCollection GenerateLightGreyColors(int count)
Parameters
countintThe count.
Returns
- ColorCollection
ColorCollection.
GeneratePastelColors(int)
Generates pastel colors.
public ColorCollection GeneratePastelColors(int count)
Parameters
countintThe count.
Returns
- ColorCollection
ColorCollection.
GenerateShadeColors(int)
Generates shade colors (Dark).
public ColorCollection GenerateShadeColors(int count)
Parameters
countintThe count.
Returns
- ColorCollection
ColorCollection.
GenerateSimilarColors(int)
Generates similar colors.
public ColorCollection GenerateSimilarColors(int count)
Parameters
countintThe count.
Returns
- ColorCollection
ColorCollection.
GenerateTintColors(int)
Generates tint colors (Light).
public ColorCollection GenerateTintColors(int count)
Parameters
countintThe count.
Returns
- ColorCollection
ColorCollection.
GenerateToneColors(int)
Generates tone colors (Medium).
public ColorCollection GenerateToneColors(int count)
Parameters
countintThe count.
Returns
- ColorCollection
ColorCollection.
GetAccentColor(int)
Gets the color of the accent.
public Color GetAccentColor(int degrees)
Parameters
degreesintThe color of the accent
Returns
- Color
The color
GetContrastColor()
Returns either black or white contrast color, based on the specified color.
public string GetContrastColor()
Returns
- string
The contrasting color
Lighten(int)
Lightens the color with the specified percent (1-100).
public Color Lighten(int percent)
Parameters
percentintThe percent (1-100).
Returns
- Color
Color.
Exceptions
- IndexOutOfRangeException
Percent must be between 1-100
Lighten(string, int)
Lightens the specified color.
public static string Lighten(string hex, int percent)
Parameters
Returns
- string
System.String.
ToHex()
Returns the hex value of the specified color.
public string ToHex()
Returns
- string
A hex value.
ToRgb()
Returns the RGB value of the specified color.
public string ToRgb()
Returns
- string
A RGB value.
ToString()
Returns current hex
public override string ToString()