Click or drag to resize
Ab4d.SharpEngine logo

Color4 Structure

Represents a color in the form of rgba.
Inheritance Hierarchy
SystemObject
  SystemValueType
    Ab4d.SharpEngine.CommonColor4

Namespace: Ab4d.SharpEngine.Common
Assembly: Ab4d.SharpEngine (in Ab4d.SharpEngine.dll) Version: 1.0.8740+deb2991acfe86a95cca780cd4f82bcae2805c1a5
Syntax
C#
public struct Color4 : IEquatable<Color4>, 
	IFormattable

The Color4 type exposes the following members.

Constructors
 NameDescription
Public methodColor4(Color3) Initializes a new instance of the Color4 struct.
Public methodColor4(Single) Initializes a new instance of the Color4 struct.
Public methodColor4(Single) Initializes a new instance of the Color4 struct.
Public methodColor4(Vector4) Initializes a new instance of the Color4 struct.
Public methodColor4(Color3, Single) Initializes a new instance of the Color4 struct.
Public methodColor4(Int32, Format) Initializes a new instance of the Color4 struct.
Public methodColor4(UInt32, Format) Initializes a new instance of the Color4 struct.
Public methodColor4(Vector3, Single) Initializes a new instance of the Color4 struct.
Public methodColor4(Single, Single, Single, Single) Initializes a new instance of the Color4 struct.
Top
Properties
 NameDescription
Public propertyItem Gets or sets the component at the specified index.
Top
Methods
 NameDescription
