ColorF Structure

Represents a 128-bit linear (not gamma-corrected) color where every color channel is represented by a 32-bit floating point value.

Definition

Namespace: KGySoft.Drawing.Imaging
Assembly: KGySoft.Drawing.Core (in KGySoft.Drawing.Core.dll) Version: 9.0.0
C#
[SerializableAttribute]
public readonly struct ColorF : IEquatable<ColorF>
Inheritance
Object    ValueType    ColorF
Implements
IEquatableColorF

Constructors

ColorF(Color32) Initializes a new instance of the ColorF struct from a Color32 instance.
ColorF(Color64) Initializes a new instance of the ColorF struct from a Color64 instance.
ColorF(Single, Single, Single) Initializes a new instance of the ColorF struct from RGB (red, green, and blue) values. For performance reasons this overload does not validate if the color components are between 0 and 1 but you can use the ColorF(Single, Single, Single, Boolean) constructor or the IsValid property for validation, or the Clip method to return a valid instance.
ColorF(Single, Single, Single, Boolean) Initializes a new instance of the ColorF struct from RGB (red, green, and blue) values.
ColorF(Single, Single, Single, Single) Initializes a new instance of the ColorF struct from ARGB (alpha, red, green, and blue) values. For performance reasons this overload does not validate if the color components are between 0 and 1 but you can use the ColorF(Single, Single, Single, Single, Boolean) constructor or the IsValid property for validation, or the Clip method to return a valid instance.
ColorF(Single, Single, Single, Single, Boolean) Initializes a new instance of the ColorF struct from ARGB (alpha, red, green, and blue) values.

Properties

IsValid Gets whether this ColorF instance represents a valid color. That is, when A, R, G and B fields are all between 0 and 1.

Methods

Clip Returns a valid ColorF instance by clipping the possibly exceeding ARGB values. If IsValid returns , then the result is the same as the original instance.
Equals(ColorF) Determines whether the current ColorF instance is equal to another one.
Equals(Object) Determines whether the specified Object is equal to this ColorF instance.
(Overrides ValueTypeEquals(Object))
FromArgb Creates a ColorF instance from the specified ColorF structure, but with the new specified alpha value. This method does not validate if the color components are between 0 and 1 but you can use the the IsValid property or the Clip method on the result.
FromGray Creates a ColorF structure representing a grayscale color of the specified brightness.
FromRgb Creates a ColorF structure from a Vector3 instance mapping X to R, Y to G and Z to B. The A component of the result will be 1.
FromRgba Creates a ColorF structure from a Vector4 instance mapping X to R, Y to G, Z to B and W to A.
GetHashCode Returns a hash code for this instance.
(Overrides ValueTypeGetHashCode)
ToColor32 Converts this ColorF instance to a Color32 structure.
ToColor64 Converts this ColorF instance to a Color64 structure.
ToGray Gets a ColorF instance that represents the matching gray shade of this ColorF instance based on human perception.
ToOpaque Gets a ColorF instance that represents this ColorF without alpha (transparency).
ToRgb Converts this ColorF instance to a Vector3 structure mapping R to X, G to Y and B to Z.
ToRgba Converts this ColorF instance to a Vector4 structure mapping R to X, G to Y, B to Z and A to W.
ToString Gets the string representation of this ColorF instance.
(Overrides ValueTypeToString)

Operators

Addition(ColorF, ColorF) Adds two colors together.
Addition(ColorF, Single) Adds a given scalar to a ColorF.
Division(ColorF, Single) Divides a ColorF by the given scalar.
Equality(ColorF, ColorF) Gets whether two ColorF structures are equal.
Inequality(ColorF, ColorF) Gets whether two ColorF structures are different.
Multiply(ColorF, Single) Multiplies a ColorF by the given scalar.
Subtraction(ColorF, ColorF) Subtracts the second color from the first one.
Subtraction(ColorF, Single) Subtracts a given scalar from the first color.

Fields

A Gets the alpha component value of this ColorF structure. This field is read-only.
B Gets the blue component value of this ColorF structure. This field is read-only.
G Gets the green component value of this ColorF structure. This field is read-only.
R Gets the red component value of this ColorF structure. This field is read-only.

Extension Methods

Blend Blends the specified foreColor and backColor in the linear color space. It returns foreColor if it has no transparency (that is, when A is greater than or equal to 1); otherwise, the result of the blending.
(Defined by ColorExtensions)
Blend Blends the specified foreColor and backColor in the specified colorSpace. It returns foreColor if it has no transparency (that is, when A is greater than or equal to 1); otherwise, the result of the blending.
(Defined by ColorExtensions)
GetBrightness Gets the brightness of a ColorF instance as a float value in the linear color space. The A component of the specified value is ignored.
(Defined by ColorExtensions)
GetBrightness Gets the brightness of a ColorF instance as a float value in the linear color space. The A component of the specified value is ignored.
(Defined by ColorExtensions)
ToColor Converts this ColorF to a Color instance.
(Defined by ColorExtensions)
ToColor Converts this ColorF to a Color instance.
(Defined by ColorExtensions)
ToColor32 Converts this ColorF to a Color32 instance.
(Defined by ColorExtensions)
ToColor64 Converts this ColorF to a Color64 instance.
(Defined by ColorExtensions)
TolerantEquals Gets whether two ColorF instances are equal using a specified tolerance.
(Defined by ColorExtensions)
ToMediaColor Converts a ColorF struct to System.Windows.Media.Color.
(Defined by ColorExtensions)
ToPColor32 Converts this ColorF to a PColor32 instance.
(Defined by ColorExtensions)
ToPColor32 Converts this ColorF to a PColor32 instance.
(Defined by ColorExtensions)
ToPColor64 Converts this ColorF to a PColor64 instance.
(Defined by ColorExtensions)
ToPColor64 Converts this ColorF to a PColor64 instance.
(Defined by ColorExtensions)
ToPColorF Converts this ColorF to a PColorF instance. It's practically the same as calling the ToPremultiplied(ColorF) method.
(Defined by ColorExtensions)
ToPremultiplied Converts this straight ColorF value to a premultiplied PColorF value. It's practically the same as calling the ToPColorF(ColorF) method.
(Defined by ColorExtensions)
ToSKColor Converts a ColorF struct to SKColor.
(Defined by ColorExtensions)
ToSKColorF Converts a ColorF struct to SKColorF.
(Defined by ColorExtensions)
ToSKPMColor Converts a ColorF struct to SKPMColor.
(Defined by ColorExtensions)
ToWindowsColor Converts a ColorF struct to Windows.UI.Color.
(Defined by ColorExtensions)

See Also