Class XMColor
The color functions provided by DirectXMath.
Inherited Members
Namespace: JeremyAnsel.DirectX.DXMath
Assembly: JeremyAnsel.DirectX.DXMath.dll
Syntax
public static class XMColor
Methods
| Edit this page View SourceAdjustContrast(XMVector, float)
Adjusts the contrast value of a color.
Declaration
public static XMVector AdjustContrast(XMVector color, float contrast)
Parameters
Type | Name | Description |
---|---|---|
XMVector | color | The color. Each of the components of C should be in the range 0.0f to 1.0f. |
float | contrast | Contrast value. This parameter linearly interpolates between 50 percent gray and the color C. If this parameter is 0.0f, the returned color is 50 percent gray. If this parameter is 1.0f, the returned color is the original color. |
Returns
Type | Description |
---|---|
XMVector | The color resulting from the contrast adjustment. |
AdjustSaturation(XMVector, float)
Adjusts the saturation value of a color.
Declaration
public static XMVector AdjustSaturation(XMVector color, float saturation)
Parameters
Type | Name | Description |
---|---|---|
XMVector | color | The color. Each of the components of C should be in the range 0.0f to 1.0f. |
float | saturation | Saturation value. This parameter linearly interpolates between the color converted to gray-scale and the original color, C. If Saturation is 0.0f, the function returns the gray-scale color. If Saturation is 1.0f, the function returns the original color. |
Returns
Type | Description |
---|---|
XMVector | The color resulting from the saturation adjustment. |
Equal(XMVector, XMVector)
Tests for the equality of two colors.
Declaration
public static bool Equal(XMVector c1, XMVector c2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | c1 | The first color to compare. |
XMVector | c2 | The second color to compare. |
Returns
Type | Description |
---|---|
bool | Returns true if each of the components of the two colors are equal, or false otherwise. |
Greater(XMVector, XMVector)
Tests whether all the components of the first color are greater than the corresponding components in the second color.
Declaration
public static bool Greater(XMVector c1, XMVector c2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | c1 | The first color to compare. |
XMVector | c2 | The second color to compare. |
Returns
Type | Description |
---|---|
bool | Returns true if every component of C1 is greater than the corresponding component in C2. Returns false otherwise. |
GreaterOrEqual(XMVector, XMVector)
Tests whether all the components of the first color are greater than or equal to the corresponding components of the second color.
Declaration
public static bool GreaterOrEqual(XMVector c1, XMVector c2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | c1 | The first color to compare. |
XMVector | c2 | The second color to compare. |
Returns
Type | Description |
---|---|
bool | Returns true if every component of C1 is greater than or equal to the corresponding component in C2. Returns false otherwise. |
HslToRgb(XMVector)
Converts HSL color values to RGB color values.
Declaration
public static XMVector HslToRgb(XMVector hsl)
Parameters
Type | Name | Description |
---|---|---|
XMVector | hsl | Color value to convert. The X element is Hue (H), the Y element is Saturation (S), the Z element is Luminance (L), and the W element is Alpha. Each has a range of 0.0 to 1.0. |
Returns
Type | Description |
---|---|
XMVector | The converted color value. X element is Red, Y element is Green, Z element is Blue, and W element is Alpha (a copy of |
HsvToRgb(XMVector)
Converts HSV color values to RGB color values.
Declaration
public static XMVector HsvToRgb(XMVector hsv)
Parameters
Type | Name | Description |
---|---|---|
XMVector | hsv | Color value to convert. The X element is Hue (H), the Y element is Saturation (S), the Z element is Value (V), and the W element is Alpha. Each has a range of 0.0 to 1.0. |
Returns
Type | Description |
---|---|
XMVector | The converted color value. X element is Red, Y element is Green, Z element is Blue, and W element is Alpha (a copy of |
IsInfinite(XMVector)
Tests to see whether any of the components of a color are either positive or negative infinity.
Declaration
public static bool IsInfinite(XMVector c)
Parameters
Type | Name | Description |
---|---|---|
XMVector | c | The color. |
Returns
Type | Description |
---|---|
bool | Returns true if any components of C are either positive or negative infinity. Returns false otherwise. |
IsNaN(XMVector)
Tests to see whether any component of a color is not a number (NaN).
Declaration
public static bool IsNaN(XMVector c)
Parameters
Type | Name | Description |
---|---|---|
XMVector | c | The color. |
Returns
Type | Description |
---|---|
bool | Returns true if any components of C are NaN, or false otherwise. |
Less(XMVector, XMVector)
Tests whether all the components of the first color are less than the corresponding components of the second color.
Declaration
public static bool Less(XMVector c1, XMVector c2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | c1 | The first color to compare. |
XMVector | c2 | The second color to compare. |
Returns
Type | Description |
---|---|
bool | Returns true if every component of C1 is less than the corresponding component in C2. Returns false otherwise. |
LessOrEqual(XMVector, XMVector)
Tests whether all the components of the first color are less than or equal to the corresponding components of the second color.
Declaration
public static bool LessOrEqual(XMVector c1, XMVector c2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | c1 | The first color to compare. |
XMVector | c2 | The second color to compare. |
Returns
Type | Description |
---|---|
bool | Returns true if every component of C1 is less than or equal to the corresponding component in C2. Returns false otherwise. |
Modulate(XMVector, XMVector)
Blends two colors by multiplying corresponding components together.
Declaration
public static XMVector Modulate(XMVector c1, XMVector c2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | c1 | The first color. |
XMVector | c2 | The second color. |
Returns
Type | Description |
---|---|
XMVector | The color resulting from the modulation. |
Negative(XMVector)
Determines the negative RGB color value of a color.
Declaration
public static XMVector Negative(XMVector c)
Parameters
Type | Name | Description |
---|---|---|
XMVector | c | The color. Each of the components of C should be in the range 0.0f to 1.0f. |
Returns
Type | Description |
---|---|
XMVector | The negative color. The w-component (alpha) is copied unmodified from the input vector. |
NotEqual(XMVector, XMVector)
Tests to see whether two colors are unequal.
Declaration
public static bool NotEqual(XMVector c1, XMVector c2)
Parameters
Type | Name | Description |
---|---|---|
XMVector | c1 | The first color to compare. |
XMVector | c2 | The second color to compare. |
Returns
Type | Description |
---|---|
bool | Returns true if any component of C1 is different from the corresponding component of C2. Returns false otherwise. |
RgbToHsl(XMVector)
Converts RGB color values to HSL color values.
Declaration
public static XMVector RgbToHsl(XMVector rgb)
Parameters
Type | Name | Description |
---|---|---|
XMVector | rgb | Color value to convert. X element is Red, Y element is Green, Z element is Blue, and W element is Alpha. Each has a range of 0.0 to 1.0. |
Returns
Type | Description |
---|---|
XMVector | The converted color value. The X element is Hue (H), the Y element is Saturation (S), the Z element is Luminance (L), and the W element is Alpha (a copy of the input's Alpha value). Each has a range of 0.0 to 1.0. |
RgbToHsv(XMVector)
Converts RGB color values to HSV color values.
Declaration
public static XMVector RgbToHsv(XMVector rgb)
Parameters
Type | Name | Description |
---|---|---|
XMVector | rgb | Color value to convert. X element is Red, Y element is Green, Z element is Blue, and W element is Alpha. Each has a range of 0.0 to 1.0. |
Returns
Type | Description |
---|---|
XMVector | The converted color value. The X element is Hue (H), the Y element is Saturation (S), the Z element is Value (V), and the W element is Alpha (a copy of |
RgbToSrgb(XMVector)
Converts an RGB color vector to sRGB.
Declaration
public static XMVector RgbToSrgb(XMVector rgb)
Parameters
Type | Name | Description |
---|---|---|
XMVector | rgb | The original RGB color vector. |
Returns
Type | Description |
---|---|
XMVector | The converted sRGBA color vector. The x element is red, the y element is green, the z element is blue, and the w element is the alpha value (which is a copy of |
RgbToXyz(XMVector)
Converts RGB color values to XYZ color values.
Declaration
public static XMVector RgbToXyz(XMVector rgb)
Parameters
Type | Name | Description |
---|---|---|
XMVector | rgb | Color value to convert. X element is Red, Y element is Green, Z element is Blue, and W element is Alpha. Each has a range of 0.0 to 1.0. |
Returns
Type | Description |
---|---|
XMVector | The converted color value with the trisimulus values of X, Y, and Z in the corresponding element, and the W element with Alpha (a copy of |
RgbToYuv(XMVector)
Converts RGB color values to YUV color values.
Declaration
public static XMVector RgbToYuv(XMVector rgb)
Parameters
Type | Name | Description |
---|---|---|
XMVector | rgb | Color value to convert. X element is Red, Y element is Green, Z element is Blue, and W element is Alpha. Each has a range of 0.0 to 1.0. |
Returns
Type | Description |
---|---|
XMVector | The converted color value in Luma-Chrominance (YUV) aka YCbCr. The X element contains Luma (Y, 0.0 to 1.0), the Y element contains Blue-difference chroma (-0.5 to 0.5), the Z element contains the Red-difference chroma (-0.5 to 0.5), and the W element contains the Alpha (a copy of |
RgbToYuvHD(XMVector)
Converts RGB color values to YUV HD color values.
Declaration
public static XMVector RgbToYuvHD(XMVector rgb)
Parameters
Type | Name | Description |
---|---|---|
XMVector | rgb | Color value to convert. X element is Red, Y element is Green, Z element is Blue, and W element is Alpha. Each has a range of 0.0 to 1.0. |
Returns
Type | Description |
---|---|
XMVector | The converted color value in Luma-Chrominance (YUV) aka YCbCr. The X element contains Luma (Y, 0.0 to 1.0), the Y element contains Blue-difference chroma (-0.5 to 0.5), the Z element contains the Red-difference chroma (-0.5 to 0.5), and the W element contains the Alpha (a copy of |
SrgbToRgb(XMVector)
Converts an sRGB color vector to RGB.
Declaration
public static XMVector SrgbToRgb(XMVector srgb)
Parameters
Type | Name | Description |
---|---|---|
XMVector | srgb | An sRGB color vector. |
Returns
Type | Description |
---|---|
XMVector | The converted RGBA color vector. The x element is red, the y element is green, the z element is blue, and the w element is the alpha value (which is a copy of |
SrgbToXyz(XMVector)
Converts SRGB color values to XYZ color values.
Declaration
public static XMVector SrgbToXyz(XMVector srgb)
Parameters
Type | Name | Description |
---|---|---|
XMVector | srgb | Color value to convert. X element is Red, Y element is Green, Z element is Blue, and W element is Alpha. Each has a range of 0.0 to 1.0 and is in the linear sRGB colorspace. |
Returns
Type | Description |
---|---|
XMVector | The converted color value with the trisimulus values of X, Y, and Z in the corresponding element, and the W element with Alpha (a copy of |
XyzToRgb(XMVector)
Converts XYZ color values to RGB color values.
Declaration
public static XMVector XyzToRgb(XMVector xyz)
Parameters
Type | Name | Description |
---|---|---|
XMVector | xyz | Color value to convert with the trisimulus values of X, Y, and Z in the corresponding element, and the W element with Alpha. Each has a range of 0.0 to 1.0. |
Returns
Type | Description |
---|---|
XMVector | The converted color value. X element is Red, Y element is Green, Z element is Blue, and W element is Alpha (a copy of |
XyzToSrgb(XMVector)
Converts XYZ color values to SRGB color values.
Declaration
public static XMVector XyzToSrgb(XMVector xyz)
Parameters
Type | Name | Description |
---|---|---|
XMVector | xyz | Color value to convert with the trisimulus values of X, Y, and Z in the corresponding element, and the W element with Alpha. Each has a range of 0.0 to 1.0. |
Returns
Type | Description |
---|---|
XMVector | The converted color value. X element is Red, Y element is Green, Z element is Blue, and W element is Alpha (a copy of |
YuvToRgb(XMVector)
Converts YUV color values to RGB color values.
Declaration
public static XMVector YuvToRgb(XMVector yuv)
Parameters
Type | Name | Description |
---|---|---|
XMVector | yuv | Color value to convert in Luma-Chrominance (YUV) aka |
Returns
Type | Description |
---|---|
XMVector | The converted color value. X element is Red, Y element is Green, Z element is Blue, and W element is Alpha (a copy of |
YuvToRgbHD(XMVector)
Converts YUV color values to RGB HD color values.
Declaration
public static XMVector YuvToRgbHD(XMVector yuv)
Parameters
Type | Name | Description |
---|---|---|
XMVector | yuv | Color value to convert in Luma-Chrominance (YUV) aka |
Returns
Type | Description |
---|---|
XMVector | The converted color value. X element is Red, Y element is Green, Z element is Blue, and W element is Alpha (a copy of |