Public methodStatic memberAdd(Color4, Color4) Adds two colors.
Public methodStatic memberAdd(Color4, Color4, Color4) Adds two colors.
Public methodStatic memberAdjustContrast(Color4, Single) Adjusts the contrast of a color.
Public methodStatic memberAdjustContrast(Color4, Single, Color4) Adjusts the contrast of a color.
Public methodStatic memberAdjustSaturation(Color4, Single) Adjusts the saturation of a color.
Public methodStatic memberAdjustSaturation(Color4, Single, Color4) Adjusts the saturation of a color.
Public methodStatic memberClamp(Color4, Color4, Color4) Restricts a value to be within a specified range.
Public methodStatic memberClamp(Color4, Color4, Color4, Color4) Restricts a value to be within a specified range.
Public methodDeconstruct Deconstruct Color4 into tuple with red, green, blue and alpha values.
Public methodEquals(Color4) Determines whether the specified Color4 is equal to this instance.
Public methodEquals(Color4) Determines whether the specified Color4 is equal to this instance.
Public methodEquals(Object) Determines whether the specified Object is equal to this instance.
(Overrides ValueTypeEquals(Object))
Public methodStatic memberFromByteRgba Gets Color4 from red, green, blue and alpha values defined as bytes (each value in range from 0 to 255)
Public methodStatic memberFromHsl(Double, Double, Double, Double) Gets Color4 from HSL (hue, saturation, lightness)
Public methodStatic memberFromHsl(Single, Single, Single, Single) Gets Color4 from HSL (hue, saturation, lightness)
Public methodStatic memberFromHsv(Double, Double, Double, Double) Gets Color4 from HSV (hue, saturation, value / brightness)
Public methodStatic memberFromHsv(Single, Single, Single, Single) Gets Color4 from HSV (hue, saturation, value / brightness)
Public methodGetHashCode Returns a hash code for this instance.
(Overrides ValueTypeGetHashCode)
Public methodIsSame Returns true if byte values (each color is in range from 0 to 255) of this color are the same as byte values of the other colors.
Public methodStatic memberLerp(Color4, Color4, Single) Performs a linear interpolation between two colors.
Public methodStatic memberLerp(Color4, Color4, Single, Color4) Performs a linear interpolation between two colors.
Public methodStatic memberMax(Color4, Color4) Returns a color containing the largest components of the specified colors.
Public methodStatic memberMax(Color4, Color4, Color4) Returns a color containing the smallest components of the specified colors.
Public methodStatic memberMin(Color4, Color4) Returns a color containing the smallest components of the specified colors.
Public methodStatic memberMin(Color4, Color4, Color4) Returns a color containing the smallest components of the specified colors.
Public methodStatic memberModulate(Color4, Color4) Modulates two colors.
Public methodStatic memberModulate(Color4, Color4, Color4) Modulates two colors.
Public methodStatic memberNegate(Color4) Negates a color.
Public methodStatic memberNegate(Color4, Color4) Negates a color.
Public methodStatic memberParse Parse method returns the color that was parsed from the color text. If the text cannot be parsed a FormatException is thrown (use TryParse(String, Color4) if you do not want to get an exception). When the color text starts with hash character (#), then the color is specified as a hex value in format RRGGBBAA, RGBA, RRGGBB or RGB (for example #FF0000FF for red color). Otherwise the color text should be one of the color names from the known colors defined in the Colors class. The name can be in any case.
Public methodPremultiply Converts the color values to alpha premultiplied values.
Public methodStatic memberPremultiply(Color4) Computes the premultiplied value of the provided color.
Public methodStatic memberPremultiply(Color4, Color4) Computes the premultiplied value of the provided color.
Public methodSaturate Update the color values to be between 0 and 1.
Public methodStatic memberSaturate(Color4) Restricts color values to be between 0 and 1.
Public methodSaturateAndPremultiply Update the color values to be between 0 and 1 and premultiplies the values by alpha value.
Public methodStatic memberScale(Color4, Single) Scales a color.
Public methodStatic memberScale(Color4, Single, Color4) Scales a color.
Public methodSetAlpha Sets the alpha value of this Color4.
Public methodStatic memberSmoothStep(Color4, Color4, Single) Performs a cubic interpolation between two colors.
Public methodStatic memberSmoothStep(Color4, Color4, Single, Color4) Performs a cubic interpolation between two colors.
Public methodStatic memberSubtract(Color4, Color4) Subtracts two colors.
Public methodStatic memberSubtract(Color4, Color4, Color4) Subtracts two colors.
Public methodToArgb Converts the color into a packed integer.
Public methodToArray Creates an array containing the elements of the color.
Public methodToBgra Converts the color into a packed integer.
Public methodToHexString Returns a string that represents a hex value of this color in format: RRGGBBAA, for example red color is "FF0000FF"
Public methodToKnownColorString If the color is one of the colors in the known Colors class, then the name of the color is returned. Otherwise a hex string with a hash ('#') prefix is returned.
Public methodToRgba Converts the color into a packed integer.
Public methodToString Returns a String that represents this instance.
(Overrides ValueTypeToString)
Public methodToString(IFormatProvider) Returns a String that represents this instance.
Public methodToString(String) Returns a String that represents this instance.
Public methodToString(String, IFormatProvider) Returns a String that represents this instance.
Public methodToVector3 Converts the color into a three component vector.
Public methodToVector4 Converts the color into a four component vector.
Public methodStatic memberTryParse TryParse method tries to parse the color text and set the color out parameter. When the color text starts with hash character (#), then the color is specified as a hex value in format RRGGBBAA, RGBA, RRGGBB or RGB (for example #FF0000FF for red color). Otherwise the color text should be one of the color names from the known colors defined in the Colors class. The name can be in any case. When the color be parse, the color is set to the color out parameter and the method returns true. Otherwise color is set to Black color and the methods returns false.
Top
Operators
 NameDescription
Public operatorStatic memberAddition(Color4, Color4) Adds two colors.
Public operatorStatic memberEquality(Color4, Color4) Tests for equality between two objects.
Public operatorStatic member(Color4 to Int32) Performs an explicit conversion from Color4 to Int32.
Public operatorStatic member(Color4 to Vector3) Performs an explicit conversion from Color4 to Vector3.
Public operatorStatic member(Color4 to UInt32) Performs an explicit conversion from Color4 to UInt32.
Public operatorStatic member(Int32 to Color4) Performs an explicit conversion from Int32 to Color4.
Public operatorStatic member(Vector3 to Color4) Performs an explicit conversion from Vector3 to Color4.
Public operatorStatic member(Vector4 to Color4) Performs an explicit conversion from Vector4 to Color4.
Public operatorStatic member(Color4 to Color3) Performs an explicit conversion from Color4 to Color3.
Public operatorStatic member(Color4 to Vector4) Performs an implicit conversion from Color4 to Vector4.
Public operatorStatic memberInequality(Color4, Color4) Tests for inequality between two objects.
Public operatorStatic memberMultiply(Color4, Color4) Modulates two colors.
Public operatorStatic memberMultiply(Color4, Single) Scales a color.
Public operatorStatic memberMultiply(Single, Color4) Scales a color.
Public operatorStatic memberSubtraction(Color4, Color4) Subtracts two colors.
Public operatorStatic memberUnaryNegation(Color4) Negates a color.
Public operatorStatic memberUnaryPlus(Color4) Assert a color (return it unchanged).
Top
Fields
 NameDescription
Public fieldAlpha The alpha component of the color.
Public fieldStatic memberBlack The Black color (0, 0, 0, 1).
Public fieldBlue The blue component of the color.
Public fieldGreen The green component of the color.
Public fieldRed The red component of the color.
Public fieldStatic memberTransparent The Transparent color with alpha 0 and Red, Green and Blue set to 1.0.
Public fieldStatic memberWhite The White color (1, 1, 1, 1).
Top
Extension Methods
 NameDescription
Public Extension MethodSaturate Ensures that the color components are within 0 and 1 - if smaller than 0 than the value is set to 0; if bigger than 1 the value is set to 1. This is the same as saturate function in HLSL.
(Defined by Extensions)
Public Extension MethodSaturate Ensures that the color components are within 0 and 1 - if smaller than 0 than the value is set to 0; if bigger than 1 the value is set to 1. This is the same as saturate function in HLSL.
(Defined by Extensions)
Public Extension MethodSaturate Ensures that the color components are within 0 and 1 - if smaller than 0 than the value is set to 0; if bigger than 1 the value is set to 1. This is the same as saturate function in HLSL.
(Defined by Extensions)
Public Extension MethodToAvaloniaColor Converts SharpEngine's Color4 to Avalonia color
(Defined by Extensions)
Public Extension MethodToColor3 Converts Color4 to Color3
(Defined by Extensions)
Public Extension MethodToWinUIColor Converts SharpEngine's Color4 to WinUI color
(Defined by Extensions)
Public Extension MethodToWpfColor Converts SharpEngine's Color4 to WPF color
(Defined by Extensions)
Top
See Also