ColourExtensionMethods
Extension methods for Eto.Drawing.Colour
Methods
Add two colours.
public static Color Add()
this Color
colour,
Base colour.
Color
overlay
Overlay colour.
Returns: Added colour.
There are four categories of special colour (Analysis, input, output, symbolic) which have four brighnesses in them (XxxxDark, Xxxx, XxxxLight, XxxxShine). This method will change those brightnesses depending on a level adjustment.
Clip the channels of a colour to the 0~1 range.
public static Color Clip()
this Color
colour
Colour to clip.
Returns: Clipped colour.
Create a new colour which acts as the composite of a background and a foreground colour.
public static Color Composite()
this Color
bottom,
Bottom colour.
Color
top
Top colour.
Returns: Composited colour.
Create a contrasting colour useful for foreground/background distinction. Contrast colours retain hue but will change luminance.
public static Color Contrast()
Returns: Associated contrast colour.
Decrease the luminance of a colour.
Returns: Darkened colour.
Desaturate a colour by moving its channels to greyscale values.
public static Color Desaturate()
this Color
colour,
Colour to desaturate.
amount,
Desaturation amount. 0=original colour, 1=pure grey.
Metric to use.
Fade a colour to transparency.
Returns: Faded colour.
Return a gamma-reverted version of this colour. By reverting the gamma, a gamma-adjusted colour is restored into standard sRGB space.
Returns: Gamma reverted version.
Gets the hue component (0~360) of a colour.
Compute the luminance of a colour.
Returns: Luminance of colour (0.0 to 1.0)
Compute the perceived luminance of a colour using non-linear HSP weighting.
Returns: Luminance of colour (0.0 to 1.0)
Gets the saturation component (0~1) of a colour, as defined by the HSB colour model.
Create a negative colour. The alpha channel is not inverted.
public static Color Invert()
this Color
colour,
Base colour.
maintainLuminance
If true, the inversion happens in HSL space, rather than RGB space.
Returns: Negative colour.
Determines whether a colour qualifies as a dark one, meaning that it requires foreground objects to be of a bright colour.
Increase the luminance of a colour.
Returns: Lightened colour.
Create colour in between this colour and some target colour.
Returns: Moved colour.
Multiply two colours. This has the effect of looking at the bottom colour through a piece of coloured glass.
public static Color Multiply()
this Color
colour,
Base colour.
Color
overlay
Overlay colour.
Returns: Multiplied colour.
Multiply a colour.
Returns: Multiplied colour.
Multiply two colours in LinearRGB. This has the effect of looking at the bottom colour through a piece of coloured glass.
public static Color MultiplyLinear()
this Color
colour,
Base colour.
Color
overlay
Overlay colour.
Returns: Multiplied colour.
Add a fixed value to all the channels in a colour.
public static Color Offset()
Returns: Offsetted colour.
Add a fixed value to all the channels in a colour.
Returns: Offsetted colour.
Gets the pair of colours associated with the given process state.
public static (Color back, Color fore) Palette()
this ProcessState
state
Pick a colour out of a palette which is the furthest away from other colours.
public static Color PickLeastAlike()
Returns: Colour in 'palette' which is the least like any colour in 'colours'.
Resolve a colour based on some context.
public static Color Resolve()
this SpecialColour
colour,
Colour to resolve.
Color
background,
Background. If fully transparent, the OS control background will be substituted.
palette = null
Palette for resolving user-settable colours. If omitted, the standard Grasshopper palette will be substituted.
Mapping function from colours to the gamma adjusted (exponent = 2.4) RGB cube.
Mapping function from colours to the gamma adjusted (exponent = 2.0) RGB cube.
Mapping function from colours to the sRGB cube.
Mapping function from colours to the HSL cylinder.
Mapping function from colours to the HSP* (perceived luminance) cylinder.
Mapping function from colours to the HSV cylinder.
Mapping function from colours to the Hsl sinusoidal space.
The projection space is a vertical half sine-wave revolved around the world Z axis. Bottom tip (black) resides at (0,0,-1) while the upper tip (white) can be found at (0,0,+1). The central axis from black to white contains all the greyscale values. Luminance is gamma adjusted and mapped along the vertical axis, hue is mapped around the vertical axis and saturation is mapped to an offset from the vertical axis. The offset is the product of the normalised saturation and the sine of the gamma-adjusted luminance.
Round a colour to 1/1000th accuracy in each channel.
public static Color Round()
this Color
colour
Colour to round.
Returns: Rounded colour.
Set the luminance of a colour. This method uses HSV luminance metric.
public static Color SetBrightness()
Returns: Modified colour.
Set the hue of a colour.
Returns: Modified colour.
Set the luminance of a colour. This method uses a custom metric and an iterative process.
public static Color SetLuminance()
this Color
colour,
Colour to modify.
luminance,
New luminance (0.0~1.0 range).
metric
specific metric to use.
Returns: Modified colour.
Set the luminance of a colour.
public static ColorHSL SetLuminance()
this ColorHSL
colour,
Colour to modify.
luminance,
New luminance (0.0~1.0 range).
metric
specific metric to use.
Returns: Modified colour.
Set the saturation of a colour. This method uses HSV saturation metric.
public static Color SetSaturation()
Returns: Modified colour.
Sinusoidal_Rgb
#Perform a reverse mapping from sinusoidal coordinates into sRGB coordinates. This conversion may be lossy if the coordinates reside outside the sinusoidal revolved volume.
Create a bitmap filled with this colour.
Returns: Single colour bitmap.
Convert a GDI+ colour into an Eto colour.
public static Color ToEto()
this Color
color
Color to convert.
Returns: Eto colour.
Gets the actual ARGB colour which hints at a special colour.
Convert an eto colour into a GDI colour.
public static Color ToGdi()
this Color
color
Color to convert.
Returns: Gdi colour.
Return the name of the colour space without any whitespace or funky characters
Return the name of the colour space without any whitespace or funky characters
Return the official name of a colour space including funky characters and whitespace.
Return the official name of a colour space including funky characters and whitespace.
Convert a colour so it will be displayed correctly in the UI. This involves optionally removing all alpha data as well as resolving special colours to their stand-in shades.
public static Color ToUiColour()
Returns: Colour suitable for display in the UI.
Try to find the named colour in Eto.Drawing.Colors which matches this colour. The pure name is returned, without the 'Eto' or the 'Drawing' or the 'Colors'. This method is fairly slow.
Returns: True if a name was found.
Test whether a colour is one of the special colour codes.
Returns: Special colour identifier if any.
Gets a stand-in colour for the given special colour.
Gets a description suitable for use in the UI for a given special colour.
Gets a name suitable for use in the UI for a given special colour.
Return a gamma-adjusted version of this colour. By adjusting the gamma, the colour is moved into a space where linear blending is more natural.
Returns: Gamma adjusted version.