System.UITypes.TAlphaColorF

From Appmethod Libraries
Jump to: navigation, search

Object Pascal

  TAlphaColorF = record
  public const
    Epsilon = 1.5259E-05; // 1 / 65535, minimal value for TPixelFormat.RGBA16 components
  private
    class function SameComponent(const Value1, Value2: Single): Boolean; static; inline;
    class function ClampComponent(const Value: Single): Single; static; inline;
  public
    R, G, B, A: Single;
    class function Create(const R, G, B: Single; const A: Single = 1): TAlphaColorF; overload; static; inline;
    class function Create(const Color: TAlphaColor): TAlphaColorF; overload; static; inline;
    class operator Add(const Color1, Color2: TAlphaColorF): TAlphaColorF;
    class operator Subtract(const Color1, Color2: TAlphaColorF): TAlphaColorF;
    class operator Equal(const Color1, Color2: TAlphaColorF): Boolean;
    class operator NotEqual(const Color1, Color2: TAlphaColorF): Boolean;
    class operator Negative(const Color: TAlphaColorF): TAlphaColorF;
    class operator Multiply(const Color1, Color2: TAlphaColorF): TAlphaColorF;
    class operator Multiply(const Color: TAlphaColorF; const Factor: Single): TAlphaColorF;
    class operator Multiply(const Factor: Single; const Color: TAlphaColorF): TAlphaColorF; inline;
    class operator Divide(const Color: TAlphaColorF; const Factor: Single): TAlphaColorF; inline;
    function PremultipliedAlpha: TAlphaColorF;
    function UnpremultipliedAlpha: TAlphaColorF;
    function Clamp: TAlphaColorF;
    function ToAlphaColor: TAlphaColor;
  end;

C++

struct DECLSPEC_DRECORD TAlphaColorF
{
public:
    #define TAlphaColorF_Epsilon  (1.525900E-05)
private:
    static bool __fastcall SameComponent(const float Value1, const float Value2);
    static float __fastcall ClampComponent(const float Value);
public:
    float R;
    float G;
    float B;
    float A;
    static TAlphaColorF __fastcall Create(const float R, const float G, const float B, const float A = 1.000000E+00f)/* overload */;
    static TAlphaColorF __fastcall Create(const TAlphaColor Color)/* overload */;
    static TAlphaColorF __fastcall _op_Addition(const TAlphaColorF &Color1, const TAlphaColorF &Color2);
    static TAlphaColorF __fastcall _op_Subtraction(const TAlphaColorF &Color1, const TAlphaColorF &Color2);
    static bool __fastcall _op_Equality(const TAlphaColorF &Color1, const TAlphaColorF &Color2);
    static bool __fastcall _op_Inequality(const TAlphaColorF &Color1, const TAlphaColorF &Color2);
    static TAlphaColorF __fastcall _op_UnaryNegation(const TAlphaColorF &Color);
    static TAlphaColorF __fastcall _op_Multiply(const TAlphaColorF &Color1, const TAlphaColorF &Color2);
    static TAlphaColorF __fastcall _op_Multiply(const TAlphaColorF &Color, const float Factor);
    static TAlphaColorF __fastcall _op_Multiply(const float Factor, const TAlphaColorF &Color);
    static TAlphaColorF __fastcall _op_Division(const TAlphaColorF &Color, const float Factor);
    TAlphaColorF __fastcall PremultipliedAlpha(void);
    TAlphaColorF __fastcall UnpremultipliedAlpha(void);
    TAlphaColorF __fastcall Clamp(void);
    TAlphaColor __fastcall ToAlphaColor(void);
};

Properties

Type Visibility Source Unit Parent
record
struct
public
System.UITypes.pas
System.UITypes.hpp
System.UITypes System.UITypes

Description

TAlphaColorF is a color type that treats each R, G, B, and A component as floats.

TAlphaColorF is used in operations with colors that require high precision, treating each R, G, B, and A component as floats. Overloaded operators allow adding, subtracting, and multiplying colors by using normal operations (such as "FinalColor := (FirstColor + SecondColor) / 2").

Previously, pixel format conversion relied on System.Math.Vectors.TVector3D, which it treated as color, but now pixel format conversion uses the new color types in TVector3D for that purpose.

See Also