Table of Contents

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

color Color

The 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

percent int

The 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

hex string

The color hex. '#FFFFFF' or 'FFFFFF'

percent int

The percent (1-100).

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

hex string

The 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

hue double

The hue. (0-360)

saturation double

The saturation. (0-1)

lightness double

The 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

hue double

The hue. (0-360)

saturation double

The saturation. (0-1)

value double

The value. (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

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

red int

The red component value. Valid values are 0 through 255

green int

The green component value. Valid values are 0 through 255

blue int

The 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

count int

The count.

Returns

ColorCollection

ColorCollection.

GenerateDarkGreyColors(int)

Generates dark grey colors.

public ColorCollection GenerateDarkGreyColors(int count)

Parameters

count int

The count.

Returns

ColorCollection

ColorCollection.

GenerateGreyColors(int)

Generates grey colors.

public ColorCollection GenerateGreyColors(int count)

Parameters

count int

The count.

Returns

ColorCollection

ColorCollection.

GenerateLightGreyColors(int)

Generates light grey colors.

public ColorCollection GenerateLightGreyColors(int count)

Parameters

count int

The count.

Returns

ColorCollection

ColorCollection.

GeneratePastelColors(int)

Generates pastel colors.

public ColorCollection GeneratePastelColors(int count)

Parameters

count int

The count.

Returns

ColorCollection

ColorCollection.

GenerateShadeColors(int)

Generates shade colors (Dark).

public ColorCollection GenerateShadeColors(int count)

Parameters

count int

The count.

Returns

ColorCollection

ColorCollection.

GenerateSimilarColors(int)

Generates similar colors.

public ColorCollection GenerateSimilarColors(int count)

Parameters

count int

The count.

Returns

ColorCollection

ColorCollection.

GenerateTintColors(int)

Generates tint colors (Light).

public ColorCollection GenerateTintColors(int count)

Parameters

count int

The count.

Returns

ColorCollection

ColorCollection.

GenerateToneColors(int)

Generates tone colors (Medium).

public ColorCollection GenerateToneColors(int count)

Parameters

count int

The count.

Returns

ColorCollection

ColorCollection.

GetAccentColor(int)

Gets the color of the accent.

public Color GetAccentColor(int degrees)

Parameters

degrees int

The 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

percent int

The 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

hex string

The color hex. '#FFFFFF' or 'FFFFFF'

percent int

The percent (1-100).

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()

Returns

string

A string that represents this instance.

To top