Class ContrastTests
Get ContrastDisplay objects containing results for each contrast test, given a foreground color and a background color.
Inheritance
Inherited Members
Namespace: Phoenix.Tiresias
Assembly: Phoenix.Plugin.Tiresias.dll
Syntax
public class ContrastTests
Fields
View SourceColorBrightnessDiffThreshold
Contrast testing threshold for color brightness.
Declaration
public const double ColorBrightnessDiffThreshold = 125
Field Value
Type | Description |
---|---|
System.Double |
ColorDiffThreshold
Contrast testing threshold for color difference.
Declaration
public const double ColorDiffThreshold = 500
Field Value
Type | Description |
---|---|
System.Double |
Fail
Failing result.
Declaration
public const string Fail = "Fail"
Field Value
Type | Description |
---|---|
System.String |
HighContrastTextThreshold
Contrast testing threshold for high contrast text.
Declaration
public const double HighContrastTextThreshold = 7
Field Value
Type | Description |
---|---|
System.Double |
NonTextThreshold
Contrast testing threshold for non text.
Declaration
public const double NonTextThreshold = 3
Field Value
Type | Description |
---|---|
System.Double |
NotApplicable
N/A result.
Declaration
public const string NotApplicable = "n/a"
Field Value
Type | Description |
---|---|
System.String |
Pass
Passing result.
Declaration
public const string Pass = "Pass!"
Field Value
Type | Description |
---|---|
System.String |
TargetLargeTextThreshold
Contrast testing threshold for large text.
Declaration
public const double TargetLargeTextThreshold = 3
Field Value
Type | Description |
---|---|
System.Double |
Properties
View SourceColorBrightnessNum
Gets or sets the color brightness number.
Declaration
public double ColorBrightnessNum { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
ColorDifferenceNum
Gets or sets the color difference number.
Declaration
public double ColorDifferenceNum { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
ContrastRatioNum
Gets or sets the contrast ratio number.
Declaration
public double ContrastRatioNum { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
DeutContrastRatioNum
Gets or sets the deuteranopia contrast ratio number.
Declaration
public double DeutContrastRatioNum { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
DeutLargeText
Gets or sets the ContrastDisplay object containing the test for deuteranopia large text.
Declaration
public ContrastDisplay DeutLargeText { get; set; }
Property Value
Type | Description |
---|---|
ContrastDisplay |
DeutNonText
Gets or sets the ContrastDisplay object containing the test for deuteranopia non-text.
Declaration
public ContrastDisplay DeutNonText { get; set; }
Property Value
Type | Description |
---|---|
ContrastDisplay |
DeutText
Gets or sets the ContrastDisplay object containing the test for deuteranopia text.
Declaration
public ContrastDisplay DeutText { get; set; }
Property Value
Type | Description |
---|---|
ContrastDisplay |
LargeTextHighContrast
Gets or sets the ContrastDisplay object containing the test for the large text high contrast.
Declaration
public ContrastDisplay LargeTextHighContrast { get; set; }
Property Value
Type | Description |
---|---|
ContrastDisplay |
LargeTextTargetContrast
Gets or sets the ContrastDisplay object containing the test for the large text target contrast.
Declaration
public ContrastDisplay LargeTextTargetContrast { get; set; }
Property Value
Type | Description |
---|---|
ContrastDisplay |
MonoContrastRatioNum
Gets or sets the monochromacy contrast ratio number.
Declaration
public double MonoContrastRatioNum { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
MonoLargeText
Gets or sets the ContrastDisplay object containing the test for monochromacy large text.
Declaration
public ContrastDisplay MonoLargeText { get; set; }
Property Value
Type | Description |
---|---|
ContrastDisplay |
MonoNonText
Gets or sets the ContrastDisplay object containing the test for monochromacy non-text.
Declaration
public ContrastDisplay MonoNonText { get; set; }
Property Value
Type | Description |
---|---|
ContrastDisplay |
MonoText
Gets or sets the ContrastDisplay object containing the test for monochromacy text.
Declaration
public ContrastDisplay MonoText { get; set; }
Property Value
Type | Description |
---|---|
ContrastDisplay |
NonTextTargetContrast
Gets or sets the ContrastDisplay object containing the test for non-text.
Declaration
public ContrastDisplay NonTextTargetContrast { get; set; }
Property Value
Type | Description |
---|---|
ContrastDisplay |
ProtContrastRatioNum
Gets or sets the protanopia contrast ratio number.
Declaration
public double ProtContrastRatioNum { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
ProtLargeText
Gets or sets the ContrastDisplay object containing the test for protanopia large text.
Declaration
public ContrastDisplay ProtLargeText { get; set; }
Property Value
Type | Description |
---|---|
ContrastDisplay |
ProtNonText
Gets or sets the ContrastDisplay object containing the test for protanopia non-text.
Declaration
public ContrastDisplay ProtNonText { get; set; }
Property Value
Type | Description |
---|---|
ContrastDisplay |
ProtText
Gets or sets the ContrastDisplay object containing the test for protanopia text.
Declaration
public ContrastDisplay ProtText { get; set; }
Property Value
Type | Description |
---|---|
ContrastDisplay |
TargetTextThreshold
Gets or sets the contrast testing threshold for text.
Declaration
public static double? TargetTextThreshold { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Double> |
TextHighContrast
Gets or sets the ContrastDisplay object containing the test for the high contrast.
Declaration
public ContrastDisplay TextHighContrast { get; set; }
Property Value
Type | Description |
---|---|
ContrastDisplay |
TextTargetContrast
Gets or sets the ContrastDisplay object containing the test for the target contrast.
Declaration
public ContrastDisplay TextTargetContrast { get; set; }
Property Value
Type | Description |
---|---|
ContrastDisplay |
TritContrastRatioNum
Gets or sets the tritanopia contrast ratio number.
Declaration
public double TritContrastRatioNum { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
TritLargeText
Gets or sets the ContrastDisplay object containing the test for tritanopia large text.
Declaration
public ContrastDisplay TritLargeText { get; set; }
Property Value
Type | Description |
---|---|
ContrastDisplay |
TritNonText
Gets or sets the ContrastDisplay object containing the test for tritanopia non-text.
Declaration
public ContrastDisplay TritNonText { get; set; }
Property Value
Type | Description |
---|---|
ContrastDisplay |
TritText
Gets or sets the ContrastDisplay object containing the test for tritanopia text.
Declaration
public ContrastDisplay TritText { get; set; }
Property Value
Type | Description |
---|---|
ContrastDisplay |
Methods
View SourceCheckColorBrightness(Color, Color)
Runs Color Brightness algorithm and determines if difference passes WCAG 2.0 guidelines.
Declaration
public void CheckColorBrightness(Color foregroundColor, Color backgroundColor)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Color | foregroundColor | The foreground color selected as part of the worst contrast pair for the line of text. |
System.Drawing.Color | backgroundColor | The background color selected as part of the worst contrast pair for the line of text. |
CheckColorDifferenceTest(Color, Color)
Runs Color Difference algorithm and determines if difference passes WCAG 2.0 guidelines.
Declaration
public void CheckColorDifferenceTest(Color foregroundColor, Color backgroundColor)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Color | foregroundColor | The foreground color selected as part of the worst contrast pair for the line of text. |
System.Drawing.Color | backgroundColor | The background color selected as part of the worst contrast pair for the line of text. |
CheckLuminanceTest(Color, Color)
Checks whether or not the selected colors pass the selected algorithm test.
Declaration
public void CheckLuminanceTest(Color foregroundColor, Color backgroundColor)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Color | foregroundColor | The foreground color selected as part of the worst contrast pair for the line of text. |
System.Drawing.Color | backgroundColor | The background color selected as part of the worst contrast pair for the line of text. |
ContrastRatio(Color, Color)
Returns the contrast ratio. Can range from 1 - 21 (commonly written as 1:1 to 21:1) https://www.w3.org/TR/WCAG20/#contrast-ratiodef.
Declaration
public static double ContrastRatio(Color fore, Color back)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Color | fore | Foreground color. |
System.Drawing.Color | back | Background color. |
Returns
Type | Description |
---|---|
System.Double | contrast ratio of 2 colors. |
MakePixelDeuteranopia(Color)
Called to apply the deuteranopia filter to a single pixel color.
Declaration
public static Color MakePixelDeuteranopia(Color color)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Color | color | A color represented in RGB. |
Returns
Type | Description |
---|---|
System.Drawing.Color | Color of filtered color. |
MakePixelGrayscale(Color)
Returns Color type filled with gray value of colorful Color type.
Declaration
public static Color MakePixelGrayscale(Color pixel)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Color | pixel | Single unfiltered pixel. |
Returns
Type | Description |
---|---|
System.Drawing.Color | Single grayscale pixel. |
MakePixelProtanopia(Color)
Called to apply the protanopia filter to a single pixel color.
Declaration
public static Color MakePixelProtanopia(Color color)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Color | color | A color represented in RGB. |
Returns
Type | Description |
---|---|
System.Drawing.Color | Color of filtered color. |
MakePixelTritanopia(Color)
Called to apply the tritanopia filter to a single pixel color.
Declaration
public static Color MakePixelTritanopia(Color color)
Parameters
Type | Name | Description |
---|---|---|
System.Drawing.Color | color | A color represented in RGB. |
Returns
Type | Description |
---|---|
System.Drawing.Color | Color of filtered color. |