SilverLining
SilverLining::Color Class Reference

A RGBA color, where each component is represented as a float from 0-1. More...

#include <Color.h>

Inheritance diagram for SilverLining::Color:
Collaboration diagram for SilverLining::Color:

Public Member Functions

 Color ()
 Default constructor, initializes to black with no translucency.
 
 Color (float red, float green, float blue, float alpha)
 Constructor that takes in RGBA single-precision values that range from 0-1.
 
 Color (float red, float green, float blue)
 Constructor that takes in RGB single-precision values that range from 0-1.
 
 Color (double red, double green, double blue, double alpha)
 Constructor that takes in RGBA double-precision values that range from 0-1.
 
 Color (double red, double green, double blue)
 Constructor that takes in RGB double-precision values that range from 0-1.
 
 Color (int red, int green, int blue, int alpha)
 Constructor that takes in RGBA integer values that range from 0-1.
 
 Color (int red, int green, int blue)
 Constructor that takes in RGB integer values that range from 0-1.
 
Color SILVERLINING_API operator* (float f) const
 Multiplication operator; multiplies each rgb component of the Color by a constant.
 
Color SILVERLINING_API operator* (const Color &c) const
 Multiplication operator; multiplies two Colors together on a per-component basis.
 
Color SILVERLINING_API operator+ (const Color &c) const
 Addition operator; adds two colors together on a per-component basis.
 
bool SILVERLINING_API operator== (const Color &c) const
 Equality operator.
 
bool SILVERLINING_API operator!= (const Color &c) const
 Inequality operator.
 
Vector4 SILVERLINING_API ToVector4 () const
 Convert Color to Vector4.
 
Vector4f SILVERLINING_API ToVector4f () const
 Convert Color to Vector4f.
 
Vector3 SILVERLINING_API ToVector3 () const
 Convert Color to Vector3.
 
bool SILVERLINING_API IsCloseTo (const Color &c, float distanceThreshold) const
 Test if two colors are within a given distance of each other.
 
void SILVERLINING_API ScaleToUnitOrLess (bool hdr)
 If any component of the Color exceeds 1.0, every component will be scaled down uniformly such that the maximum color component equals 1.0.
 
void SILVERLINING_API ScaleToValueOrLess (float value, bool hdr)
 If any component of the Color exceeds the given value, every component will be scaled down uniformly such that the maximum color component equals it.
 
void SILVERLINING_API ClampToUnitOrLess (bool hdr)
 Clamps each color component to be within the range [0, 1.0].
 
Color SILVERLINING_API ToGrayscale () const
 Convert the RGB color to a grayscale value.
 
void SILVERLINING_API Serialize (std::ostream &s) const
 Save this color to disk.
 
void SILVERLINING_API Unserialize (std::istream &s)
 Restore this color from disk.
 

Detailed Description

A RGBA color, where each component is represented as a float from 0-1.

Constructor & Destructor Documentation

◆ Color() [1/7]

SilverLining::Color::Color ( )
inline

Default constructor, initializes to black with no translucency.

◆ Color() [2/7]

SilverLining::Color::Color ( float red,
float green,
float blue,
float alpha )
inline

Constructor that takes in RGBA single-precision values that range from 0-1.

◆ Color() [3/7]

SilverLining::Color::Color ( float red,
float green,
float blue )
inline

Constructor that takes in RGB single-precision values that range from 0-1.

The alpha component is assumed to be 1.0.

◆ Color() [4/7]

SilverLining::Color::Color ( double red,
double green,
double blue,
double alpha )
inline

Constructor that takes in RGBA double-precision values that range from 0-1.

◆ Color() [5/7]

SilverLining::Color::Color ( double red,
double green,
double blue )
inline

Constructor that takes in RGB double-precision values that range from 0-1.

The alpha component is assumed to be 1.0.

◆ Color() [6/7]

SilverLining::Color::Color ( int red,
int green,
int blue,
int alpha )
inline

Constructor that takes in RGBA integer values that range from 0-1.

◆ Color() [7/7]

SilverLining::Color::Color ( int red,
int green,
int blue )
inline

Constructor that takes in RGB integer values that range from 0-1.

The alpha component is assumed to be 1.0.

Member Function Documentation

◆ ClampToUnitOrLess()

void SILVERLINING_API SilverLining::Color::ClampToUnitOrLess ( bool hdr)

Clamps each color component to be within the range [0, 1.0].

◆ operator*() [1/2]

Color SILVERLINING_API SilverLining::Color::operator* ( const Color & c) const
inline

Multiplication operator; multiplies two Colors together on a per-component basis.

◆ operator*() [2/2]

Color SILVERLINING_API SilverLining::Color::operator* ( float f) const
inline

Multiplication operator; multiplies each rgb component of the Color by a constant.

◆ operator+()

Color SILVERLINING_API SilverLining::Color::operator+ ( const Color & c) const
inline

Addition operator; adds two colors together on a per-component basis.

◆ ScaleToUnitOrLess()

void SILVERLINING_API SilverLining::Color::ScaleToUnitOrLess ( bool hdr)

If any component of the Color exceeds 1.0, every component will be scaled down uniformly such that the maximum color component equals 1.0.

◆ ScaleToValueOrLess()

void SILVERLINING_API SilverLining::Color::ScaleToValueOrLess ( float value,
bool hdr )

If any component of the Color exceeds the given value, every component will be scaled down uniformly such that the maximum color component equals it.

◆ Serialize()

void SILVERLINING_API SilverLining::Color::Serialize ( std::ostream & s) const
inline

Save this color to disk.

◆ ToGrayscale()

Color SILVERLINING_API SilverLining::Color::ToGrayscale ( ) const
inline

Convert the RGB color to a grayscale value.

◆ Unserialize()

void SILVERLINING_API SilverLining::Color::Unserialize ( std::istream & s)
inline

Restore this color from disk.


The documentation for this class was generated from the following file: