Class Extensions
- Namespace
- OFT.Rendering
- Assembly
- OFT.Rendering.dll
Helper extension methods of the rendering library: value comparison, stopwatch tick conversion and color helpers.
public static class Extensions
- Inheritance
-
objectExtensions
Methods
Compare(RenderAdjustableArrowCap?, RenderAdjustableArrowCap?)
Compares two arrow caps by width and height; two null values are equal.
Added in ATAS 8.0.15.
public static bool Compare(this RenderAdjustableArrowCap? first, RenderAdjustableArrowCap? second)
Parameters
firstRenderAdjustableArrowCapFirst cap, can be null.
secondRenderAdjustableArrowCapSecond cap, can be null.
Returns
Compare(double, double)
Compares two values. The tolerance is double.Epsilon, so in practice only equal values match.
public static bool Compare(this double first, double second)
Parameters
firstdoubleFirst value.
seconddoubleSecond value.
Returns
- bool
true when the values are equal.
Compare(float, float)
Compares two values. The tolerance is float.Epsilon, so in practice only equal values match.
public static bool Compare(this float first, float second)
Parameters
firstfloatFirst value.
secondfloatSecond value.
Returns
- bool
true when the values are equal.
Compare(float[]?, float[]?)
Compares two arrays element by element with Compare(float, float); two null arrays are equal.
Added in ATAS 8.0.15.
public static bool Compare(this float[]? first, float[]? second)
Parameters
Returns
ConvertTicksToMSec(long)
Converts System.Diagnostics.Stopwatch ticks to whole milliseconds (truncated).
public static long ConvertTicksToMSec(this long value)
Parameters
valuelongElapsed System.Diagnostics.Stopwatch ticks.
Returns
- long
The elapsed time in milliseconds.
ConvertTicksToSec(long)
Converts System.Diagnostics.Stopwatch ticks to seconds.
public static double ConvertTicksToSec(this long value)
Parameters
valuelongElapsed System.Diagnostics.Stopwatch ticks.
Returns
- double
The elapsed time in seconds.
GetContrastingColor(Color)
Specifies a color (black or white) for better readability on a given background.
public static Color GetContrastingColor(this Color backgroundColor)
Parameters
backgroundColorColorBackground color.
Returns
- Color
The resulting color (black or white).
GetContrastingColor(Color, Color)
Specifies a color (black or white) for better readability on a semi-transparent foreground drawn over an opaque background.
Not in ATAS 8.0.15 yet: available from the next version.
public static Color GetContrastingColor(this Color foreground, Color background)
Parameters
foregroundColorForeground color, may be semi-transparent.
backgroundColorBackground color the foreground is drawn over.
Returns
- Color
The resulting color (black or white).
SetTransparency(Color, decimal)
Returns color with the alpha channel set from a transparency level; the original alpha is ignored.
public static Color SetTransparency(this Color color, decimal transparencyLevel)
Parameters
colorColorSource color.
transparencyLeveldecimalTransparency from 0 (opaque) to 1 (fully transparent); values outside the range are clamped.
Returns
- Color
The color with the new alpha channel.
ToTextRenderingHint(RenderTextRenderingHint)
Converts a text anti-aliasing mode to the GDI+ text rendering hint:
Aliased becomes SingleBitPerPixelGridFit, any other value AntiAlias.
public static TextRenderingHint ToTextRenderingHint(this RenderTextRenderingHint textRenderingHint)
Parameters
textRenderingHintRenderTextRenderingHintMode to convert.
Returns
- TextRenderingHint
The GDI+ text rendering hint.